You might notice that each serial device shows up twice in /dev,
once as a tty.* and once as a cu.*. So, what's the difference?
Well, TTY devices are for calling
into UNIX systems, whereas CU (Call-Up)
devices are for calling
out from them (eg, modems). We want to
call-out from our Mac, so /dev/cu.* is the correct device to
use.
The technical difference is that /dev/tty.* devices will wait
(or listen) for DCD (data-carrier-detect), eg, someone calling in,
before responding. /dev/cu.* devices do not assert DCD, so they
will always connect (respond or succeed) immediately.
举例,接入一个USB串口串口转换线后,会查询到两个串口设备。
ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port
/dev/cu.usbserial-FT9FTKXV
/dev/cu.Bluetooth-Modem
ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port
/dev/tty.usbserial-FT9FTKXV
/dev/tty.Bluetooth-Modem