Update of /cvsroot/com0com/hub4com/plugins/serial
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv7231/serial
Modified Files:
comio.cpp comio.h comport.cpp comport.h
Log Message:
Added
HUB_MSG_TYPE_GET_ESC_OPTS
HUB_MSG_TYPE_FAIL_ESC_OPTS
HUB_MSG_TYPE_BREAK_STATUS
Index: comport.cpp
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** comport.cpp 22 Aug 2008 12:45:34 -0000 1.8
--- comport.cpp 22 Aug 2008 16:57:12 -0000 1.9
***************
*** 20,23 ****
--- 20,29 ----
*
* $Log$
+ * Revision 1.9 2008/08/22 16:57:12 vfrolov
+ * Added
+ * HUB_MSG_TYPE_GET_ESC_OPTS
+ * HUB_MSG_TYPE_FAIL_ESC_OPTS
+ * HUB_MSG_TYPE_BREAK_STATUS
+ *
* Revision 1.8 2008/08/22 12:45:34 vfrolov
* Added masking to HUB_MSG_TYPE_MODEM_STATUS and HUB_MSG_TYPE_LINE_STATUS
***************
*** 84,93 ****
filterX(FALSE),
maskOutPins(0),
! options(0),
writeQueueLimit(256),
writeQueued(0),
writeLost(0),
writeLostTotal(0),
! errors(0)
{
filterX = comParams.InX();
--- 90,101 ----
filterX(FALSE),
maskOutPins(0),
! maskMst(0),
! intercepted_options(0),
writeQueueLimit(256),
writeQueued(0),
writeLost(0),
writeLostTotal(0),
! errors(0),
! _inOptions(0)
{
filterX = comParams.InX();
***************
*** 171,174 ****
--- 179,207 ----
};
+ static void WarnIgnoredInOptions(
+ const char *pHead,
+ const char *pTail,
+ DWORD options,
+ BYTE optsMst,
+ BYTE optsLsr)
+ {
+ if (optsMst) {
+ cerr << pHead << " WARNING: Changing of MODEM STATUS bit(s) 0x"
+ << hex << (unsigned)optsMst << dec << " ["
+ << FieldToName(codeNameTableModemStatus, optsMst)
+ << "] will be ignored by driver" << pTail << endl;
+ }
+
+ if (optsLsr) {
+ cerr << pHead << " WARNING: Changing of LINE STATUS bit(s) 0x"
+ << hex << (unsigned)optsLsr << dec << " ["
+ << FieldToName(codeNameTableLineStatus, optsLsr)
+ << "] will be ignored by driver" << pTail << endl;
+ }
+
+ cerr << pHead << " WARNING: Requested option(s) 0x"
+ << hex << options << dec << " will be ignored by driver" << pTail << endl;
+ }
+
static FIELD2NAME codeNameTableComEvents[] = {
TOFIELD2NAME2(EV_, CTS),
***************
*** 190,242 ****
BYTE *pBuf = NULL;
DWORD done = 0;
! if (options & GO_ESCAPE_MODE) {
! options = SetEscMode(handle, options, 'a'/*0xFF*/, &pBuf, &done);
! } else {
! if ((options & GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS)) != 0)
! events |= EV_CTS;
! if ((options & GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)) != 0)
! events |= EV_DSR;
! if ((options & GO_V2O_MODEM_STATUS(MODEM_STATUS_DCD)) != 0)
! events |= EV_RLSD;
! if ((options & GO_V2O_MODEM_STATUS(MODEM_STATUS_RI)) != 0)
! events |= EV_RING;
! options &= ~GO_V2O_MODEM_STATUS(
! MODEM_STATUS_CTS|MODEM_STATUS_DSR|MODEM_STATUS_DCD|MODEM_STATUS_RI);
! }
! BYTE optsMst = GO_O2V_MODEM_STATUS(options);
! if (optsMst) {
! cerr << name << " WARNING: Changing of MODEM STATUS bit(s) 0x"
! << hex << (unsigned)optsMst << dec << " ["
! << FieldToName(codeNameTableModemStatus, optsMst)
! << "] will be ignored" << endl;
}
! BYTE optsLsr = GO_O2V_LINE_STATUS(options);
! if (optsLsr) {
! cerr << name << " WARNING: Changing of LINE STATUS bit(s) 0x"
! << hex << (unsigned)optsLsr << dec << " ["
! << FieldToName(codeNameTableLineStatus, optsLsr)
! << "] will be ignored" << endl;
}
! HUB_MSG msg;
! if (options) {
! cerr << name << " WARNING: Requested option(s) 0x"
! << hex << options << dec << " will be ignored" << endl;
! msg.type = HUB_MSG_TYPE_FAIL_IN_OPTS;
! msg.u.val = options;
! pOnRead(hHub, hMasterPort, &msg);
}
if (events) {
if (!SetComEvents(handle, &events) || !StartWaitCommEvent()) {
--- 223,286 ----
BYTE *pBuf = NULL;
DWORD done = 0;
+ HUB_MSG msg;
! if (intercepted_options & GO_ESCAPE_MODE) {
! DWORD escapeOptions = 0;
! msg.type = HUB_MSG_TYPE_GET_ESC_OPTS;
! msg.u.pv.pVal = &escapeOptions;
! pOnRead(hHub, hMasterPort, &msg);
! escapeOptions = SetEscMode(handle, escapeOptions, &pBuf, &done);
! if ((escapeOptions & ESC_OPTS_V2O_ESCCHAR(-1)) == 0) {
! InOptionsAdd(GO_ESCAPE_MODE);
! if (escapeOptions) {
! WarnIgnoredInOptions(name.c_str(), " (escape mode)",
! escapeOptions,
! ESC_OPTS_O2V_MST(escapeOptions),
! ESC_OPTS_O2V_LSR(escapeOptions));
! msg.type = HUB_MSG_TYPE_FAIL_ESC_OPTS;
! msg.u.val = escapeOptions;
! pOnRead(hHub, hMasterPort, &msg);
! }
! }
! }
! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS)) {
! events |= EV_CTS;
! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS));
}
! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)) {
! events |= EV_DSR;
! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR));
! }
! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_DCD)) {
! events |= EV_RLSD;
! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_DCD));
}
! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_RI)) {
! events |= EV_RING;
! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_RI));
! }
! DWORD fail_options = (intercepted_options & ~InOptions());
! if (fail_options) {
! WarnIgnoredInOptions(name.c_str(), "",
! fail_options,
! GO_O2V_MODEM_STATUS(fail_options),
! GO_O2V_LINE_STATUS(fail_options));
}
+ msg.type = HUB_MSG_TYPE_FAIL_IN_OPTS;
+ msg.u.val = fail_options;
+ pOnRead(hHub, hMasterPort, &msg);
+
if (events) {
if (!SetComEvents(handle, &events) || !StartWaitCommEvent()) {
***************
*** 250,255 ****
}
- CheckComEvents(DWORD(-1));
-
if (!StartRead()) {
pBufFree(pBuf);
--- 294,297 ----
***************
*** 265,272 ****
msg.u.buf.pBuf = pBuf;
msg.u.buf.size = done;
-
pOnRead(hHub, hMasterPort, &msg);
}
return TRUE;
}
--- 307,315 ----
msg.u.buf.pBuf = pBuf;
msg.u.buf.size = done;
pOnRead(hHub, hMasterPort, &msg);
}
+ CheckComEvents(DWORD(-1));
+
return TRUE;
}
***************
*** 304,317 ****
if (pInMsg->type == HUB_MSG_TYPE_GET_IN_OPTS) {
! // get supported options from subsequent filters separately
! DWORD supported_options = pInMsg->u.pv.val & (
GO_ESCAPE_MODE |
GO_RBR_STATUS |
GO_RLC_STATUS |
GO_V2O_MODEM_STATUS(-1) |
GO_V2O_LINE_STATUS(-1));
! pInMsg->u.pv.val &= ~supported_options;
pInMsg = pMsgInsertNone(pInMsg, HUB_MSG_TYPE_EMPTY);
--- 347,361 ----
if (pInMsg->type == HUB_MSG_TYPE_GET_IN_OPTS) {
! // get interceptable options from subsequent filters separately
! DWORD interceptable_options = (pInMsg->u.pv.val &
GO_ESCAPE_MODE |
GO_RBR_STATUS |
GO_RLC_STATUS |
+ GO_BREAK_STATUS |
GO_V2O_MODEM_STATUS(-1) |
GO_V2O_LINE_STATUS(-1));
! pInMsg->u.pv.val &= ~interceptable_options;
pInMsg = pMsgInsertNone(pInMsg, HUB_MSG_TYPE_EMPTY);
***************
*** 319,324 ****
if (pInMsg) {
pInMsg->type = HUB_MSG_TYPE_GET_IN_OPTS;
! pInMsg->u.pv.pVal = &options;
! pInMsg->u.pv.val = supported_options;
}
}
--- 363,368 ----
if (pInMsg) {
pInMsg->type = HUB_MSG_TYPE_GET_IN_OPTS;
! pInMsg->u.pv.pVal = &intercepted_options;
! pInMsg->u.pv.val = interceptable_options;
}
}
***************
*** 440,444 ****
return FALSE;
! BYTE addedPins = (~maskOutPins & SO_O2V_PIN_STATE(pMsg->u.val));
if (addedPins & PIN_STATE_RTS) {
--- 484,488 ----
return FALSE;
! WORD addedPins = (~maskOutPins & SO_O2V_PIN_STATE(pMsg->u.val));
if (addedPins & PIN_STATE_RTS) {
***************
*** 558,562 ****
void ComPort::CheckComEvents(DWORD eMask)
{
! if ((eMask & (EV_CTS|EV_DSR|EV_RLSD|EV_RING)) != 0) {
DWORD stat;
--- 602,606 ----
void ComPort::CheckComEvents(DWORD eMask)
{
! if (maskMst && (eMask & (EV_CTS|EV_DSR|EV_RLSD|EV_RING)) != 0) {
DWORD stat;
***************
*** 572,576 ****
msg.type = HUB_MSG_TYPE_MODEM_STATUS;
! msg.u.val = ((DWORD)(BYTE)stat | VAL2MASK(MODEM_STATUS_CTS|MODEM_STATUS_DSR|MODEM_STATUS_DCD|MODEM_STATUS_RI));
pOnRead(hHub, hMasterPort, &msg);
--- 616,620 ----
msg.type = HUB_MSG_TYPE_MODEM_STATUS;
! msg.u.val = ((DWORD)(BYTE)stat | VAL2MASK(maskMst));
pOnRead(hHub, hMasterPort, &msg);
Index: comport.h
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** comport.h 20 Aug 2008 14:30:19 -0000 1.7
--- comport.h 22 Aug 2008 16:57:12 -0000 1.8
***************
*** 20,23 ****
--- 20,29 ----
*
* $Log$
+ * Revision 1.8 2008/08/22 16:57:12 vfrolov
+ * Added
+ * HUB_MSG_TYPE_GET_ESC_OPTS
+ * HUB_MSG_TYPE_FAIL_ESC_OPTS
+ * HUB_MSG_TYPE_BREAK_STATUS
+ *
* Revision 1.7 2008/08/20 14:30:19 vfrolov
* Redesigned serial port options
***************
*** 106,111 ****
int countXoff;
BOOL filterX;
! BYTE maskOutPins;
! DWORD options;
DWORD writeQueueLimit;
--- 112,118 ----
int countXoff;
BOOL filterX;
! WORD maskOutPins;
! WORD maskMst;
! DWORD intercepted_options;
DWORD writeQueueLimit;
***************
*** 114,117 ****
--- 121,141 ----
DWORD writeLostTotal;
DWORD errors;
+
+ private:
+ DWORD _inOptions;
+
+ DWORD InOptions() const {
+ return _inOptions;
+ }
+
+ void InOptionsDel(DWORD opts) {
+ _inOptions &= ~opts;
+ maskMst = GO_O2V_MODEM_STATUS(_inOptions);
+ }
+
+ void InOptionsAdd(DWORD opts) {
+ _inOptions |= opts;
+ maskMst = GO_O2V_MODEM_STATUS(_inOptions);
+ }
};
///////////////////////////////////////////////////////////////
Index: comio.h
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/comio.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** comio.h 20 Aug 2008 14:30:19 -0000 1.5
--- comio.h 22 Aug 2008 16:57:12 -0000 1.6
***************
*** 20,23 ****
--- 20,29 ----
*
* $Log$
+ * Revision 1.6 2008/08/22 16:57:12 vfrolov
+ * Added
+ * HUB_MSG_TYPE_GET_ESC_OPTS
+ * HUB_MSG_TYPE_FAIL_ESC_OPTS
+ * HUB_MSG_TYPE_BREAK_STATUS
+ *
* Revision 1.5 2008/08/20 14:30:19 vfrolov
* Redesigned serial port options
***************
*** 66,70 ****
extern BOOL SetComEvents(HANDLE handle, DWORD *events);
extern BOOL CommFunction(HANDLE handle, DWORD func);
! extern DWORD SetEscMode(HANDLE handle, DWORD options, BYTE escapeChar, BYTE **ppBuf, DWORD *pDone);
///////////////////////////////////////////////////////////////
class ReadOverlapped : private OVERLAPPED
--- 72,76 ----
extern BOOL SetComEvents(HANDLE handle, DWORD *events);
extern BOOL CommFunction(HANDLE handle, DWORD func);
! extern DWORD SetEscMode(HANDLE handle, DWORD escOptions, BYTE **ppBuf, DWORD *pDone);
///////////////////////////////////////////////////////////////
class ReadOverlapped : private OVERLAPPED
Index: comio.cpp
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/comio.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** comio.cpp 20 Aug 2008 14:30:19 -0000 1.5
--- comio.cpp 22 Aug 2008 16:57:11 -0000 1.6
***************
*** 20,23 ****
--- 20,29 ----
*
* $Log$
+ * Revision 1.6 2008/08/22 16:57:11 vfrolov
+ * Added
+ * HUB_MSG_TYPE_GET_ESC_OPTS
+ * HUB_MSG_TYPE_FAIL_ESC_OPTS
+ * HUB_MSG_TYPE_BREAK_STATUS
+ *
* Revision 1.5 2008/08/20 14:30:19 vfrolov
* Redesigned serial port options
***************
*** 303,307 ****
}
! DWORD SetEscMode(HANDLE handle, DWORD options, BYTE escapeChar, BYTE **ppBuf, DWORD *pDone)
{
_ASSERTE(ppBuf != NULL);
--- 309,313 ----
}
! DWORD SetEscMode(HANDLE handle, DWORD escOptions, BYTE **ppBuf, DWORD *pDone)
{
_ASSERTE(ppBuf != NULL);
***************
*** 310,328 ****
_ASSERTE(*pDone == 0);
if (!escapeChar)
! return options;
ULONG opts = (C0CE_INSERT_IOCTL_GET|C0CE_INSERT_IOCTL_RXCLEAR);
! if (options & GO_V2O_MODEM_STATUS(-1))
opts |= C0CE_INSERT_ENABLE_MST;
! if (options & GO_V2O_LINE_STATUS(LINE_STATUS_BI))
opts |= C0CE_INSERT_ENABLE_LSR_BI;
! if (options & GO_RBR_STATUS)
opts |= C0CE_INSERT_ENABLE_RBR;
! if (options & GO_RLC_STATUS)
opts |= C0CE_INSERT_ENABLE_RLC;
--- 316,342 ----
_ASSERTE(*pDone == 0);
+ BYTE escapeChar = ESC_OPTS_O2V_ESCCHAR(escOptions);
+
if (!escapeChar)
! return escOptions | ESC_OPTS_V2O_ESCCHAR(-1);
ULONG opts = (C0CE_INSERT_IOCTL_GET|C0CE_INSERT_IOCTL_RXCLEAR);
! #define MODEM_STATUS_BITS (MODEM_STATUS_CTS|MODEM_STATUS_DSR|MODEM_STATUS_RI|MODEM_STATUS_DCD)
! #define LINE_STATUS_BITS (LINE_STATUS_OE|LINE_STATUS_PE|LINE_STATUS_FE|LINE_STATUS_BI|LINE_STATUS_FIFOERR)
!
! if (escOptions & ESC_OPTS_V2O_MST(MODEM_STATUS_BITS))
opts |= C0CE_INSERT_ENABLE_MST;
! if (escOptions & ESC_OPTS_BREAK_STATUS)
opts |= C0CE_INSERT_ENABLE_LSR_BI;
! if (escOptions & ESC_OPTS_V2O_LSR(LINE_STATUS_BITS))
! opts |= C0CE_INSERT_ENABLE_LSR;
!
! if (escOptions & ESC_OPTS_RBR_STATUS)
opts |= C0CE_INSERT_ENABLE_RBR;
! if (escOptions & ESC_OPTS_RLC_STATUS)
opts |= C0CE_INSERT_ENABLE_RLC;
***************
*** 330,334 ****
if (!opts)
! return options;
BYTE inBufIoctl[sizeof(UCHAR) + C0CE_SIGNATURE_SIZE + sizeof(ULONG)];
--- 344,348 ----
if (!opts)
! return escOptions | ESC_OPTS_V2O_ESCCHAR(-1);
BYTE inBufIoctl[sizeof(UCHAR) + C0CE_SIGNATURE_SIZE + sizeof(ULONG)];
***************
*** 369,390 ****
*pDone = 0;
! return options;
}
- options &= ~GO_ESCAPE_MODE;
-
if (opts & C0CE_INSERT_ENABLE_MST)
! options &= ~GO_V2O_MODEM_STATUS(-1);
if (opts & C0CE_INSERT_ENABLE_LSR_BI)
! options &= ~GO_V2O_LINE_STATUS(LINE_STATUS_BI);
if (opts & C0CE_INSERT_ENABLE_RBR)
! options &= ~GO_RBR_STATUS;
if (opts & C0CE_INSERT_ENABLE_RLC)
! options &= ~GO_RLC_STATUS;
! return options;
}
///////////////////////////////////////////////////////////////
--- 383,405 ----
*pDone = 0;
! return escOptions | ESC_OPTS_V2O_ESCCHAR(-1);
}
if (opts & C0CE_INSERT_ENABLE_MST)
! escOptions &= ~ESC_OPTS_V2O_MST(MODEM_STATUS_BITS);
if (opts & C0CE_INSERT_ENABLE_LSR_BI)
! escOptions &= ~ESC_OPTS_BREAK_STATUS;
!
! if (opts & C0CE_INSERT_ENABLE_LSR)
! escOptions &= ~ESC_OPTS_V2O_LSR(LINE_STATUS_BITS & ~LINE_STATUS_BI);
if (opts & C0CE_INSERT_ENABLE_RBR)
! escOptions &= ~ESC_OPTS_RBR_STATUS;
if (opts & C0CE_INSERT_ENABLE_RLC)
! escOptions &= ~ESC_OPTS_RLC_STATUS;
! return escOptions & ~ESC_OPTS_V2O_ESCCHAR(-1);
}
///////////////////////////////////////////////////////////////
|