enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
{
+ struct port_data data;
+ struct sp_port_config config;
+ enum sp_return ret;
+
TRACE("%p, %x", port, flags);
CHECK_PORT();
}
#else
int flags_local = 0;
- struct port_data data;
- struct sp_port_config config;
- int ret;
/* Map 'flags' to the OS-specific settings. */
if (flags & (SP_MODE_READ | SP_MODE_WRITE))
if ((port->fd = open(port->name, flags_local)) < 0)
RETURN_FAIL("open() failed");
+#endif
ret = get_config(port, &data, &config);
RETURN_CODEVAL(ret);
}
+ /* Set sane port settings. */
+#ifdef _WIN32
+ data.dcb.fBinary = TRUE;
+ data.dcb.fDsrSensitivity = FALSE;
+ data.dcb.fErrorChar = FALSE;
+ data.dcb.fNull = FALSE;
+ data.dcb.fAbortOnError = TRUE;
+#else
/* Turn off all fancy termios tricks, give us a raw channel. */
data.term.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IUCLC|IMAXBEL);
data.term.c_oflag &= ~(OPOST|OLCUC|ONLCR|OCRNL|ONOCR|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
/* Ignore modem status lines; enable receiver; leave control lines alone on close. */
data.term.c_cflag |= (CLOCAL | CREAD | HUPCL);
+#endif
ret = set_config(port, &data, &config);
sp_close(port);
RETURN_CODEVAL(ret);
}
-#endif
RETURN_OK();
}