这些设备连接名称是什么?

What are these device connection names?

我想将 Arduino 连接到 linux 计算机。所有设备都列在 /dev/*。例如,当我连接原始的 Arduino mega 时,我得到了这些额外的设备:

/dev/tty.usbmodem...
/dev/cu.usbmodem...

现在,当我想使用这个 C 函数从串口读取数据时:

void read_from_serial() {
    int fd = open("/dev/cu.usbmodem14101", O_RDWR | O_NOCTTY | O_SYNC);
    if(fd < 0) {
        printf("Failed to open connection to device.\n");
        return;
    }

    struct termios tty;
    if (tcgetattr(fd, &tty) < 0) {
        printf("Error: %s\n", strerror(errno));
        return;
    }

    cfsetospeed(&tty, (speed_t)B115200);
    cfsetispeed(&tty, (speed_t)B115200);

    if (tcsetattr(fd, TCSANOW, &tty) != 0) {
        printf("Error: %s\n", strerror(errno));
        return;
    }

    tcflush(fd, TCIOFLUSH);

    char c;
    while (read(fd, &c, 1) == 1) {
        putchar(c);
    }

    close(fd);
}

我需要连接到 /dev/cu... 而不是 /dev/tty... cu 和 tty 是什么意思?

What are these device connection names?

What is the meaning of cu and tty?

tty 代表“TeleTYpewriter”,来自 https://en.wikipedia.org/wiki/Tty_(unix) .

cu代表“Call-Up”设备,用于调用它们的设备,如调制解调器,来自https://pbxbook.com/other/mac-tty.html