*list_ptr = list;
RETURN_OK();
case SP_ERR_SUPP:
- DEBUG_ERROR(SP_ERR_SUPP, "Enumeration not supported on this platform.");
+ DEBUG_ERROR(SP_ERR_SUPP, "Enumeration not supported on this platform");
default:
if (list)
sp_free_port_list(list);
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))))
data.term.c_cflag |= (CLOCAL | CREAD | HUPCL);
#endif
+#ifdef _WIN32
+ if (ClearCommError(port->hdl, &errors, &status) == 0)
+ RETURN_FAIL("ClearCommError() failed");
+#endif
+
ret = set_config(port, &data, &config);
if (ret < 0) {
RETURN_FAIL("WriteFile() failed");
}
} else {
- DEBUG("Single byte written immediately.");
+ DEBUG("Single byte written immediately");
written++;
}
}
- DEBUG("All bytes written immediately.");
+ DEBUG("All bytes written immediately");
RETURN_VALUE("%d", written);
#else
COMSTAT comstat;
if (ClearCommError(port->hdl, &errors, &comstat) == 0)
- RETURN_FAIL("ClearComError() failed");
+ RETURN_FAIL("ClearCommError() failed");
RETURN_VALUE("%d", comstat.cbInQue);
#else
int bytes_waiting;
COMSTAT comstat;
if (ClearCommError(port->hdl, &errors, &comstat) == 0)
- RETURN_FAIL("ClearComError() failed");
+ RETURN_FAIL("ClearCommError() failed");
RETURN_VALUE("%d", comstat.cbOutQue);
#else
int bytes_waiting;
if (config->parity >= 0) {
switch (config->parity) {
- /* Note: There's also SPACEPARITY, MARKPARITY (unneeded so far). */
case SP_PARITY_NONE:
data->dcb.Parity = NOPARITY;
break;