1
0
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:
Martin Ling 2013-12-17 17:19:55 +00:00
parent 950faaa94a
commit 537942c9ed

View File

@ -608,8 +608,9 @@ enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
DEBUG("Opening port %s", port->name);
#ifdef _WIN32
DWORD desired_access = 0, flags_and_attributes = 0;
DWORD desired_access = 0, flags_and_attributes = 0, errors;
char *escaped_port_name;
COMSTAT status;
/* Prefix port name with '\\.\' to work with ports above COM9. */
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);
#endif
#ifdef _WIN32
ClearCommError(port->hdl, &errors, &status);
#endif
ret = set_config(port, &data, &config);
if (ret < 0) {