Clear data at serial port in Linux in C?

前端 未结 1 643
别跟我提以往
别跟我提以往 2021-01-22 14:45

I am testing the sending and receiving programs with the code as

The main() function is below:

#include \"lib.h\"

int fd;

int initport(int fd) {
    s         


        
相关标签:
1条回答
  • 2021-01-22 15:28

    Either your comment or your code is wrong:

    // Set the baud rates to 19200... 
    cfsetispeed(&options, B9600); 
    cfsetospeed(&options, B9600); 
    

    This says it will be setting the baud rate to 19200, but it really sets it to 9600. Maybe you want this:

    // Set the baud rates to 19200... 
    cfsetispeed(&options, B19200);
    cfsetospeed(&options, B19200);
    
    0 讨论(0)
提交回复
热议问题