0
我現在正在使用下面的代碼,我想知道它錯在哪裏。如何在linux上使用cfsetispeed和tcsetattr命令將端口的波特率配置爲9600?
struct termios options;
int fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);
fcntl(fd, F_SETFL, 0);
tcgetattr(fd, &options);
cfsetispeed(&options, B9600);
tcsetattr(fd, TCSANOW, &options);
是的,這是一個錯字。我更新了它。 – Cacheing 2013-03-03 20:43:06
你認爲代碼是正確的嗎?我只是不確定它是否正確... – Cacheing 2013-03-03 20:45:04
您需要檢查每個命令的返回代碼,以查看哪個失敗。 – 2013-03-03 20:53:46