[Com0com-cvs] hub4com/plugins/pinmap filter.cpp,1.18,1.19
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
From: Vyacheslav F. <vf...@us...> - 2011-05-23 09:54:01
|
Update of /cvsroot/com0com/hub4com/plugins/pinmap In directory vz-cvs-2.sog:/tmp/cvs-serv13771 Modified Files: filter.cpp Log Message: Added --data option Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/pinmap/filter.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** filter.cpp 19 May 2011 16:33:34 -0000 1.18 --- filter.cpp 23 May 2011 09:53:58 -0000 1.19 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.19 2011/05/23 09:53:58 vfrolov + * Added --data option + * * Revision 1.18 2011/05/19 16:33:34 vfrolov * Fixed typo *************** *** 86,89 **** --- 89,93 ---- /////////////////////////////////////////////////////////////// static ROUTINE_MSG_INSERT_VAL *pMsgInsertVal; + static ROUTINE_MSG_REPLACE_NONE *pMsgReplaceNone; static ROUTINE_PORT_NAME_A *pPortName; static ROUTINE_FILTER_NAME_A *pFilterName; *************** *** 109,125 **** }; /////////////////////////////////////////////////////////////// static struct { const char *pName; ! WORD val; } pinOut_names[] = { ! {"rts=", PIN_STATE_RTS}, ! {"dtr=", PIN_STATE_DTR}, ! {"out1=", PIN_STATE_OUT1}, ! {"out2=", PIN_STATE_OUT2}, ! {"cts=", PIN_STATE_CTS}, ! {"dsr=", PIN_STATE_DSR}, ! {"ring=", PIN_STATE_RI}, ! {"dcd=", PIN_STATE_DCD}, ! {"break=", PIN_STATE_BREAK}, }; /////////////////////////////////////////////////////////////// --- 113,134 ---- }; /////////////////////////////////////////////////////////////// + #define PST2OM(m) ((DWORD)((WORD)(m))) + #define OM2PST(m) ((WORD)(m)) + #define OM_DATA ((DWORD)1 << 16) + static struct { const char *pName; ! DWORD val; } pinOut_names[] = { ! {"rts=", PST2OM(PIN_STATE_RTS)}, ! {"dtr=", PST2OM(PIN_STATE_DTR)}, ! {"out1=", PST2OM(PIN_STATE_OUT1)}, ! {"out2=", PST2OM(PIN_STATE_OUT2)}, ! {"cts=", PST2OM(PIN_STATE_CTS)}, ! {"dsr=", PST2OM(PIN_STATE_DSR)}, ! {"ring=", PST2OM(PIN_STATE_RI)}, ! {"dcd=", PST2OM(PIN_STATE_DCD)}, ! {"break=", PST2OM(PIN_STATE_BREAK)}, ! {"data=", OM_DATA}, }; /////////////////////////////////////////////////////////////// *************** *** 148,151 **** --- 157,161 ---- State(HMASTERPORT hMasterPort) : pName(pPortName(hMasterPort)) + , outVal(0) , lmInVal(LM_ON) , connectionCounter(0) *************** *** 153,156 **** --- 163,167 ---- const char *const pName; + DWORD outVal; WORD lmInVal; int connectionCounter; *************** *** 166,175 **** PinOuts() : mask(0), val(0) {} ! WORD mask; ! WORD val; }; PinOuts pinMap[sizeof(pinIn_names)/sizeof(pinIn_names[0])]; ! WORD outMask; WORD lmInMask; --- 177,186 ---- PinOuts() : mask(0), val(0) {} ! DWORD mask; ! DWORD val; }; PinOuts pinMap[sizeof(pinIn_names)/sizeof(pinIn_names[0])]; ! DWORD outMask; WORD lmInMask; *************** *** 299,302 **** --- 310,314 ---- << " --dcd=[!]<s> - wire input state of <s> to output pin DCD." << endl << " --break=[!]<s> - wire input state of <s> to output state of BREAK." << endl + << " --data=[!]<s> - wire input state of <s> to state of DATA." << endl << endl << " The possible values of <s> above can be on, cts, dsr, dcd, ring, break or" << endl *************** *** 316,319 **** --- 328,333 ---- << " BREAK_STATUS(<val>) - current state of break." << endl << " MODEM_STATUS(<val>) - current state of modem." << endl + << " LINE_DATA(<data>) - will be discarded from stream if the state of DATA is" << endl + << " OFF." << endl << endl << "OUT method output data stream description:" << endl *************** *** 345,348 **** --- 359,370 ---- << " - receive data and signals from COM2 and send it back to COM2." << endl << " " << pProgPath << " --load=,,_END_" << endl + << " --create-filter=pinmap:--data=!cts" << endl + << " --add-filters=0:pinmap" << endl + << " --echo-route=0" << endl + << " --octs=off" << endl + << " COM2" << endl + << " _END_" << endl + << " - receive data from COM2 and if cts is OFF then send data back to COM2." << endl + << " " << pProgPath << " --load=,,_END_" << endl << " --route=all:0" << endl << " --create-filter=pinmap:--rts=connect --dtr=connect" << endl *************** *** 414,420 **** /////////////////////////////////////////////////////////////// static void InsertPinState( ! Filter &filter, WORD lmInMask, WORD lmInVal, HUB_MSG **ppOutMsg) { --- 436,443 ---- /////////////////////////////////////////////////////////////// static void InsertPinState( ! const Filter &filter, WORD lmInMask, WORD lmInVal, + State &state, HUB_MSG **ppOutMsg) { *************** *** 424,429 **** //cout << "InsertPinState lmInMask=0x" << hex << lmInMask << " lmInVal=0x" << lmInVal << dec << endl; ! WORD mask = 0; ! WORD val = 0; for (int iIn = 0 ; iIn < sizeof(pinIn_names)/sizeof(pinIn_names[0]) ; iIn++) { --- 447,452 ---- //cout << "InsertPinState lmInMask=0x" << hex << lmInMask << " lmInVal=0x" << lmInVal << dec << endl; ! DWORD outMask = 0; ! DWORD outVal = 0; for (int iIn = 0 ; iIn < sizeof(pinIn_names)/sizeof(pinIn_names[0]) ; iIn++) { *************** *** 431,444 **** continue; ! mask |= filter.pinMap[iIn].mask; if ((lmInVal & pinIn_names[iIn].lmVal) != 0) ! val |= (filter.pinMap[iIn].val & filter.pinMap[iIn].mask); else ! val |= (~filter.pinMap[iIn].val & filter.pinMap[iIn].mask); } ! if (mask) { ! DWORD dVal = (VAL2MASK(mask) | val); //cout << "SET_PIN_STATE 0x" << hex << dVal << dec << endl; *ppOutMsg = pMsgInsertVal(*ppOutMsg, HUB_MSG_TYPE_SET_PIN_STATE, dVal); --- 454,469 ---- continue; ! outMask |= filter.pinMap[iIn].mask; if ((lmInVal & pinIn_names[iIn].lmVal) != 0) ! outVal |= (filter.pinMap[iIn].val & filter.pinMap[iIn].mask); else ! outVal |= (~filter.pinMap[iIn].val & filter.pinMap[iIn].mask); } ! state.outVal = (outVal & outMask) | (state.outVal & ~outMask); ! ! if (OM2PST(outMask)) { ! DWORD dVal = (VAL2MASK(OM2PST(outMask)) | OM2PST(outVal)); //cout << "SET_PIN_STATE 0x" << hex << dVal << dec << endl; *ppOutMsg = pMsgInsertVal(*ppOutMsg, HUB_MSG_TYPE_SET_PIN_STATE, dVal); *************** *** 460,467 **** case HUB_MSG_T2N(HUB_MSG_TYPE_SET_OUT_OPTS): { // or'e with the required mask to set pin state ! pOutMsg->u.val |= SO_V2O_PIN_STATE(((Filter *)hFilter)->outMask); // init pin state ! InsertPinState(*(Filter *)hFilter, ((Filter *)hFilter)->lmInMask, ((State *)hFilterInstance)->lmInVal, &pOutMsg); break; --- 485,492 ---- case HUB_MSG_T2N(HUB_MSG_TYPE_SET_OUT_OPTS): { // or'e with the required mask to set pin state ! pOutMsg->u.val |= SO_V2O_PIN_STATE(OM2PST(((Filter *)hFilter)->outMask)); // init pin state ! InsertPinState(*(Filter *)hFilter, ((Filter *)hFilter)->lmInMask, ((State *)hFilterInstance)->lmInVal, *(State *)hFilterInstance, &pOutMsg); break; *************** *** 494,498 **** case HUB_MSG_T2N(HUB_MSG_TYPE_SET_PIN_STATE): // discard any pin settings controlled by this filter ! pOutMsg->u.val &= ~(VAL2MASK(((Filter *)hFilter)->outMask)); break; case HUB_MSG_T2N(HUB_MSG_TYPE_MODEM_STATUS): { --- 519,523 ---- case HUB_MSG_T2N(HUB_MSG_TYPE_SET_PIN_STATE): // discard any pin settings controlled by this filter ! pOutMsg->u.val &= ~(VAL2MASK(OM2PST(((Filter *)hFilter)->outMask))); break; case HUB_MSG_T2N(HUB_MSG_TYPE_MODEM_STATUS): { *************** *** 500,504 **** WORD lmInVal = ((MST2LM(pOutMsg->u.val) & lmInMask) | (((State *)hFilterInstance)->lmInVal & ~lmInMask)); ! InsertPinState(*(Filter *)hFilter, ((State *)hFilterInstance)->lmInVal ^ lmInVal, lmInVal, &pOutMsg); ((State *)hFilterInstance)->lmInVal = lmInVal; --- 525,529 ---- WORD lmInVal = ((MST2LM(pOutMsg->u.val) & lmInMask) | (((State *)hFilterInstance)->lmInVal & ~lmInMask)); ! InsertPinState(*(Filter *)hFilter, ((State *)hFilterInstance)->lmInVal ^ lmInVal, lmInVal, *(State *)hFilterInstance, &pOutMsg); ((State *)hFilterInstance)->lmInVal = lmInVal; *************** *** 509,513 **** WORD lmInVal = ((pOutMsg->u.val ? LM_BREAK : 0) | (((State *)hFilterInstance)->lmInVal & ~LM_BREAK)); ! InsertPinState(*(Filter *)hFilter, ((State *)hFilterInstance)->lmInVal ^ lmInVal, lmInVal, &pOutMsg); ((State *)hFilterInstance)->lmInVal = lmInVal; --- 534,538 ---- WORD lmInVal = ((pOutMsg->u.val ? LM_BREAK : 0) | (((State *)hFilterInstance)->lmInVal & ~LM_BREAK)); ! InsertPinState(*(Filter *)hFilter, ((State *)hFilterInstance)->lmInVal ^ lmInVal, lmInVal, *(State *)hFilterInstance, &pOutMsg); ((State *)hFilterInstance)->lmInVal = lmInVal; *************** *** 530,534 **** WORD lmInVal = ((((State *)hFilterInstance)->connectionCounter > 0 ? LM_CONNECT : 0) | (((State *)hFilterInstance)->lmInVal & ~LM_CONNECT)); ! InsertPinState(*(Filter *)hFilter, ((State *)hFilterInstance)->lmInVal ^ lmInVal, lmInVal, &pOutMsg); ((State *)hFilterInstance)->lmInVal = lmInVal; --- 555,559 ---- WORD lmInVal = ((((State *)hFilterInstance)->connectionCounter > 0 ? LM_CONNECT : 0) | (((State *)hFilterInstance)->lmInVal & ~LM_CONNECT)); ! InsertPinState(*(Filter *)hFilter, ((State *)hFilterInstance)->lmInVal ^ lmInVal, lmInVal, *(State *)hFilterInstance, &pOutMsg); ((State *)hFilterInstance)->lmInVal = lmInVal; *************** *** 536,539 **** --- 561,572 ---- break; } + case HUB_MSG_T2N(HUB_MSG_TYPE_LINE_DATA): { + if ((((Filter *)hFilter)->outMask & OM_DATA) != 0 && (((State *)hFilterInstance)->outVal & OM_DATA) == 0) { + if (!pMsgReplaceNone(pOutMsg, HUB_MSG_TYPE_EMPTY)) + return FALSE; + } + + break; + } } *************** *** 567,570 **** --- 600,604 ---- { if (!ROUTINE_IS_VALID(pHubRoutines, pMsgInsertVal) || + !ROUTINE_IS_VALID(pHubRoutines, pMsgReplaceNone) || !ROUTINE_IS_VALID(pHubRoutines, pPortName) || !ROUTINE_IS_VALID(pHubRoutines, pFilterName) || *************** *** 575,578 **** --- 609,613 ---- pMsgInsertVal = pHubRoutines->pMsgInsertVal; + pMsgReplaceNone = pHubRoutines->pMsgReplaceNone; pPortName = pHubRoutines->pPortName; pFilterName = pHubRoutines->pFilterName; |