Linux, serial port, non-buffering mode

前端 未结 1 538
离开以前
离开以前 2021-01-20 04:07

I am trying to organize nob-blocking read-write functionality with serial port in Linux. Here is the code I have: http://pastebin.com/RSPw7HAi It all works fine, but it is b

相关标签:
1条回答
  • 2021-01-20 04:12

    Looks like I found out the solution.

    /* set input mode (non-canonical, no echo,...) */
    newtio.c_lflag = 0;
    
    newtio.c_cc[VTIME]    = 0;   /* inter-character timer unused */
    newtio.c_cc[VMIN]     = 1;   /* blocking read until 1 char received */
    
    tcflush(fd, TCIFLUSH);
    Taken from : http://tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html
    
    0 讨论(0)
提交回复
热议问题