2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-01-11 02:22:31 +00:00

Also autoconsole when exactly one serial port is detected at all.

This commit is contained in:
Jarrod Johnson
2025-11-25 11:53:50 -05:00
parent 224f349053
commit 3cbac38d57

View File

@@ -107,6 +107,7 @@ serial_port_t search_serial_ports() {
int fd;
int status;
int numfound= 0;
int numpossible = 0;
dir = opendir("/dev");
if (!dir) {
@@ -127,6 +128,11 @@ serial_port_t search_serial_ports() {
}
if (ioctl(fd, TIOCMGET, &status) == 0) {
numpossible++;
if (numfound < 1) {
strncpy(result.devnode, devpath, sizeof(result.devnode));
result.speed = B115200;
}
if (status & TIOCM_CAR) {
strncpy(result.devnode, devpath, sizeof(result.devnode));
numfound++;
@@ -139,7 +145,7 @@ serial_port_t search_serial_ports() {
}
closedir(dir);
if (numfound == 1) {
if (numfound == 1 || numpossible == 1) {
result.valid = 1;
}
return result;