i.mx6 Linux, Jni IOCTL differences

Source: Internet
Author: User

/*********************************************************************** * i.mx6 Linux, Jni IOCTL differences * Disclaimer: * In the process of using JNI ioctl (), it is found that it cannot be used as a normal Linux function, * the IOCTL () function of 3 parameters must be used. * 2015-12-20 Shenzhen Nanshan Ping Shan village Zengjianfeng *********************************************************** ***********/#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<string.h>#include<jni.h>#include"android/log.h"Static Const Char*tag="Buzz";#defineLOGE (FMT, args ...) __android_log_print (Android_log_error, TAG, FMT, # #args)#defineBuzzer_enable 82#defineBuzzer_freqency 83#defineBuzzer_disable 84/** Class:com_android_buzz_buzz * method:enable * Signature: () V*/Jniexportvoidjnicall java_com_android_buzz_buzz_enable (jnienv*env, Jobject obj) {    intFD = open ("/dev/buzzer", O_RDWR); if(FD = =-1) {LOGE ("Open Buzzer device error."); return; }    //IOCTL (FD, buzzer_enable); //cannot use thisIOCTL (FD, Buzzer_enable,0);//it has to be used.Close (FD); //LOGE ("Enable buzzer device.");}/** Class:com_android_buzz_buzz * method:setfrequency * Signature: (I) V*/Jniexportvoidjnicall java_com_android_buzz_buzz_setfrequency (jnienv*env, Jobject obj, Jint frequency) {    intFD = open ("/dev/buzzer", O_RDWR); if(FD = =-1) {LOGE ("Open Buzzer device error."); return;    } IOCTL (FD, buzzer_freqency, frequency);    Close (FD); //LOGE ("Set buzzer device frequency.");}/** Class:com_android_buzz_buzz * method:disable * Signature: () V*/Jniexportvoidjnicall java_com_android_buzz_buzz_disable (jnienv*env, Jobject obj) {    intFD = open ("/dev/buzzer", O_RDWR); if(FD = =-1) {LOGE ("Open Buzzer device error."); return; }    //IOCTL (FD, buzzer_disable); //cannot use thisIOCTL (FD, Buzzer_disable,0);//it has to be used.Close (FD); //LOGE ("Disable buzzer device.");}

i.mx6 Linux, Jni IOCTL differences

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.