mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Windows: clear errors after port open.
This commit is contained in:
@ -608,8 +608,9 @@ enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
|
|||||||
DEBUG("Opening port %s", port->name);
|
DEBUG("Opening port %s", port->name);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD desired_access = 0, flags_and_attributes = 0;
|
DWORD desired_access = 0, flags_and_attributes = 0, errors;
|
||||||
char *escaped_port_name;
|
char *escaped_port_name;
|
||||||
|
COMSTAT status;
|
||||||
|
|
||||||
/* Prefix port name with '\\.\' to work with ports above COM9. */
|
/* Prefix port name with '\\.\' to work with ports above COM9. */
|
||||||
if (!(escaped_port_name = malloc(strlen(port->name + 5))))
|
if (!(escaped_port_name = malloc(strlen(port->name + 5))))
|
||||||
@ -727,6 +728,10 @@ enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
|
|||||||
data.term.c_cflag |= (CLOCAL | CREAD | HUPCL);
|
data.term.c_cflag |= (CLOCAL | CREAD | HUPCL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
ClearCommError(port->hdl, &errors, &status);
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = set_config(port, &data, &config);
|
ret = set_config(port, &data, &config);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
Reference in New Issue
Block a user