From: Martin Ling Date: Tue, 17 Dec 2013 17:19:55 +0000 (+0000) Subject: Windows: clear errors after port open. X-Git-Tag: libserialport-0.1.0~22 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=537942c9edb37ebfc88d8b06fd330e8492d36bee;p=libserialport.git Windows: clear errors after port open. --- diff --git a/serialport.c b/serialport.c index db77080..e935464 100644 --- a/serialport.c +++ b/serialport.c @@ -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) {