diff options
Diffstat (limited to 'serial/wheel.c')
-rw-r--r-- | serial/wheel.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/serial/wheel.c b/serial/wheel.c index 936f55c..8155734 100644 --- a/serial/wheel.c +++ b/serial/wheel.c | |||
@@ -1,10 +1,16 @@ | |||
1 | #include "serial.h" | 1 | #include "serial.h" |
2 | 2 | ||
3 | int fd; // 轮子的串口文件描述符 | 3 | int fd; // 轮子的串口文件描述符 |
4 | char portname[50] = "/dev/ttyUSB0"; // 串口设备名 | 4 | char *portname; // 串口设备名 |
5 | struct termios tty; | 5 | struct termios tty; |
6 | 6 | ||
7 | bool whellInit() { | 7 | bool whellInit() { |
8 | portname = findUSBDev("wheel"); | ||
9 | if (portname == NULL) { | ||
10 | fprintf(stderr, "Error: Failed to find wheel serial port\n"); | ||
11 | return false; | ||
12 | } | ||
13 | printf("Wheel serial port: %s\n", portname); | ||
8 | // 打开串口 | 14 | // 打开串口 |
9 | fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC); | 15 | fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC); |
10 | if (fd < 0) { | 16 | if (fd < 0) { |