mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Merge 1d0276892f into 6fb3a64ba2
This commit is contained in:
commit
921beee43b
2 changed files with 27 additions and 2 deletions
|
|
@ -60,6 +60,31 @@ int setspeed(int fd, int baudrate)
|
|||
return ioctl(fd, IOSSIOSPEED, (char *)&baudrate);
|
||||
}
|
||||
|
||||
#elif defined (__CYGWIN__)
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
int setspeed(int fd, int baudrate)
|
||||
{
|
||||
HANDLE hSerial = (HANDLE)_get_osfhandle(fd);
|
||||
DCB dcbSerialParams = {0};
|
||||
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
|
||||
|
||||
if (!GetCommState(hSerial, &dcbSerialParams))
|
||||
{
|
||||
int err = GetLastError();
|
||||
errno = err == ERROR_INVALID_HANDLE ? ENODEV : EINVAL;
|
||||
return -1;
|
||||
}
|
||||
dcbSerialParams.BaudRate = baudrate;
|
||||
if (!SetCommState(hSerial, &dcbSerialParams))
|
||||
{
|
||||
int err = GetLastError();
|
||||
errno = err == ERROR_INVALID_HANDLE ? ENODEV : EINVAL;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int setspeed(int fd, int baudrate)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1266,7 +1266,7 @@ void tty_configure(void)
|
|||
BAUDRATE_CASES
|
||||
|
||||
default:
|
||||
#if defined (HAVE_TERMIOS2) || defined (HAVE_IOSSIOSPEED)
|
||||
#if defined (HAVE_TERMIOS2) || defined (HAVE_IOSSIOSPEED) || defined (__CYGWIN__)
|
||||
standard_baudrate = false;
|
||||
break;
|
||||
#else
|
||||
|
|
@ -2361,7 +2361,7 @@ void tty_wait_for_device(void)
|
|||
// Happens when port unpluged
|
||||
if (errno == EACCES)
|
||||
{
|
||||
goto error;
|
||||
break;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
if (errno == EBADF)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue