mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix TTY device listing on Darwin. (#136)
This commit is contained in:
parent
3d08787142
commit
2d1e0f1233
1 changed files with 12 additions and 5 deletions
17
src/tty.c
17
src/tty.c
|
|
@ -49,7 +49,11 @@
|
|||
extern int setspeed2(int fd, int baudrate);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define PATH_SERIAL_DEVICES "/dev/"
|
||||
#else
|
||||
#define PATH_SERIAL_DEVICES "/dev/serial/by-id/"
|
||||
#endif
|
||||
|
||||
static struct termios tio, tio_old, stdout_new, stdout_old, stdin_new, stdin_old;
|
||||
static unsigned long rx_total = 0, tx_total = 0;
|
||||
|
|
@ -824,18 +828,21 @@ error_open:
|
|||
|
||||
void list_serial_devices(void)
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
d = opendir(PATH_SERIAL_DEVICES);
|
||||
|
||||
DIR *d = opendir(PATH_SERIAL_DEVICES);
|
||||
if (d)
|
||||
{
|
||||
struct dirent *dir;
|
||||
while ((dir = readdir(d)) != NULL)
|
||||
{
|
||||
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
|
||||
printf("%s%s\n", PATH_SERIAL_DEVICES, dir->d_name);
|
||||
}
|
||||
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue