LoginSignup
3
3

More than 3 years have passed since last update.

macosのcuコマンドで入力が効かない無効のときは/dev/cuを使う

Last updated at Posted at 2021-01-24

macosのcuコマンドで入力が効かないときは/dev/cuを使う

この記事では,UUCPのcuコマンドで入力が効かず,screenコマンドなら動作する場合の対処法を説明する.

TL;DR

こうすれば良い.

sudo cu -l /dev/cu.usbserial
  • /dev/cu.usbserial* のパスは,使用するUSBシリアルケーブルによって異なる.
    • StartechのUSB-C to RS232Cならば, /dev/cu.usbserial-<シリアル番号>となる.
    • シリアル番号は,システム情報.appでも確認できる.
  • /dev/tty.usbserial は,モデムとかで使う.

なぜ?

/dev/tty.usbserialは,モデムやコールアウト/コールインプロセス間で共有する場合に使うものらしい(詳しいことは調べてません).

cuコマンドは,デバイスへの排他的アクセスが必要なので,専有を前提としている/dev/cu.usbserialを使用する.

なお,cuのコマンド引数ではハードウェアフロー制御を設定できず,/etc/uucp配下にportコンフィグファイルを作成すれば動作するいう報告は,どうやらCatalinaでは動作しないらしい(原因究明はしてない).
ハードウェアフロー制御はsttyコマンドで設定できるので, sudo stty -f /dev/cu.usbserial -crtsctsとする手はあるが,残念ながら効果がなかった.

ところでシリアル通信のオプションは?

細く指定せずとも,大抵のネットワーク機器は,--speed 9600--speed 115200で動く.

9600 bps, 8 bit, パリティなし, 1 stop bit,XON/XOFFフロー制御なし,にするなら,

cu -s 9600 --parity=none --nostop

どんな設定になってるか確認したいければ,デバッグ有効にするといろいろ教えてくれる.

% sudo cu -l /dev/cu.usbserial -d 
cu: fconn_open: Opening port /dev/cu.usbserial(default speed)
cu: fsserial_open: Baud rate is 9600
cu: fconn_set: Changing setting to 0, 0, 2
Connected.
cu: fconn_write: Writing 1 "\r"


FreeBSD/arm (Amnesiac) (ttyu0)

login: 

sttyでも見れる.

% sudo stty -af /dev/cu.usbserial
speed 9600 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
    -echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin
    -nokerninfo -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel -iutf8
    -ignbrk -brkint -inpck -ignpar -parmrk
oflags: -opost -onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 1; werase = ^W;

詳しくは--helpman cuでどうぞ.

# cu --help
Taylor UUCP 1.07, copyright (C) 1991, 92, 93, 94, 1995, 2002 Ian Lance Taylor
Usage: cu [options] [system or phone-number]
 -a,-p,--port port: Use named port
 -l,--line line: Use named device (e.g. tty0)
 -s,--speed,--baud speed, -#: Use given speed
 -c,--phone phone: Phone number to call
 -z,--system system: System to call
 -e: Set even parity
 -o: Set odd parity
 --parity={odd,even}: Set parity
 -E,--escape char: Set escape character
 -h,--halfduplex: Echo locally
 --nostop: Turn off XON/XOFF handling
 -t,--mapcr: Map carriage return to carriage return/linefeed
 -n,--prompt: Prompt for phone number
 -d: Set maximum debugging level
 -x,--debug debug: Set debugging type
 -I,--config file: Set configuration file to use
 -v,--version: Print version and exit
 --help: Print help and exit
Report bugs to taylor-uucp@gnu.org

screen使えばええやん?

screenscreenとして使いたいので・・・

参考

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3