mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix listing of serial devices in MSYS2/Cygwin
We generally try to list serial devices by ID but in the MSYS2/Cygwin environment serial devices are not available by ID and so we simply list the basic serial device paths instead.
This commit is contained in:
parent
3c8d7fa786
commit
68fc159654
1 changed files with 9 additions and 5 deletions
12
src/tty.c
12
src/tty.c
|
|
@ -54,8 +54,13 @@
|
|||
|
||||
#ifdef __APPLE__
|
||||
#define PATH_SERIAL_DEVICES "/dev/"
|
||||
#define PREFIX_TTY_DEVICES "tty."
|
||||
#elifdef __CYGWIN__
|
||||
#define PATH_SERIAL_DEVICES "/dev/serial/by-id/"
|
||||
#define PREFIX_TTY_DEVICES "ttyS"
|
||||
#else
|
||||
#define PATH_SERIAL_DEVICES "/dev/serial/by-id/"
|
||||
#define PREFIX_TTY_DEVICES ""
|
||||
#endif
|
||||
|
||||
#ifndef CMSPAR
|
||||
|
|
@ -1343,13 +1348,12 @@ void list_serial_devices(void)
|
|||
{
|
||||
if ((strcmp(dir->d_name, ".")) && (strcmp(dir->d_name, "..")))
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
#define TTY_DEVICES_PREFIX "tty."
|
||||
if (!strncmp(dir->d_name, TTY_DEVICES_PREFIX, sizeof(TTY_DEVICES_PREFIX) - 1))
|
||||
#endif
|
||||
if (!strncmp(dir->d_name, PREFIX_TTY_DEVICES, sizeof(PREFIX_TTY_DEVICES) - 1))
|
||||
{
|
||||
printf("%s%s\n", PATH_SERIAL_DEVICES, dir->d_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue