ºìÁªLinuxÃÅ»§
Linux°ïÖú

android ´®¿Ú»º´æ³¬Ê±ÅäÖü¬ÊÖÎÊÌâ

·¢²¼Ê±¼ä:2012-12-11 09:58:11À´Ô´:ºìÁª×÷Õß:³Æ°Ô¸â¸»Ë§
¸÷λ´óÉñ£¬ÎÒÔÚÈýÐǵÄqt210¿ª·¢°åÉÏ·ÉÏßÁË´®¿Ú£¬µ±´®¿ÚÊý¾Ý¿ìËÙ´óÁ¿·¢ËÍÊý¾Ý£¨ÉÏ°Ùkb£¬µ¥Æ¬»úÄDZßÎÒÎÞ·¨¿ØÖÆ·¢ËÍ£©µ½android¶Ëʱ»á³öÏÖ½ÓÊÕ³ö´í£¬ÓÐʱºò¾ÍÖ»ÄܽÓÊÕµ½¼¸¸ö×Ö½Ú»ò¼¸Ê®¸ö×Ö½Ú£¬»¹ÊÇÂҵģ¬ÎÒÉϲã³ÌÐò¼Ü¹¹ÊÇ8¸ö×Ö½ÚÒ»´Î´Î¶Á£¬Õâ¸öÖмä»áÓÐÑÓ³Ù£¬¶ÁÁË8¸ö×Ö½Ú´¦ÀíºÃÁËÒÔºóÔÙÍùÏÂÃæ¶Á¡£¶øÎÒÓÐʱºòÊý¾Ý²»´¦ÀíÒ»´ÎÐÔ¶ÁÍ꣬¶Áµ½µÄÊý¾Ý¾Í¶àµã¡£ÎÒ»³ÒÉÊÇ´®¿Ú»º´æÒç³ö»ò³¬Ê±ÎÊÌ⣨µ¥Æ¬»úÄDZ߷¢ËÍÉÙÁ¿Êý¾Ý100×Ö½ÚÒÔÏ£¬¶ÁȡûÓÐÎÊÌ⣩¡£¸÷λ´óÉñ¿´¿´ÎÒµÄÅäÖÃÄÄÀïÓÐÎÊÌâÐèÒªÐ޸ġ£
¶ÁÈ¡ÊÇselectÒì²½¶ÁÈ¡£¬Í£Ö¹Î»Îª1£¬8Êý¾Ý룬ÎÞУÑé¡£ÅäÖÃÈçÏ¡£
struct termios options;
fcntl(pHandle, F_SETFL, 0);

tcgetattr(pHandle, &options);
//bzero(&options, sizeof(options));
cfmakeraw(&options);
cfsetispeed(&options, B115200);//²¨ÌØÂʵ¥Æ¬»ú¶¨ËÀµÄ£¬ÎÒÕâ±ßÎÞ·¨¿ØÖÆ
cfsetospeed(&options, B115200);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_cflag &= ~CRTSCTS;
options.c_iflag |= (IXOFF);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_oflag &= ~OPOST;


tcflush(pHandle, TCIFLUSH);
if (tcsetattr(pHandle, TCSANOW, &options) != 0) {
LOGE("set_uart_opt failed");
close(pHandle);
return -1;
}
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ