Thread: [Com0com-cvs] hub4com/plugins/pin2con filter.cpp,1.5,1.6
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
From: Vyacheslav F. <vf...@us...> - 2008-08-20 14:57:17
|
Update of /cvsroot/com0com/hub4com/plugins/pin2con In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29647/plugins/pin2con Modified Files: filter.cpp Log Message: Redesigned serial port options Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/pin2con/filter.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** filter.cpp 11 Aug 2008 07:15:33 -0000 1.5 --- filter.cpp 20 Aug 2008 14:30:19 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2008/08/20 14:30:19 vfrolov + * Redesigned serial port options + * * Revision 1.5 2008/08/11 07:15:33 vfrolov * Replaced *************** *** 51,54 **** --- 54,59 ---- static ROUTINE_MSG_INSERT_VAL *pMsgInsertVal = NULL; static ROUTINE_MSG_REPLACE_NONE *pMsgReplaceNone = NULL; + static ROUTINE_PORT_NAME_A *pPortName = NULL; + static ROUTINE_FILTER_NAME_A *pFilterName = NULL; /////////////////////////////////////////////////////////////// const char *GetParam(const char *pArg, const char *pPattern) *************** *** 69,79 **** }; /////////////////////////////////////////////////////////////// - typedef map<int, State*> PortsMap; - typedef pair<int, State*> PortPair; - class Filter { public: Filter(int argc, const char *const argv[]); State *GetState(int nPort); DWORD pin; --- 74,84 ---- }; /////////////////////////////////////////////////////////////// class Filter { public: Filter(int argc, const char *const argv[]); + void SetHub(HHUB _hHub) { hHub = _hHub; } State *GetState(int nPort); + const char *PortName(int nPort) const { return pPortName(hHub, nPort); } + const char *FilterName() const { return pFilterName(hHub, (HFILTER)this); } DWORD pin; *************** *** 81,84 **** --- 86,94 ---- private: + HHUB hHub; + + typedef map<int, State*> PortsMap; + typedef pair<int, State*> PortPair; + PortsMap portsMap; }; *************** *** 97,101 **** Filter::Filter(int argc, const char *const argv[]) : pin(GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)), ! negative(FALSE) { for (const char *const *pArgs = &argv[1] ; argc > 1 ; pArgs++, argc--) { --- 107,112 ---- Filter::Filter(int argc, const char *const argv[]) : pin(GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)), ! negative(FALSE), ! hHub(NULL) { for (const char *const *pArgs = &argv[1] ; argc > 1 ; pArgs++, argc--) { *************** *** 180,190 **** << endl << "IN method input data stream description:" << endl ! << " HUB_MSG_TYPE_GET_OPTIONS(<pOptions>)" << endl ! << " - the value pointed by <pOptions> will be or'ed with" << endl << " the required mask to get line status and modem" << endl << " status." << endl << " CONNECT(TRUE/FALSE) - will be discarded from stream." << endl ! << " LINE_STATUS(<val>) - current state of line" << endl ! << " MODEM_STATUS(<val>) - current state of modem" << endl << endl << "IN method output data stream description:" << endl --- 191,200 ---- << endl << "IN method input data stream description:" << endl ! << " GET_IN_OPTS(<pOpts>) - the value pointed by <pOpts> will be or'ed with" << endl << " the required mask to get line status and modem" << endl << " status." << endl << " CONNECT(TRUE/FALSE) - will be discarded from stream." << endl ! << " LINE_STATUS(<val>) - current state of line." << endl ! << " MODEM_STATUS(<val>) - current state of modem." << endl << endl << "IN method output data stream description:" << endl *************** *** 206,209 **** --- 216,231 ---- } /////////////////////////////////////////////////////////////// + static BOOL CALLBACK Init( + HFILTER hFilter, + HHUB hHub) + { + _ASSERTE(hFilter != NULL); + _ASSERTE(hHub != NULL); + + ((Filter *)hFilter)->SetHub(hHub); + + return TRUE; + } + /////////////////////////////////////////////////////////////// static BOOL CALLBACK InMethod( HFILTER hFilter, *************** *** 217,225 **** _ASSERTE(*ppEchoMsg == NULL); ! if (pInMsg->type == HUB_MSG_TYPE_GET_OPTIONS) { _ASSERTE(pInMsg->u.pv.pVal != NULL); *pInMsg->u.pv.pVal |= (((Filter *)hFilter)->pin & pInMsg->u.pv.val); } else if (pInMsg->type == HUB_MSG_TYPE_CONNECT) { // discard any CONNECT messages from the input stream --- 239,259 ---- _ASSERTE(*ppEchoMsg == NULL); ! if (pInMsg->type == HUB_MSG_TYPE_GET_IN_OPTS) { _ASSERTE(pInMsg->u.pv.pVal != NULL); + // or'e with the required mask to get line status and modem status *pInMsg->u.pv.pVal |= (((Filter *)hFilter)->pin & pInMsg->u.pv.val); } else + if (pInMsg->type == HUB_MSG_TYPE_FAIL_IN_OPTS) { + DWORD fail_options = (pInMsg->u.val & ((Filter *)hFilter)->pin); + + if (fail_options) { + cerr << ((Filter *)hFilter)->PortName(nFromPort) + << " WARNING: Requested by filter " << ((Filter *)hFilter)->FilterName() + << " option(s) 0x" << hex << fail_options << dec + << " not accepted" << endl; + } + } + else if (pInMsg->type == HUB_MSG_TYPE_CONNECT) { // discard any CONNECT messages from the input stream *************** *** 268,272 **** NULL, // ConfigStop Create, ! NULL, // Init InMethod, NULL, // OutMethod --- 302,306 ---- NULL, // ConfigStop Create, ! Init, InMethod, NULL, // OutMethod *************** *** 283,287 **** { if (!ROUTINE_IS_VALID(pHubRoutines, pMsgInsertVal) || ! !ROUTINE_IS_VALID(pHubRoutines, pMsgReplaceNone)) { return NULL; --- 317,323 ---- { if (!ROUTINE_IS_VALID(pHubRoutines, pMsgInsertVal) || ! !ROUTINE_IS_VALID(pHubRoutines, pMsgReplaceNone) || ! !ROUTINE_IS_VALID(pHubRoutines, pPortName) || ! !ROUTINE_IS_VALID(pHubRoutines, pFilterName)) { return NULL; *************** *** 290,293 **** --- 326,331 ---- pMsgInsertVal = pHubRoutines->pMsgInsertVal; pMsgReplaceNone = pHubRoutines->pMsgReplaceNone; + pPortName = pHubRoutines->pPortName; + pFilterName = pHubRoutines->pFilterName; return plugins; |