UUCP cu command

cu 是 uucp 套件里的小工具,用做串口通讯感觉特别棒。cu 可以直接带参数连接串口:

cu -l /dev/tts/USB0 -s 115200

cu 的配置也很简单,在 /etc/uucp 下修改两个文件就可以了:

# /etc/uucp/port

# /dev/ttyS0
port Serial0_115200
type direct
device /dev/ttyS0
speed 115200
hardflow false

# for Moto E2
port ACM0_38400
type direct
device /dev/ttyACM0
speed 38400
hardflow false

# for USB serial port
port USB0_115200
type direct
device /dev/ttyUSB0
speed 115200
hardflow false

相应的在 /etc/uucp/sys 中有如下设置:

# /etc/uucp/sys

# /dev/ttyS0
system S0
port Serial0_115200
time any

# /dev/ttyACM0
system ACM0
port ACM0_38400
time any

# /dev/ttyUSB0
system USB0
port USB0_115200
time any

然后就可以使用下列命令连接串口,以 USB0 为例:

$ cu USB0
Connected.

要退出连接状态, 输入 ~. 即可。更多命令参看 man cu。

USB 转串口时,udev 会自动在 /dev 下生成 /dev/tts/USB0 和 指向前者的连接 /dev/ttyUSB0。

root@jick-laptop:~# ls -l /dev/ttyUSB0 /dev/tts/USB0
crw-rw---- 1 root uucp 188, 0 2007-07-27 10:49 /dev/tts/USB0
lrwxrwxrwx 1 root root      8 2007-07-27 10:33 /dev/ttyUSB0 -> tts/USB0

如果想让普通用户使用串口调试,将他加入 uucp 用户组,然后使用 /dev/tts/USB0 是比较好的方法。
page_revision: 0, last_edited: 1203334743|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License