Serial-Port

從終端讀取串口參數

  • March 27, 2017

假設我執行了一個讀取/寫入串列埠 (/dev/ttyS0) 的程序。我知道該程序使用波特率19200並動態設置奇偶校驗位(標記奇偶校驗或空間奇偶校驗)。

是否可以從終端檢查這些參數?

我試過setserial -g /dev/ttyS0。這是輸出(與奇偶校驗位和波特率無關):

/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4

改用stty

stty -F /dev/ttyS0 -a

範例輸出:

speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

引用自:https://unix.stackexchange.com/questions/353569