RETURN_CODEVAL(ret);
}
+ /*
+ * Assume a default baudrate if the OS does not provide one.
+ * Cannot assign -1 here since Windows holds the baudrate in
+ * the DCB and does not configure the rate individually.
+ */
+ if (config.baudrate == 0) {
+ config.baudrate = 9600;
+ }
+
/* Set sane port settings. */
#ifdef _WIN32
data.dcb.fBinary = TRUE;
data.term.c_cc[VTIME] = 0;
/* Ignore modem status lines; enable receiver; leave control lines alone on close. */
- data.term.c_cflag |= (CLOCAL | CREAD | HUPCL);
+ data.term.c_cflag |= (CLOCAL | CREAD);
+ data.term.c_cflag &= ~(HUPCL);
#endif
#ifdef _WIN32
unsigned char *ptr = (unsigned char *) buf;
struct timeout timeout;
fd_set fds;
- int result;
+ ssize_t result;
timeout_start(&timeout, timeout_ms);
unsigned char *ptr = (unsigned char *) buf;
struct timeout timeout;
fd_set fds;
- int result;
+ ssize_t result;
timeout_start(&timeout, timeout_ms);
size_t bytes_read = 0;
struct timeout timeout;
fd_set fds;
- int result;
+ ssize_t result;
timeout_start(&timeout, timeout_ms);