Update of /cvsroot/com0com/hub4com/plugins/serial
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21436/plugins/serial
Modified Files:
comport.cpp comport.h import.h port.cpp
Log Message:
Added fake read filter method to ports
Index: comport.cpp
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** comport.cpp 13 Aug 2008 15:14:02 -0000 1.5
--- comport.cpp 15 Aug 2008 12:44:59 -0000 1.6
***************
*** 20,23 ****
--- 20,26 ----
*
* $Log$
+ * Revision 1.6 2008/08/15 12:44:59 vfrolov
+ * Added fake read filter method to ports
+ *
* Revision 1.5 2008/08/13 15:14:02 vfrolov
* Print bit values in readable form
***************
*** 76,79 ****
--- 79,83 ----
events(0),
maskOutPins(0),
+ options(0),
writeQueueLimit(256),
writeQueued(0),
***************
*** 172,187 ****
BOOL ComPort::Start()
{
_ASSERTE(hMasterPort != NULL);
_ASSERTE(hHub != NULL);
_ASSERTE(handle != INVALID_HANDLE_VALUE);
- HUB_MSG msg;
-
- DWORD options = 0;
- msg.type = HUB_MSG_TYPE_GET_OPTIONS;
- msg.u.pv.pVal = &options;
- msg.u.pv.val = 0xFFFFFFFF;
- pOnRead(hHub, hMasterPort, &msg);
-
BYTE optsLsr = GO_O2V_LINE_STATUS(options);
BYTE optsMst = GO_O2V_MODEM_STATUS(options);
--- 176,185 ----
BOOL ComPort::Start()
{
+ //cout << name << " Start " << ::GetCurrentThreadId() << endl;
+
_ASSERTE(hMasterPort != NULL);
_ASSERTE(hHub != NULL);
_ASSERTE(handle != INVALID_HANDLE_VALUE);
BYTE optsLsr = GO_O2V_LINE_STATUS(options);
BYTE optsMst = GO_O2V_MODEM_STATUS(options);
***************
*** 234,237 ****
--- 232,237 ----
return FALSE;
+ HUB_MSG msg;
+
msg.type = HUB_MSG_TYPE_CONNECT;
msg.u.val = TRUE;
***************
*** 268,271 ****
--- 268,290 ----
}
+ BOOL ComPort::FakeReadFilter(HUB_MSG *pInMsg)
+ {
+ _ASSERTE(pInMsg != NULL);
+
+ if (pInMsg->type == HUB_MSG_TYPE_GET_OPTIONS) {
+ pInMsg->u.pv.val &= ~(GO_V2O_MODEM_STATUS(-1) | GO_V2O_LINE_STATUS(-1));
+
+ pInMsg = pMsgInsertNone(pInMsg, HUB_MSG_TYPE_EMPTY);
+
+ if (pInMsg) {
+ pInMsg->type = HUB_MSG_TYPE_GET_OPTIONS;
+ pInMsg->u.pv.pVal = &options;
+ pInMsg->u.pv.val = GO_V2O_MODEM_STATUS(-1) | GO_V2O_LINE_STATUS(-1);
+ }
+ }
+
+ return pInMsg != NULL;
+ }
+
static FIELD2NAME codeNameTableSetPinState[] = {
TOFIELD2NAME2(PIN_STATE_, RTS),
***************
*** 432,439 ****
countWaitCommEventOverlapped++;
! //cout << name << " Started WaitCommEvent " << countReadOverlapped
! // << " " << hex << events << dec << " ["
! // << FieldToName(codeNameTableComEvents, events)
! // << "] << endl;
return TRUE;
--- 451,460 ----
countWaitCommEventOverlapped++;
! /*
! cout << name << " Started WaitCommEvent " << countReadOverlapped
! << " " << hex << events << dec << " ["
! << FieldToName(codeNameTableComEvents, events)
! << "] << endl;
! */
return TRUE;
***************
*** 442,445 ****
--- 463,468 ----
void ComPort::OnWrite(WriteOverlapped *pOverlapped, DWORD len, DWORD done)
{
+ //cout << name << " OnWrite " << ::GetCurrentThreadId() << endl;
+
delete pOverlapped;
***************
*** 455,458 ****
--- 478,483 ----
void ComPort::OnRead(ReadOverlapped *pOverlapped, BYTE *pBuf, DWORD done)
{
+ //cout << name << " OnRead " << ::GetCurrentThreadId() << endl;
+
HUB_MSG msg;
***************
*** 467,471 ****
countReadOverlapped--;
! //cout << name << " Stopped Read " << countReadOverlapped << endl;
}
}
--- 492,496 ----
countReadOverlapped--;
! cout << name << " Stopped Read " << countReadOverlapped << endl;
}
}
***************
*** 473,476 ****
--- 498,509 ----
void ComPort::OnCommEvent(WaitCommEventOverlapped *pOverlapped, DWORD eMask)
{
+ //cout << name << " OnCommEvent " << ::GetCurrentThreadId() << endl;
+
+ /*
+ cout << name << " Event(s): 0x" << hex << eMask << dec << " ["
+ << FieldToName(codeNameTableComEvents, eMask)
+ << "]" << endl;
+ */
+
CheckComEvents(eMask);
***************
*** 479,483 ****
countWaitCommEventOverlapped--;
! //cout << name << " Stopped WaitCommEvent " << countWaitCommEventOverlapped << endl;
}
}
--- 512,516 ----
countWaitCommEventOverlapped--;
! cout << name << " Stopped WaitCommEvent " << countWaitCommEventOverlapped << endl;
}
}
***************
*** 489,492 ****
--- 522,532 ----
if (::GetCommModemStatus(handle, &stat)) {
+ /*
+ cout << name << " MODEM STATUS bit(s): 0x"
+ << hex << stat << dec << " ["
+ << FieldToName(codeNameTableModemStatus, stat)
+ << "]" << endl;
+ */
+
HUB_MSG msg;
Index: import.h
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/import.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** import.h 26 Mar 2008 08:41:18 -0000 1.1
--- import.h 15 Aug 2008 12:44:59 -0000 1.2
***************
*** 20,27 ****
*
* $Log$
* Revision 1.1 2008/03/26 08:41:18 vfrolov
* Initial revision
*
- *
*/
--- 20,29 ----
*
* $Log$
+ * Revision 1.2 2008/08/15 12:44:59 vfrolov
+ * Added fake read filter method to ports
+ *
* Revision 1.1 2008/03/26 08:41:18 vfrolov
* Initial revision
*
*/
***************
*** 34,37 ****
--- 36,40 ----
extern ROUTINE_BUF_ALLOC *pBufAlloc;
extern ROUTINE_BUF_FREE *pBufFree;
+ extern ROUTINE_MSG_INSERT_NONE *pMsgInsertNone;
extern ROUTINE_ON_XOFF *pOnXoff;
extern ROUTINE_ON_XON *pOnXon;
Index: port.cpp
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/port.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** port.cpp 13 Aug 2008 14:33:18 -0000 1.5
--- port.cpp 15 Aug 2008 12:44:59 -0000 1.6
***************
*** 20,23 ****
--- 20,26 ----
*
* $Log$
+ * Revision 1.6 2008/08/15 12:44:59 vfrolov
+ * Added fake read filter method to ports
+ *
* Revision 1.5 2008/08/13 14:33:18 vfrolov
* Fixed Help
***************
*** 107,112 ****
<< endl
<< "Input data stream description:" << endl
- << " GET_OPTIONS(<pOpts>) - the port sends this message at starting to get the" << endl
- << " required input data stream options." << endl
<< " LINE_DATA(<data>) - readed <data> from serial port." << endl
<< " CONNECT(TRUE) - serial port started." << endl
--- 110,113 ----
***************
*** 114,117 ****
--- 115,129 ----
<< " MODEM_STATUS(<val>) - current state of modem." << endl
<< endl
+ << "Fake read filter input data stream description:" << endl
+ << " GET_OPTIONS(<pOpts>,<mask>)" << endl
+ << " - the port removes bits from <mask> in this message" << endl
+ << " for locally supported input data stream options." << endl
+ << endl
+ << "Fake read filter output data stream description:" << endl
+ << " GET_OPTIONS(<pOpts>,<mask>)" << endl
+ << " - the port adds this message at detecting the" << endl
+ << " GET_OPTIONS message in the stream to get the" << endl
+ << " required input data stream options." << endl
+ << endl
<< "Examples:" << endl
<< " " << pProgPath << " COM1 \\\\.\\CNCB1 \\\\.\\CNCB2" << endl
***************
*** 271,274 ****
--- 283,296 ----
}
///////////////////////////////////////////////////////////////
+ static BOOL CALLBACK FakeReadFilter(
+ HPORT hPort,
+ HUB_MSG *pMsg)
+ {
+ _ASSERTE(hPort != NULL);
+ _ASSERTE(pMsg != NULL);
+
+ return ((ComPort *)hPort)->FakeReadFilter(pMsg);
+ }
+ ///////////////////////////////////////////////////////////////
static BOOL CALLBACK Write(
HPORT hPort,
***************
*** 318,321 ****
--- 340,344 ----
Init,
Start,
+ FakeReadFilter,
Write,
AddXoff,
***************
*** 331,334 ****
--- 354,358 ----
ROUTINE_BUF_ALLOC *pBufAlloc;
ROUTINE_BUF_FREE *pBufFree;
+ ROUTINE_MSG_INSERT_NONE *pMsgInsertNone;
ROUTINE_ON_XOFF *pOnXoff;
ROUTINE_ON_XON *pOnXon;
***************
*** 341,344 ****
--- 365,369 ----
if (!ROUTINE_IS_VALID(pHubRoutines, pBufAlloc) ||
!ROUTINE_IS_VALID(pHubRoutines, pBufFree) ||
+ !ROUTINE_IS_VALID(pHubRoutines, pMsgInsertNone) ||
!ROUTINE_IS_VALID(pHubRoutines, pOnXoff) ||
!ROUTINE_IS_VALID(pHubRoutines, pOnXon) ||
***************
*** 350,353 ****
--- 375,379 ----
pBufAlloc = pHubRoutines->pBufAlloc;
pBufFree = pHubRoutines->pBufFree;
+ pMsgInsertNone = pHubRoutines->pMsgInsertNone;
pOnXoff = pHubRoutines->pOnXoff;
pOnXon = pHubRoutines->pOnXon;
Index: comport.h
===================================================================
RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** comport.h 13 Aug 2008 15:14:02 -0000 1.5
--- comport.h 15 Aug 2008 12:44:59 -0000 1.6
***************
*** 20,23 ****
--- 20,26 ----
*
* $Log$
+ * Revision 1.6 2008/08/15 12:44:59 vfrolov
+ * Added fake read filter method to ports
+ *
* Revision 1.5 2008/08/13 15:14:02 vfrolov
* Print bit values in readable form
***************
*** 75,78 ****
--- 78,82 ----
BOOL Init(HMASTERPORT _hMasterPort, HHUB _hHub);
BOOL Start();
+ BOOL FakeReadFilter(HUB_MSG *pInMsg);
BOOL Write(HUB_MSG *pMsg);
void OnWrite(WriteOverlapped *pOverlapped, DWORD len, DWORD done);
***************
*** 101,104 ****
--- 105,109 ----
DWORD events;
BYTE maskOutPins;
+ DWORD options;
DWORD writeQueueLimit;
|