Commit b24efb69 authored by rswindell's avatar rswindell
Browse files

Change the return value and arguments to Get/SetTxFlowControl functions to...

Change the return value and arguments to Get/SetTxFlowControl functions to support multiple types of flow control, not just RTS/CTS, but also DTR/DSR and XON/OFF (and obviously, none).
TODO: consider how the dcb.fRtsControl member might need to be adjusted by the comSetTxFlowControl function (for Win32).
parent ec3945d4
......@@ -98,6 +98,13 @@
#endif
enum COM_FLOW_CONTROL {
COM_FLOW_CONTROL_NONE,
COM_FLOW_CONTROL_RTS_CTS,
COM_FLOW_CONTROL_DTR_DSR,
COM_FLOW_CONTROL_XON_OFF
};
/**************/
/* Prototypes */
/**************/
......@@ -111,8 +118,9 @@ COMIOEXPORT COM_HANDLE comOpen(const char* device);
COMIOEXPORT BOOL comClose(COM_HANDLE);
COMIOEXPORT long comGetBaudRate(COM_HANDLE);
COMIOEXPORT BOOL comSetBaudRate(COM_HANDLE, ulong rate);
COMIOEXPORT BOOL comGetTxFlowControl(COM_HANDLE);
COMIOEXPORT BOOL comSetTxFlowControl(COM_HANDLE, BOOL enable);
COMIOEXPORT enum COM_FLOW_CONTROL
comGetTxFlowControl(COM_HANDLE);
COMIOEXPORT BOOL comSetTxFlowControl(COM_HANDLE, enum COM_FLOW_CONTROL);
COMIOEXPORT int comGetModemStatus(COM_HANDLE);
COMIOEXPORT int comRaiseDTR(COM_HANDLE);
COMIOEXPORT int comLowerDTR(COM_HANDLE);
......
......@@ -112,24 +112,43 @@ BOOL comSetBaudRate(COM_HANDLE handle, unsigned long rate)
return SetCommState(handle, &dcb);
}
BOOL comGetTxFlowControl(COM_HANDLE handle)
enum COM_FLOW_CONTROL comGetTxFlowControl(COM_HANDLE handle)
{
DCB dcb;
if(GetCommState(handle, &dcb) != TRUE)
return COM_ERROR;
return dcb.fOutxCtsFlow;
if(dcb.fOutxCtsFlow)
return COM_FLOW_CONTROL_RTS_CTS;
if(dcb.fOutxDsrFlow)
return COM_FLOW_CONTROL_DTR_DSR;
if(dcb.fOutX)
return COM_FLOW_CONTROL_XON_OFF;
return COM_FLOW_CONTROL_NONE;
}
BOOL comSetTxFlowControl(COM_HANDLE handle, BOOL enable)
BOOL comSetTxFlowControl(COM_HANDLE handle, enum COM_FLOW_CONTROL type)
{
DCB dcb;
if(GetCommState(handle, &dcb) != TRUE)
return FALSE;
dcb.fOutxCtsFlow = enable;
dcb.fOutxCtsFlow = 0;
dcb.fOutxDsrFlow = 0;
dcb.fOutX = 0;
switch(type) {
case COM_FLOW_CONTROL_RTS_CTS:
dcb.fOutxCtsFlow = 1;
break;
case COM_FLOW_CONTROL_DTR_DSR:
dcb.fOutxDsrFlow = 1;
break;
case COM_FLOW_CONTROL_XON_OFF:
dcb.fOutX = 1;
break;
}
return SetCommState(handle, &dcb);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment