Thread: [Com0com-cvs] hub4com/plugins/pin2con filter.cpp,1.1,1.2
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
From: Vyacheslav F. <vf...@us...> - 2008-04-07 12:24:23
|
Update of /cvsroot/com0com/hub4com/plugins/pin2con In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15397 Modified Files: filter.cpp Log Message: Replaced --rt-events option by SET_RT_EVENTS message Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/pin2con/filter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** filter.cpp 2 Apr 2008 10:33:23 -0000 1.1 --- filter.cpp 7 Apr 2008 12:24:17 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/04/07 12:24:17 vfrolov + * Replaced --rt-events option by SET_RT_EVENTS message + * * Revision 1.1 2008/04/02 10:33:23 vfrolov * Initial revision *************** *** 29,38 **** /////////////////////////////////////////////////////////////// - #ifndef _DEBUG - #define DEBUG_PARAM(par) - #else /* _DEBUG */ - #define DEBUG_PARAM(par) par - #endif /* _DEBUG */ - /////////////////////////////////////////////////////////////// static ROUTINE_MSG_INSERT_VAL *pMsgInsertVal = NULL; static ROUTINE_MSG_REPLACE_NONE *pMsgReplaceNone = NULL; --- 32,35 ---- *************** *** 65,68 **** --- 62,67 ---- DWORD pin; BOOL negative; + DWORD myEvents; + DWORD events; private: *************** *** 73,81 **** DWORD val; const char *pName; } pin_names[] = { ! {MS_CTS_ON, "cts"}, ! {MS_DSR_ON, "dsr"}, ! {MS_RLSD_ON, "dcd"}, ! {MS_RING_ON, "ring"}, }; --- 72,81 ---- DWORD val; const char *pName; + DWORD events; } pin_names[] = { ! {MS_CTS_ON, "cts", EV_CTS}, ! {MS_DSR_ON, "dsr", EV_DSR}, ! {MS_RLSD_ON, "dcd", EV_RLSD}, ! {MS_RING_ON, "ring", EV_RING}, }; *************** *** 115,118 **** --- 115,127 ---- } } + + myEvents = 0; + + for (int i = 0 ; i < sizeof(pin_names)/sizeof(pin_names[0]) ; i++) { + if ((pin & pin_names[i].val) != 0) + myEvents |= pin_names[i].events; + } + + events = myEvents; } *************** *** 172,177 **** << " CONNECT(FALSE) - will be added on appropriate pin state changing." << endl << endl << "Examples:" << endl ! << " " << pProgPath << " --create-filter=" << GetPluginAbout()->pName << " --add-filters=0:" << GetPluginAbout()->pName << " --rt-events=dsr COM1 --use-port-module=tcp 111.11.11.11:1111" << endl << " - wait DSR ON from COM1 and then establish connection to 111.11.11.11:1111" << endl << " and disconnect on DSR OFF." << endl --- 181,196 ---- << " CONNECT(FALSE) - will be added on appropriate pin state changing." << endl << endl + << "IN method echo data stream description:" << endl + << " SET_RT_EVENTS(<mask>) - will be added on CONNECT(TRUE) in input data stream." << endl + << endl + << "OUT method input data stream description:" << endl + << " SET_RT_EVENTS(<mask>) - <mask> is the events mask." << endl + << endl + << "OUT method output data stream description:" << endl + << " SET_RT_EVENTS(<mask>) - <mask> is the events mask with event required by this" << endl + << " filter." << endl + << endl << "Examples:" << endl ! << " " << pProgPath << " --create-filter=" << GetPluginAbout()->pName << " --add-filters=0:" << GetPluginAbout()->pName << " COM1 --use-port-module=tcp 111.11.11.11:1111" << endl << " - wait DSR ON from COM1 and then establish connection to 111.11.11.11:1111" << endl << " and disconnect on DSR OFF." << endl *************** *** 191,195 **** int nFromPort, HUB_MSG *pInMsg, ! HUB_MSG **DEBUG_PARAM(ppEchoMsg)) { _ASSERTE(hFilter != NULL); --- 210,214 ---- int nFromPort, HUB_MSG *pInMsg, ! HUB_MSG **ppEchoMsg) { _ASSERTE(hFilter != NULL); *************** *** 199,202 **** --- 218,230 ---- if (pInMsg->type == HUB_MSG_TYPE_CONNECT) { + if (pInMsg->u.val) { + *ppEchoMsg = pMsgInsertVal(NULL, + HUB_MSG_TYPE_SET_RT_EVENTS, + ((Filter *)hFilter)->events); + + if (!*ppEchoMsg) + return FALSE; + } + // discard any CONNECT messages from the input stream pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); *************** *** 228,231 **** --- 256,277 ---- } /////////////////////////////////////////////////////////////// + static BOOL CALLBACK OutMethod( + HFILTER hFilter, + int /*nFromPort*/, + int /*nToPort*/, + HUB_MSG *pOutMsg) + { + _ASSERTE(hFilter != NULL); + _ASSERTE(pOutMsg != NULL); + + if (pOutMsg->type == HUB_MSG_TYPE_SET_RT_EVENTS) { + // Add event required by this filter + pOutMsg->u.val |= ((Filter *)hFilter)->myEvents; + ((Filter *)hFilter)->events = pOutMsg->u.val; + } + + return TRUE; + } + /////////////////////////////////////////////////////////////// static const FILTER_ROUTINES_A routines = { sizeof(FILTER_ROUTINES_A), *************** *** 239,243 **** NULL, // Init InMethod, ! NULL, // OutMethod }; --- 285,289 ---- NULL, // Init InMethod, ! OutMethod, }; |