端末からシリアルポートパラメータを読み取る

端末からシリアルポートパラメータを読み取る

シリアルポート(/dev/ttyS0)を読み書きするプログラムを実行するとします。私はプログラムが19200の転送速度を使用し、パリティビット(マークパリティまたはスペースパリティを示す)を動的に設定することを知っています。

端末でこれらのパラメータを確認できますか?

頑張りましたsetserial -g /dev/ttyS0。出力は次のとおりです(パリティビットと転送速度とは無関係)。

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

ベストアンサー1

代わりに使用してください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

おすすめ記事