freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

嵌入式linux編程基礎(chǔ)-資料下載頁(yè)

2025-05-12 06:45本頁(yè)面
  

【正文】 否激活或者停止)。 串口使用 ( 2) ? 讀寫(xiě)串口 讀寫(xiě)串口操作和讀寫(xiě)普通文件一樣,使用 read()和 write()函數(shù) : write(fd, buff, strlen(buff))。 read(fd, buff, BUFFER_SIZE)。 接下來(lái)可恢復(fù)串口的狀態(tài)為阻塞狀態(tài),用于等待串口 數(shù)據(jù)的讀入 : 接著可以測(cè)試打開(kāi)文件描述符是否連接到一個(gè)終端設(shè)備,以進(jìn)一步確認(rèn)串口是否正確打開(kāi) : ftl(fd, F_SETFL, 0)。 isatty(STDIN_FILENO)。 示例 — 串行端口程序設(shè)計(jì) include include include include include sys/ include define BAUDRATE B115200 define COM1 /dev/ttyS0 define COM2 /dev/ttyS1 define ENDMINITERM 27 /* ESC to quit miniterm */ define FALSE 0 define TRUE 1 volatile int STOP=FALSE。 volatile int fd。 void child_handler(int s) { printf(stop!!!\n)。 STOP=TRUE。 } void* keyboard(void * data) { int c。 for (。){ c=getchar()。 if( c== ENDMINITERM){ STOP=TRUE。 break 。} } return NULL。 } /* modem input handler */ void* receive(void * data) { int c。 printf(read modem\n)。 while (STOP==FALSE) { read(fd,amp。c,1)。 /* port */ write(1,amp。c,1)。 /* stdout */ } printf(exit from reading modem\n)。 return NULL。 } void* send(void * data) { int c=39。039。 printf(send data\n)。 while (STOP==FALSE) { c++。 c %= 255。 write(fd,amp。c,1)。 /* stdout */ usleep(100000)。 } return NULL。 /* wait for child to die or it will bee a zombie */ } int main(int argc,char** argv) { struct termios oldtio,newtio,oldstdtio,newstdtio。 struct sigaction sa。 int ok。 pthread_t th_a, th_b, th_c。 void * retval。 if( argc 1) fd = open(COM2, O_RDWR )。 else fd = open(COM1, O_RDWR )。 //| O_NOCTTY |O_NONBLOCK)。 if (fd 0) { perror(COM1)。 exit(1)。 } tcgetattr(0,amp。oldstdtio)。 tcgetattr(fd,amp。oldtio)。 /* save current modem settings */ tcgetattr(fd,amp。newstdtio)。 /* get working stdtio */ = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD。 /*ctrol flag*/ = IGNPAR。 /*input flag, 忽略幀和奇偶校驗(yàn)錯(cuò) */ = 0。 /*output flag*/ = 0。 [VMIN]=1。 [VTIME]=0。 /* now clean the modem line and activate the settings for modem */ tcflush(fd, TCIFLUSH)。 //刷新數(shù)據(jù)線上的數(shù)據(jù)。 tcsetattr(fd,TCSANOW,amp。newtio)。//串口屬性設(shè)置立即生效。 = child_handler。 = 0。 sigaction(SIGCHLD,amp。sa,NULL)。 /* handle dying child */ pthread_create(amp。th_a, NULL, keyboard, 0)。 pthread_create(amp。th_b, NULL, receive, 0)。 pthread_create(amp。th_c, NULL, send, 0)。 pthread_join(th_a, amp。retval)。 pthread_join(th_b, amp。retval)。 pthread_join(th_c, amp。retval)。 tcsetattr(fd,TCSANOW,amp。oldtio)。 /* restore old modem setings */ tcsetattr(0,TCSANOW,amp。oldstdtio)。 /* restore old tty setings */ close(fd)。 exit(0)。 }
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1