com0com-cvs Mailing List for Null-modem emulator (Page 13)
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
You can subscribe to this list here.
2005 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
(13) |
Jun
(18) |
Jul
(9) |
Aug
(10) |
Sep
(15) |
Oct
(6) |
Nov
(9) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(6) |
Feb
(4) |
Mar
(4) |
Apr
(2) |
May
(7) |
Jun
(11) |
Jul
(6) |
Aug
(9) |
Sep
(1) |
Oct
(27) |
Nov
(22) |
Dec
(3) |
2007 |
Jan
(13) |
Feb
(16) |
Mar
(2) |
Apr
(3) |
May
(7) |
Jun
(17) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(20) |
Nov
(18) |
Dec
(1) |
2008 |
Jan
|
Feb
(3) |
Mar
(46) |
Apr
(40) |
May
(4) |
Jun
(9) |
Jul
(7) |
Aug
(62) |
Sep
(25) |
Oct
(51) |
Nov
(67) |
Dec
(81) |
2009 |
Jan
(13) |
Feb
(31) |
Mar
(12) |
Apr
|
May
(10) |
Jun
|
Jul
(5) |
Aug
(2) |
Sep
(10) |
Oct
|
Nov
(3) |
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
|
May
(12) |
Jun
(9) |
Jul
(12) |
Aug
(7) |
Sep
(6) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(11) |
Jun
|
Jul
(26) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(23) |
2012 |
Jan
(7) |
Feb
(3) |
Mar
|
Apr
|
May
(2) |
Jun
(9) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Vyacheslav F. <vf...@us...> - 2008-12-01 17:14:58
|
Update of /cvsroot/com0com/hub4com In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11304 Modified Files: hub4com.cpp route.cpp route.h Log Message: Implemented --fc-route and --no-default-fc-route options Index: route.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/route.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** route.cpp 24 Nov 2008 12:36:59 -0000 1.2 --- route.cpp 1 Dec 2008 17:14:52 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/12/01 17:14:52 vfrolov + * Implemented --fc-route and --no-default-fc-route options + * * Revision 1.2 2008/11/24 12:36:59 vfrolov * Changed plugin API *************** *** 49,52 **** --- 52,78 ---- } + static void AddRoute( + PortMap &map, + const PortPair &pair, + BOOL noRoute) + { + for (;;) { + PortMap::iterator i = FindPair(map, pair); + + if (i == map.end()) { + if (!noRoute) + map.insert(pair); + break; + } + else + if (noRoute) { + map.erase(i); + } + else { + break; + } + } + } + void AddRoute( PortMap &map, *************** *** 56,76 **** BOOL noEcho) { ! if (pFrom != pTo || !noEcho || noRoute) { ! PortPair pair(pFrom, pTo); ! ! for (;;) { ! PortMap::iterator i = FindPair(map, pair); ! if (i == map.end()) { ! if (!noRoute) ! map.insert(pair); ! break; ! } else if (noRoute) { ! map.erase(i); ! } else { ! break; ! } ! } ! } } --- 82,96 ---- BOOL noEcho) { ! if (pFrom != pTo || !noEcho || noRoute) ! AddRoute(map, PortPair(pFrom, pTo), noRoute); ! } ! void AddRoute( ! PortMap &map, ! PortMap &noMap, ! BOOL noRoute) ! { ! for (PortMap::const_iterator i = noMap.begin() ; i != noMap.end() ; i++) ! AddRoute(map, *i, noRoute); } Index: hub4com.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/hub4com.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** hub4com.cpp 26 Nov 2008 15:55:24 -0000 1.19 --- hub4com.cpp 1 Dec 2008 17:14:52 -0000 1.20 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.20 2008/12/01 17:14:52 vfrolov + * Implemented --fc-route and --no-default-fc-route options + * * Revision 1.19 2008/11/26 15:55:24 vfrolov * Changed port number to unsigned *************** *** 125,128 **** --- 128,139 ---- << " --no-route=<LstR>:<LstL> - do not send data received from any port listed in" << endl << " <LstR> to the ports listed in <LstL>." << endl + << " --fc-route=<LstR>:<LstL> - enable flow control route from any port listed in" << endl + << " <LstR> to all ports listed in <LstL>." << endl + << " --no-default-fc-route=<LstR>:<LstL>" << endl + << " disable default flow control route from any port" << endl + << " listed in <LstR> to all ports listed in <LstL>" << endl + << " (default flow control route enabled from P1 to P2" << endl + << " if enabled data route from P1 to P2 and from P2 to" << endl + << " P1)." << endl << endl << " If no any route option specified, then the options --route=0:All --route=1:0" << endl *************** *** 183,193 **** } /////////////////////////////////////////////////////////////// static BOOL EnumPortList( ComHub &hub, const char *pList, ! BOOL (*pFunc)(ComHub &hub, Port *pPort, PVOID p0, PVOID p1, PVOID p2), ! PVOID p0 = NULL, ! PVOID p1 = NULL, ! PVOID p2 = NULL) { char *pTmpList = _strdup(pList); --- 194,208 ---- } /////////////////////////////////////////////////////////////// + DECLARE_HANDLE(HPRM0); + DECLARE_HANDLE(HPRM1); + DECLARE_HANDLE(HPRM2); + static BOOL EnumPortList( ComHub &hub, const char *pList, ! BOOL (*pFunc)(ComHub &hub, Port *pPort, HPRM0 p0, HPRM1 p1, HPRM2 p2), ! HPRM0 p0 = NULL, ! HPRM1 p1 = NULL, ! HPRM2 p2 = NULL) { char *pTmpList = _strdup(pList); *************** *** 226,230 **** } /////////////////////////////////////////////////////////////// ! static BOOL EchoRoute(ComHub &/*hub*/, Port *pPort, PVOID pMap, PVOID /*p1*/, PVOID /*p2*/) { AddRoute(*(PortMap *)pMap, pPort, pPort, FALSE, FALSE); --- 241,245 ---- } /////////////////////////////////////////////////////////////// ! static BOOL EchoRoute(ComHub &/*hub*/, Port *pPort, HPRM0 pMap, HPRM1 /*p1*/, HPRM2 /*p2*/) { AddRoute(*(PortMap *)pMap, pPort, pPort, FALSE, FALSE); *************** *** 234,238 **** static void EchoRoute(ComHub &hub, const char *pList, PortMap &map) { ! if (!EnumPortList(hub, pList, EchoRoute, &map)) { cerr << "Invalid echo route " << pList << endl; exit(1); --- 249,253 ---- static void EchoRoute(ComHub &hub, const char *pList, PortMap &map) { ! if (!EnumPortList(hub, pList, EchoRoute, (HPRM0)&map)) { cerr << "Invalid echo route " << pList << endl; exit(1); *************** *** 240,252 **** } /////////////////////////////////////////////////////////////// ! static BOOL Route(ComHub &/*hub*/, Port *pTo, PVOID pFrom, PVOID pNoRoute, PVOID pMap) { ! AddRoute(*(PortMap *)pMap, (Port *)pFrom, pTo, *(BOOL *)pNoRoute, TRUE); return TRUE; } ! static BOOL RouteList(ComHub &hub, Port *pFrom, PVOID pListTo, PVOID pNoRoute, PVOID pMap) { ! return EnumPortList(hub, (const char *)pListTo, Route, pFrom, pNoRoute, pMap); } --- 255,274 ---- } /////////////////////////////////////////////////////////////// ! struct RouteParams { ! RouteParams(BOOL _noRoute, BOOL _noEcho) : noRoute(_noRoute), noEcho(_noEcho) {} ! ! BOOL noRoute; ! BOOL noEcho; ! }; ! ! static BOOL Route(ComHub &/*hub*/, Port *pTo, HPRM0 pFrom, HPRM1 pParams, HPRM2 pMap) { ! AddRoute(*(PortMap *)pMap, (Port *)pFrom, pTo, ((RouteParams *)pParams)->noRoute, ((RouteParams *)pParams)->noEcho); return TRUE; } ! static BOOL RouteList(ComHub &hub, Port *pFrom, HPRM0 pListTo, HPRM1 pParams, HPRM2 pMap) { ! return EnumPortList(hub, (const char *)pListTo, Route, (HPRM0)pFrom, (HPRM1)pParams, (HPRM2)pMap); } *************** *** 255,262 **** const char *pListFrom, const char *pListTo, ! BOOL noRoute, PortMap &map) { ! return EnumPortList(hub, pListFrom, RouteList, (PVOID)pListTo, &noRoute, &map); } /////////////////////////////////////////////////////////////// --- 277,284 ---- const char *pListFrom, const char *pListTo, ! const RouteParams *pRouteParams, PortMap &map) { ! return EnumPortList(hub, pListFrom, RouteList, (HPRM0)pListTo, (HPRM1)pRouteParams, (HPRM2)&map); } /////////////////////////////////////////////////////////////// *************** *** 266,269 **** --- 288,292 ---- BOOL biDirection, BOOL noRoute, + BOOL noEcho, PortMap &map) { *************** *** 278,285 **** const char *pListR = STRTOK_R(pTmp, ":", &pSave); const char *pListL = STRTOK_R(NULL, ":", &pSave); if (!pListR || !pListL || ! !Route(hub, pListR, pListL, noRoute, map) || ! (biDirection && !Route(hub, pListL, pListR, noRoute, map))) { cerr << "Invalid route " << pParam << endl; --- 301,309 ---- const char *pListR = STRTOK_R(pTmp, ":", &pSave); const char *pListL = STRTOK_R(NULL, ":", &pSave); + const RouteParams routeParams(noRoute, noEcho); if (!pListR || !pListL || ! !Route(hub, pListR, pListL, &routeParams, map) || ! (biDirection && !Route(hub, pListL, pListR, &routeParams, map))) { cerr << "Invalid route " << pParam << endl; *************** *** 347,351 **** } /////////////////////////////////////////////////////////////// ! static BOOL AddFilters(ComHub &hub, Port *pPort, PVOID pFilters, PVOID pListFlt, PVOID /*p2*/) { char *pTmpList = _strdup((const char *)pListFlt); --- 371,375 ---- } /////////////////////////////////////////////////////////////// ! static BOOL AddFilters(ComHub &hub, Port *pPort, HPRM0 pFilters, HPRM1 pListFlt, HPRM2 /*p2*/) { char *pTmpList = _strdup((const char *)pListFlt); *************** *** 444,448 **** } ! if (!EnumPortList(hub, pList, AddFilters, &filters, (PVOID)pListFlt)) { cerr << "Can't add filters " << pListFlt << " to ports " << pList << endl; exit(1); --- 468,472 ---- } ! if (!EnumPortList(hub, pList, AddFilters, (HPRM0)&filters, (HPRM1)pListFlt)) { cerr << "Can't add filters " << pListFlt << " to ports " << pList << endl; exit(1); *************** *** 462,466 **** BOOL defaultRouteData = TRUE; - BOOL defaultRouteFlowControl = TRUE; int plugged = 0; Plugins *pPlugins = new Plugins(); --- 486,489 ---- *************** *** 477,480 **** --- 500,504 ---- PortMap routeDataMap; PortMap routeFlowControlMap; + PortMap noDefaultRouteFlowControlMap; const char *pUseDriver = "serial"; *************** *** 525,537 **** if ((pParam = GetParam(pArg, "route=")) != NULL) { defaultRouteData = FALSE; ! Route(hub, pParam, FALSE, FALSE, routeDataMap); } else if ((pParam = GetParam(pArg, "bi-route=")) != NULL) { defaultRouteData = FALSE; ! Route(hub, pParam, TRUE, FALSE, routeDataMap); } else if ((pParam = GetParam(pArg, "no-route=")) != NULL) { defaultRouteData = FALSE; ! Route(hub, pParam, FALSE, TRUE, routeDataMap); } else if ((pParam = GetParam(pArg, "echo-route=")) != NULL) { --- 549,561 ---- if ((pParam = GetParam(pArg, "route=")) != NULL) { defaultRouteData = FALSE; ! Route(hub, pParam, FALSE, FALSE, TRUE, routeDataMap); } else if ((pParam = GetParam(pArg, "bi-route=")) != NULL) { defaultRouteData = FALSE; ! Route(hub, pParam, TRUE, FALSE, TRUE, routeDataMap); } else if ((pParam = GetParam(pArg, "no-route=")) != NULL) { defaultRouteData = FALSE; ! Route(hub, pParam, FALSE, TRUE, TRUE, routeDataMap); } else if ((pParam = GetParam(pArg, "echo-route=")) != NULL) { *************** *** 539,542 **** --- 563,574 ---- EchoRoute(hub, pParam, routeDataMap); } else + if ((pParam = GetParam(pArg, "fc-route=")) != NULL) { + defaultRouteData = FALSE; + Route(hub, pParam, FALSE, FALSE, FALSE, routeFlowControlMap); + } else + if ((pParam = GetParam(pArg, "no-default-fc-route=")) != NULL) { + defaultRouteData = FALSE; + Route(hub, pParam, FALSE, FALSE, FALSE, noDefaultRouteFlowControlMap); + } else if ((pParam = GetParam(pArg, "create-filter=")) != NULL) { if (!pFilters) *************** *** 577,588 **** if (plugged > 1 && defaultRouteData) { ! Route(hub, "0:All", FALSE, FALSE, routeDataMap); ! Route(hub, "1:0", FALSE, FALSE, routeDataMap); } ! if (defaultRouteFlowControl) { ! SetFlowControlRoute(routeFlowControlMap, routeDataMap, FALSE); ! } else { ! } hub.SetFlowControlRoute(routeFlowControlMap); --- 609,621 ---- if (plugged > 1 && defaultRouteData) { ! Route(hub, "0:All", FALSE, FALSE, TRUE, routeDataMap); ! Route(hub, "1:0", FALSE, FALSE, TRUE, routeDataMap); } ! PortMap defaultRouteFlowControlMap; ! ! SetFlowControlRoute(defaultRouteFlowControlMap, routeDataMap, FALSE); ! AddRoute(defaultRouteFlowControlMap, noDefaultRouteFlowControlMap, TRUE); ! AddRoute(routeFlowControlMap, defaultRouteFlowControlMap, FALSE); hub.SetFlowControlRoute(routeFlowControlMap); Index: route.h =================================================================== RCS file: /cvsroot/com0com/hub4com/route.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** route.h 24 Nov 2008 12:36:59 -0000 1.2 --- route.h 1 Dec 2008 17:14:52 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/12/01 17:14:52 vfrolov + * Implemented --fc-route and --no-default-fc-route options + * * Revision 1.2 2008/11/24 12:36:59 vfrolov * Changed plugin API *************** *** 42,45 **** --- 45,52 ---- BOOL noRoute, BOOL noEcho); + void AddRoute( + PortMap &map, + PortMap &noMap, + BOOL noRoute); void SetFlowControlRoute( PortMap &routeFlowControlMap, |
From: Vyacheslav F. <vf...@us...> - 2008-12-01 17:09:40
|
Update of /cvsroot/com0com/hub4com/plugins/tcp In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11032 Modified Files: comio.cpp comio.h comport.cpp comport.h import.h port.cpp precomp.h Log Message: Improved write buffering Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comport.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** comport.cpp 27 Nov 2008 13:46:29 -0000 1.11 --- comport.cpp 1 Dec 2008 17:09:34 -0000 1.12 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.12 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.11 2008/11/27 13:46:29 vfrolov * Added --write-limit option *************** *** 140,144 **** writeSuspended(FALSE), writeLost(0), ! writeLostTotal(0) { writeQueueLimitSendXoff = (writeQueueLimit*2)/3; --- 143,149 ---- writeSuspended(FALSE), writeLost(0), ! writeLostTotal(0), ! pWriteBuf(NULL), ! lenWriteBuf(0) { writeQueueLimitSendXoff = (writeQueueLimit*2)/3; *************** *** 197,200 **** --- 202,214 ---- } } + + for (int i = 0 ; i < 3 ; i++) { + WriteOverlapped *pOverlapped = new WriteOverlapped(*this); + + if (pOverlapped) + writeOverlappedBuf.push(pOverlapped); + else + isValid = FALSE; + } } *************** *** 286,289 **** --- 300,330 ---- } + void ComPort::FlowControlUpdate() + { + if (writeSuspended) { + if (writeQueued <= writeQueueLimitSendXon) { + writeSuspended = FALSE; + + HUB_MSG msg; + + msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; + msg.u.val = FALSE; + + pOnRead(hMasterPort, &msg); + } + } else { + if (writeQueued > writeQueueLimitSendXoff) { + writeSuspended = TRUE; + + HUB_MSG msg; + + msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; + msg.u.val = TRUE; + + pOnRead(hMasterPort, &msg); + } + } + } + BOOL ComPort::Write(HUB_MSG *pMsg) { *************** *** 307,355 **** } ! if (isConnected) { ! WriteOverlapped *pOverlapped; ! ! pOverlapped = new WriteOverlapped(*this, pBuf, len); ! if (!pOverlapped) { ! writeLost += len; ! return FALSE; } ! pMsg->type = HUB_MSG_TYPE_EMPTY; ! //if (writeQueued > writeQueueLimit) { ! //} ! if (!pOverlapped->StartWrite()) { writeLost += len; ! delete pOverlapped; return FALSE; } } else { ! if (writeQueued > writeQueueLimit) { ! for (Bufs::const_iterator i = bufs.begin() ; i != bufs.end() ; i++) { ! pBufFree(i->pBuf); ! writeLost += i->len; ! } ! bufs.clear(); ! } ! bufs.push_back(Buf(pBuf, len)); ! pMsg->type = HUB_MSG_TYPE_EMPTY; } writeQueued += len; ! ! if (writeQueued > writeQueueLimitSendXoff && !writeSuspended) { ! writeSuspended = TRUE; ! ! HUB_MSG msg; ! ! msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; ! msg.u.val = TRUE; ! ! pOnRead(hMasterPort, &msg); ! } //cout << "Started Write " << name << " " << len << " " << writeQueued << endl; --- 348,388 ---- } ! if (writeQueued > writeQueueLimit) { ! if (lenWriteBuf) { ! _ASSERTE(pWriteBuf != NULL); ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! lenWriteBuf = 0; ! pBufFree(pWriteBuf); ! pWriteBuf = NULL; } + } ! if (isConnected && writeOverlappedBuf.size()) { ! _ASSERTE(pWriteBuf == NULL); ! _ASSERTE(lenWriteBuf == 0); ! WriteOverlapped *pOverlapped = writeOverlappedBuf.front(); ! _ASSERTE(pOverlapped != NULL); ! ! if (!pOverlapped->StartWrite(pBuf, len)) { writeLost += len; ! FlowControlUpdate(); return FALSE; } + + writeOverlappedBuf.pop(); + pMsg->type = HUB_MSG_TYPE_EMPTY; // detach pBuf } else { ! _ASSERTE((pWriteBuf == NULL && lenWriteBuf == 0) || (pWriteBuf != NULL && lenWriteBuf != 0)); ! pBufAppend(&pWriteBuf, lenWriteBuf, pBuf, len); ! lenWriteBuf += len; } writeQueued += len; ! FlowControlUpdate(); //cout << "Started Write " << name << " " << len << " " << writeQueued << endl; *************** *** 422,426 **** void ComPort::OnWrite(WriteOverlapped *pOverlapped, DWORD len, DWORD done) { ! delete pOverlapped; if (len > done) --- 455,459 ---- void ComPort::OnWrite(WriteOverlapped *pOverlapped, DWORD len, DWORD done) { ! //cout << name << " OnWrite " << ::GetCurrentThreadId() << " len=" << len << " done=" << done << " queued=" << writeQueued << endl; if (len > done) *************** *** 429,442 **** writeQueued -= len; ! if (writeQueued <= writeQueueLimitSendXon && writeSuspended) { ! writeSuspended = FALSE; ! HUB_MSG msg; ! msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; ! msg.u.val = FALSE; ! pOnRead(hMasterPort, &msg); } } --- 462,488 ---- writeQueued -= len; ! _ASSERTE(pWriteBuf != NULL || lenWriteBuf == 0); ! _ASSERTE(pWriteBuf == NULL || lenWriteBuf != 0); ! if (lenWriteBuf && ! isConnected && ! !isDisconnected && ! hSock != INVALID_SOCKET) ! { ! if (!pOverlapped->StartWrite(pWriteBuf, lenWriteBuf)) { ! writeOverlappedBuf.push(pOverlapped); ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! pBufFree(pWriteBuf); ! } ! lenWriteBuf = 0; ! pWriteBuf = NULL; ! } else { ! writeOverlappedBuf.push(pOverlapped); } + + FlowControlUpdate(); } *************** *** 479,482 **** --- 525,540 ---- if (isConnected) { + if (lenWriteBuf) { + _ASSERTE(pWriteBuf != NULL); + + writeLost += lenWriteBuf; + writeQueued -= lenWriteBuf; + lenWriteBuf = 0; + pBufFree(pWriteBuf); + pWriteBuf = NULL; + + FlowControlUpdate(); + } + isConnected = FALSE; *************** *** 548,551 **** --- 606,610 ---- _ASSERTE(isConnected == FALSE); _ASSERTE(isDisconnected == FALSE); + _ASSERTE(hSock != INVALID_SOCKET); isConnected = TRUE; *************** *** 554,575 **** StartRead(); ! for (Bufs::const_iterator i = bufs.begin() ; i != bufs.end() ; i++) { ! WriteOverlapped *pWriteOverlapped; ! pWriteOverlapped = new WriteOverlapped(*this, i->pBuf, i->len); ! if (!pWriteOverlapped) { ! pBufFree(i->pBuf); ! writeLost += i->len; ! continue; ! } ! if (!pWriteOverlapped->StartWrite()) { ! writeLost += i->len; ! delete pWriteOverlapped; ! continue; } } - bufs.clear(); HUB_MSG msg; --- 613,634 ---- StartRead(); ! if (lenWriteBuf && writeOverlappedBuf.size()) { ! WriteOverlapped *pOverlapped = writeOverlappedBuf.front(); ! _ASSERTE(pOverlapped != NULL); ! if (pOverlapped->StartWrite(pWriteBuf, lenWriteBuf)) { ! writeOverlappedBuf.pop(); ! } else { ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! pBufFree(pWriteBuf); ! FlowControlUpdate(); } + + lenWriteBuf = 0; + pWriteBuf = NULL; } HUB_MSG msg; Index: port.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/port.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** port.cpp 27 Nov 2008 13:46:29 -0000 1.10 --- port.cpp 1 Dec 2008 17:09:34 -0000 1.11 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.11 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.10 2008/11/27 13:46:29 vfrolov * Added --write-limit option *************** *** 311,314 **** --- 314,318 ---- ROUTINE_BUF_ALLOC *pBufAlloc; ROUTINE_BUF_FREE *pBufFree; + ROUTINE_BUF_APPEND *pBufAppend; ROUTINE_ON_READ *pOnRead; /////////////////////////////////////////////////////////////// *************** *** 319,322 **** --- 323,327 ---- if (!ROUTINE_IS_VALID(pHubRoutines, pBufAlloc) || !ROUTINE_IS_VALID(pHubRoutines, pBufFree) || + !ROUTINE_IS_VALID(pHubRoutines, pBufAppend) || !ROUTINE_IS_VALID(pHubRoutines, pOnRead)) { *************** *** 326,329 **** --- 331,335 ---- pBufAlloc = pHubRoutines->pBufAlloc; pBufFree = pHubRoutines->pBufFree; + pBufAppend = pHubRoutines->pBufAppend; pOnRead = pHubRoutines->pOnRead; Index: comport.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comport.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** comport.h 24 Nov 2008 16:30:56 -0000 1.7 --- comport.h 1 Dec 2008 17:09:34 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.7 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 72,84 **** }; /////////////////////////////////////////////////////////////// - struct Buf { - Buf(BYTE *_pBuf, DWORD _len) : pBuf(_pBuf), len(_len) {} - - BYTE *pBuf; - DWORD len; - }; - - typedef vector<Buf> Bufs; - /////////////////////////////////////////////////////////////// class ComPort { --- 75,78 ---- *************** *** 105,108 **** --- 99,103 ---- private: + void FlowControlUpdate(); BOOL StartRead(); BOOL StartWaitEvent(SOCKET hSockWait); *************** *** 139,143 **** DWORD writeLostTotal; ! Bufs bufs; }; /////////////////////////////////////////////////////////////// --- 134,140 ---- DWORD writeLostTotal; ! queue<WriteOverlapped *> writeOverlappedBuf; ! BYTE *pWriteBuf; ! DWORD lenWriteBuf; }; /////////////////////////////////////////////////////////////// Index: comio.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comio.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** comio.h 17 Nov 2008 16:44:57 -0000 1.4 --- comio.h 1 Dec 2008 17:09:34 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.4 2008/11/17 16:44:57 vfrolov * Fixed race conditions *************** *** 69,75 **** { public: ! WriteOverlapped(ComPort &_port, BYTE *_pBuf, DWORD _len); ! ~WriteOverlapped(); ! BOOL StartWrite(); private: --- 72,87 ---- { public: ! WriteOverlapped(ComPort &_port) : port(_port) { ! #ifdef _DEBUG ! pBuf = NULL; ! #endif ! } ! #ifdef _DEBUG ! ~WriteOverlapped() { ! _ASSERTE(pBuf == NULL); ! } ! #endif ! ! BOOL StartWrite(BYTE *_pBuf, DWORD _len); private: *************** *** 78,81 **** --- 90,94 ---- DWORD done, LPOVERLAPPED pOverlapped); + void BufFree(); ComPort &port; Index: precomp.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/precomp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** precomp.h 27 Mar 2008 17:18:52 -0000 1.1 --- precomp.h 1 Dec 2008 17:09:34 -0000 1.2 *************** *** 20,27 **** * * $Log$ * Revision 1.1 2008/03/27 17:18:52 vfrolov * Initial revision * - * */ --- 20,29 ---- * * $Log$ + * Revision 1.2 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.1 2008/03/27 17:18:52 vfrolov * Initial revision * */ *************** *** 35,43 **** #include <crtdbg.h> - #include <string> - #include <vector> #include <queue> #include <iostream> - #include <fstream> #include <sstream> --- 37,42 ---- Index: import.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/import.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** import.h 24 Nov 2008 16:30:56 -0000 1.4 --- import.h 1 Dec 2008 17:09:34 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.4 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 40,43 **** --- 43,47 ---- extern ROUTINE_BUF_ALLOC *pBufAlloc; extern ROUTINE_BUF_FREE *pBufFree; + extern ROUTINE_BUF_APPEND *pBufAppend; extern ROUTINE_ON_READ *pOnRead; /////////////////////////////////////////////////////////////// Index: comio.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comio.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** comio.cpp 17 Nov 2008 16:44:57 -0000 1.6 --- comio.cpp 1 Dec 2008 17:09:34 -0000 1.7 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.7 2008/12/01 17:09:34 vfrolov + * Improved write buffering + * * Revision 1.6 2008/11/17 16:44:57 vfrolov * Fixed race conditions *************** *** 205,220 **** } /////////////////////////////////////////////////////////////// - WriteOverlapped::WriteOverlapped(ComPort &_port, BYTE *_pBuf, DWORD _len) - : port(_port), - pBuf(_pBuf), - len(_len) - { - } - - WriteOverlapped::~WriteOverlapped() - { - pBufFree(pBuf); - } - VOID CALLBACK WriteOverlapped::OnWrite( DWORD err, --- 208,211 ---- *************** *** 224,227 **** --- 215,220 ---- WriteOverlapped *pOver = (WriteOverlapped *)pOverlapped; + pOver->BufFree(); + if (err != ERROR_SUCCESS && err != ERROR_OPERATION_ABORTED) TraceError(err, "WriteOverlapped::OnWrite: %s", pOver->port.Name().c_str()); *************** *** 230,245 **** } ! BOOL WriteOverlapped::StartWrite() { ::memset((OVERLAPPED *)this, 0, sizeof(OVERLAPPED)); ! if (!pBuf) ! return FALSE; ! if (!::WriteFileEx(port.Handle(), pBuf, len, this, OnWrite)) { TraceError(GetLastError(), "WriteOverlapped::StartWrite(): WriteFileEx(%x) %s", port.Handle(), port.Name().c_str()); return FALSE; } return TRUE; } --- 223,254 ---- } ! void WriteOverlapped::BufFree() { + _ASSERTE(pBuf != NULL); + + pBufFree(pBuf); + + #ifdef _DEBUG + pBuf = NULL; + #endif + } + + BOOL WriteOverlapped::StartWrite(BYTE *_pBuf, DWORD _len) + { + _ASSERTE(pBuf == NULL); + ::memset((OVERLAPPED *)this, 0, sizeof(OVERLAPPED)); ! _ASSERTE(_pBuf != NULL); ! _ASSERTE(_len != 0); ! if (!::WriteFileEx(port.Handle(), _pBuf, _len, this, OnWrite)) { TraceError(GetLastError(), "WriteOverlapped::StartWrite(): WriteFileEx(%x) %s", port.Handle(), port.Name().c_str()); return FALSE; } + pBuf = _pBuf; + len = _len; + return TRUE; } |
From: Vyacheslav F. <vf...@us...> - 2008-12-01 17:06:35
|
Update of /cvsroot/com0com/hub4com/plugins/serial In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10820 Modified Files: comio.cpp comio.h comport.cpp comport.h precomp.h Log Message: Improved write buffering Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** comport.cpp 27 Nov 2008 16:25:08 -0000 1.19 --- comport.cpp 1 Dec 2008 17:06:29 -0000 1.20 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.20 2008/12/01 17:06:29 vfrolov + * Improved write buffering + * * Revision 1.19 2008/11/27 16:25:08 vfrolov * Improved write buffering *************** *** 120,130 **** const char *pPath) : hMasterPort(NULL), - countWriteOverlapped(0), countReadOverlapped(0), countWaitCommEventOverlapped(0), countXoff(0), filterX(FALSE), - pWriteBuf(NULL), - lenWriteBuf(0), intercepted_options(0), inOptions(0), --- 123,130 ---- *************** *** 135,139 **** writeLost(0), writeLostTotal(0), ! errors(0) { writeQueueLimitSendXoff = (writeQueueLimit*2)/3; --- 135,141 ---- writeLost(0), writeLostTotal(0), ! errors(0), ! pWriteBuf(NULL), ! lenWriteBuf(0) { writeQueueLimitSendXoff = (writeQueueLimit*2)/3; *************** *** 154,157 **** --- 156,170 ---- pComIo = NULL; } + + for (int i = 0 ; i < 3 ; i++) { + WriteOverlapped *pOverlapped = new WriteOverlapped(); + + if (!pOverlapped) { + cerr << "No enough memory." << endl; + exit(2); + } + + writeOverlappedBuf.push(pOverlapped); + } } *************** *** 473,476 **** --- 486,516 ---- } + void ComPort::FlowControlUpdate() + { + if (writeSuspended) { + if (writeQueued <= writeQueueLimitSendXon) { + writeSuspended = FALSE; + + HUB_MSG msg; + + msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; + msg.u.val = FALSE; + + pOnRead(hMasterPort, &msg); + } + } else { + if (writeQueued > writeQueueLimitSendXoff) { + writeSuspended = TRUE; + + HUB_MSG msg; + + msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; + msg.u.val = TRUE; + + pOnRead(hMasterPort, &msg); + } + } + } + BOOL ComPort::Write(HUB_MSG *pMsg) { *************** *** 525,550 **** } ! if (countWriteOverlapped < 3) { _ASSERTE(pWriteBuf == NULL); _ASSERTE(lenWriteBuf == 0); ! WriteOverlapped *pOverlapped; ! ! pOverlapped = new WriteOverlapped(*pComIo, pBuf, len); ! ! if (!pOverlapped) { ! writeLost += len; ! return FALSE; ! } ! pMsg->type = HUB_MSG_TYPE_EMPTY; ! if (!pOverlapped->StartWrite()) { writeLost += len; ! delete pOverlapped; return FALSE; } ! countWriteOverlapped++; } else { _ASSERTE((pWriteBuf == NULL && lenWriteBuf == 0) || (pWriteBuf != NULL && lenWriteBuf != 0)); --- 565,584 ---- } ! if (writeOverlappedBuf.size()) { _ASSERTE(pWriteBuf == NULL); _ASSERTE(lenWriteBuf == 0); ! WriteOverlapped *pOverlapped = writeOverlappedBuf.front(); ! _ASSERTE(pOverlapped != NULL); ! if (!pOverlapped->StartWrite(pComIo, pBuf, len)) { writeLost += len; ! FlowControlUpdate(); return FALSE; } ! writeOverlappedBuf.pop(); ! pMsg->type = HUB_MSG_TYPE_EMPTY; // detach pBuf } else { _ASSERTE((pWriteBuf == NULL && lenWriteBuf == 0) || (pWriteBuf != NULL && lenWriteBuf != 0)); *************** *** 555,569 **** writeQueued += len; ! ! if (writeQueued > writeQueueLimitSendXoff && !writeSuspended) { ! writeSuspended = TRUE; ! ! HUB_MSG msg; ! ! msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; ! msg.u.val = TRUE; ! ! pOnRead(hMasterPort, &msg); ! } //cout << name << " Started Write " << len << " " << writeQueued << endl; --- 589,593 ---- writeQueued += len; ! FlowControlUpdate(); //cout << name << " Started Write " << len << " " << writeQueued << endl; *************** *** 762,768 **** //cout << name << " OnWrite " << ::GetCurrentThreadId() << " len=" << len << " done=" << done << " queued=" << writeQueued << endl; - countWriteOverlapped--; - delete pOverlapped; - if (len > done) writeLost += len - done; --- 786,789 ---- *************** *** 771,809 **** _ASSERTE(pComIo != NULL); if (lenWriteBuf) { ! _ASSERTE(pWriteBuf != NULL); ! ! pOverlapped = new WriteOverlapped(*pComIo, pWriteBuf, lenWriteBuf); ! ! if (pOverlapped) { ! if (pOverlapped->StartWrite()) { ! countWriteOverlapped++; ! } else { ! delete pOverlapped; ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! } ! } else { ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! pBufFree(pWriteBuf); } lenWriteBuf = 0; pWriteBuf = NULL; } ! if (writeQueued <= writeQueueLimitSendXon && writeSuspended) { ! writeSuspended = FALSE; ! ! HUB_MSG msg; ! ! msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; ! msg.u.val = FALSE; ! ! pOnRead(hMasterPort, &msg); ! } } --- 792,814 ---- _ASSERTE(pComIo != NULL); + _ASSERTE(pWriteBuf != NULL || lenWriteBuf == 0); + _ASSERTE(pWriteBuf == NULL || lenWriteBuf != 0); if (lenWriteBuf) { ! if (!pOverlapped->StartWrite(pComIo, pWriteBuf, lenWriteBuf)) { ! writeOverlappedBuf.push(pOverlapped); ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! pBufFree(pWriteBuf); } lenWriteBuf = 0; pWriteBuf = NULL; + } else { + writeOverlappedBuf.push(pOverlapped); } ! FlowControlUpdate(); } Index: precomp.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/precomp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** precomp.h 26 Mar 2008 08:40:45 -0000 1.1 --- precomp.h 1 Dec 2008 17:06:29 -0000 1.2 *************** *** 20,27 **** * * $Log$ * Revision 1.1 2008/03/26 08:40:45 vfrolov * Initial revision * - * */ --- 20,29 ---- * * $Log$ + * Revision 1.2 2008/12/01 17:06:29 vfrolov + * Improved write buffering + * * Revision 1.1 2008/03/26 08:40:45 vfrolov * Initial revision * */ *************** *** 34,42 **** #include <crtdbg.h> ! #include <string> ! #include <vector> ! #include <map> #include <iostream> - #include <fstream> #include <sstream> --- 36,41 ---- #include <crtdbg.h> ! #include <queue> #include <iostream> #include <sstream> Index: comio.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comio.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** comio.h 13 Nov 2008 07:35:10 -0000 1.9 --- comio.h 1 Dec 2008 17:06:29 -0000 1.10 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.10 2008/12/01 17:06:29 vfrolov + * Improved write buffering + * * Revision 1.9 2008/11/13 07:35:10 vfrolov * Changed for staticaly linking *************** *** 139,145 **** { public: ! WriteOverlapped(ComIo &_comIo, BYTE *_pBuf, DWORD _len); ! ~WriteOverlapped(); ! BOOL StartWrite(); private: --- 142,153 ---- { public: ! #ifdef _DEBUG ! WriteOverlapped() : pBuf(NULL) {} ! ~WriteOverlapped() { ! _ASSERTE(pBuf == NULL); ! } ! #endif ! ! BOOL StartWrite(ComIo *_pComIo, BYTE *_pBuf, DWORD _len); private: *************** *** 148,153 **** DWORD done, LPOVERLAPPED pOverlapped); ! ComIo &comIo; BYTE *pBuf; DWORD len; --- 156,162 ---- DWORD done, LPOVERLAPPED pOverlapped); + void BufFree(); ! ComIo *pComIo; BYTE *pBuf; DWORD len; Index: comio.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comio.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** comio.cpp 13 Nov 2008 07:35:10 -0000 1.12 --- comio.cpp 1 Dec 2008 17:06:29 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/12/01 17:06:29 vfrolov + * Improved write buffering + * * Revision 1.12 2008/11/13 07:35:10 vfrolov * Changed for staticaly linking *************** *** 647,662 **** } /////////////////////////////////////////////////////////////// - WriteOverlapped::WriteOverlapped(ComIo &_comIo, BYTE *_pBuf, DWORD _len) - : comIo(_comIo), - pBuf(_pBuf), - len(_len) - { - } - - WriteOverlapped::~WriteOverlapped() - { - pBufFree(pBuf); - } - VOID CALLBACK WriteOverlapped::OnWrite( DWORD err, --- 650,653 ---- *************** *** 666,684 **** WriteOverlapped *pOver = (WriteOverlapped *)pOverlapped; if (err != ERROR_SUCCESS && err != ERROR_OPERATION_ABORTED) ! TraceError(err, "WriteOverlapped::OnWrite: %s", pOver->comIo.port.Name().c_str()); ! pOver->comIo.port.OnWrite(pOver, pOver->len, done); } ! BOOL WriteOverlapped::StartWrite() { ::memset((OVERLAPPED *)this, 0, sizeof(OVERLAPPED)); ! if (!pBuf) ! return FALSE; ! if (!::WriteFileEx(comIo.Handle(), pBuf, len, this, OnWrite)) return FALSE; return TRUE; --- 657,697 ---- WriteOverlapped *pOver = (WriteOverlapped *)pOverlapped; + pOver->BufFree(); + if (err != ERROR_SUCCESS && err != ERROR_OPERATION_ABORTED) ! TraceError(err, "WriteOverlapped::OnWrite: %s", pOver->pComIo->port.Name().c_str()); ! pOver->pComIo->port.OnWrite(pOver, pOver->len, done); } ! void WriteOverlapped::BufFree() { + _ASSERTE(pBuf != NULL); + + pBufFree(pBuf); + + #ifdef _DEBUG + pBuf = NULL; + #endif + } + + BOOL WriteOverlapped::StartWrite(ComIo *_pComIo, BYTE *_pBuf, DWORD _len) + { + _ASSERTE(pBuf == NULL); + ::memset((OVERLAPPED *)this, 0, sizeof(OVERLAPPED)); ! _ASSERTE(_pComIo != NULL); ! _ASSERTE(_pBuf != NULL); ! _ASSERTE(_len != 0); ! if (!::WriteFileEx(_pComIo->Handle(), _pBuf, _len, this, OnWrite)) { ! TraceError(GetLastError(), "WriteOverlapped::StartWrite(): WriteFileEx(%x) %s", _pComIo->Handle(), _pComIo->port.Name().c_str()); return FALSE; + } + + pComIo = _pComIo; + pBuf = _pBuf; + len = _len; return TRUE; Index: comport.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** comport.h 27 Nov 2008 16:25:08 -0000 1.13 --- comport.h 1 Dec 2008 17:06:29 -0000 1.14 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.14 2008/12/01 17:06:29 vfrolov + * Improved write buffering + * * Revision 1.13 2008/11/27 16:25:08 vfrolov * Improved write buffering *************** *** 115,118 **** --- 118,122 ---- private: + void FlowControlUpdate(); BOOL StartRead(); BOOL StartWaitCommEvent(); *************** *** 122,126 **** string name; HMASTERPORT hMasterPort; - int countWriteOverlapped; int countReadOverlapped; int countWaitCommEventOverlapped; --- 126,129 ---- *************** *** 128,134 **** BOOL filterX; - BYTE *pWriteBuf; - DWORD lenWriteBuf; - DWORD intercepted_options; DWORD inOptions; --- 131,134 ---- *************** *** 143,146 **** --- 143,150 ---- DWORD writeLostTotal; DWORD errors; + + queue<WriteOverlapped *> writeOverlappedBuf; + BYTE *pWriteBuf; + DWORD lenWriteBuf; }; /////////////////////////////////////////////////////////////// |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:40:47
|
Update of /cvsroot/com0com/hub4com In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17127 Modified Files: hub4com.sln Log Message: Added port-connector and filter-tag Index: hub4com.sln =================================================================== RCS file: /cvsroot/com0com/hub4com/hub4com.sln,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** hub4com.sln 16 Oct 2008 07:09:10 -0000 1.11 --- hub4com.sln 27 Nov 2008 16:40:41 -0000 1.12 *************** *** 28,31 **** --- 28,35 ---- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filter-lsrmap", "plugins\lsrmap\lsrmap.vcproj", "{9089D426-5B23-4F82-B32E-33D56AF225DC}" EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "port-connector", "plugins\connector\connector.vcproj", "{630AEA21-57A9-4803-BA9A-F85DCB73CD5D}" + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filter-tag", "plugins\tag\tag.vcproj", "{523E524B-786C-45AB-A393-5135706449BC}" + EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution *************** *** 86,89 **** --- 90,101 ---- {9089D426-5B23-4F82-B32E-33D56AF225DC}.Release|Win32.ActiveCfg = Release|Win32 {9089D426-5B23-4F82-B32E-33D56AF225DC}.Release|Win32.Build.0 = Release|Win32 + {630AEA21-57A9-4803-BA9A-F85DCB73CD5D}.Debug|Win32.ActiveCfg = Debug|Win32 + {630AEA21-57A9-4803-BA9A-F85DCB73CD5D}.Debug|Win32.Build.0 = Debug|Win32 + {630AEA21-57A9-4803-BA9A-F85DCB73CD5D}.Release|Win32.ActiveCfg = Release|Win32 + {630AEA21-57A9-4803-BA9A-F85DCB73CD5D}.Release|Win32.Build.0 = Release|Win32 + {523E524B-786C-45AB-A393-5135706449BC}.Debug|Win32.ActiveCfg = Debug|Win32 + {523E524B-786C-45AB-A393-5135706449BC}.Debug|Win32.Build.0 = Debug|Win32 + {523E524B-786C-45AB-A393-5135706449BC}.Release|Win32.ActiveCfg = Release|Win32 + {523E524B-786C-45AB-A393-5135706449BC}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:38:11
|
Update of /cvsroot/com0com/hub4com/plugins/connector In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16861/connector Added Files: comport.cpp comport.h connector.vcproj import.h port.cpp precomp.cpp precomp.h Log Message: Initial revision --- NEW FILE: precomp.cpp --- /* * $Id: precomp.cpp,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /////////////////////////////////////////////////////////////// #include "precomp.h" /////////////////////////////////////////////////////////////// --- NEW FILE: comport.cpp --- /* * $Id: comport.cpp,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: comport.cpp,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #include "precomp.h" #include "../plugins_api.h" /////////////////////////////////////////////////////////////// namespace PortConnector { /////////////////////////////////////////////////////////////// #include "comport.h" #include "import.h" /////////////////////////////////////////////////////////////// ComPort::ComPort(const char *pPath) : hMasterPort(NULL), name(pPath), countConnections(0), countXoff(0) { } BOOL ComPort::Init(HMASTERPORT _hMasterPort) { hMasterPort = _hMasterPort; return TRUE; } BOOL ComPort::FakeReadFilter(HUB_MSG *pInMsg) { _ASSERTE(pInMsg != NULL); switch (pInMsg->type) { case HUB_MSG_TYPE_LOOP_TEST: pInMsg->u.hVal = (HANDLE)hMasterPort; break; } return pInMsg != NULL; } BOOL ComPort::Write(HUB_MSG *pMsg) { _ASSERTE(pMsg != NULL); switch (pMsg->type) { case HUB_MSG_TYPE_LOOP_TEST: for (Ports::const_iterator i = connectedDataPorts.begin() ; i != connectedDataPorts.end() ; i++) { if (pMsg->u.hVal == (HANDLE)(*i)->hMasterPort) { cerr << "Loop detected on link " << Name() << "->" << (*i)->Name() << endl; exit(1); } } break; case HUB_MSG_TYPE_LINE_DATA: if (!pMsg->u.buf.size) break; for (Ports::const_iterator i = connectedDataPorts.begin() ; i != connectedDataPorts.end() ; i++) { BYTE *pBuf = pBufAlloc(pMsg->u.buf.size); if (!pBuf) return FALSE; memcpy(pBuf, pMsg->u.buf.pBuf, pMsg->u.buf.size); HUB_MSG msg; msg.type = HUB_MSG_TYPE_LINE_DATA; msg.u.buf.pBuf = pBuf; msg.u.buf.size = pMsg->u.buf.size; pOnRead((*i)->hMasterPort, &msg); } break; case HUB_MSG_TYPE_CONNECT: if (pMsg->u.val) { if (countConnections++ != 0) break; } else { if (--countConnections != 0) break; } for (Ports::const_iterator i = connectedDataPorts.begin() ; i != connectedDataPorts.end() ; i++) { HUB_MSG msg; msg.type = HUB_MSG_TYPE_CONNECT; msg.u.val = pMsg->u.val; pOnRead((*i)->hMasterPort, &msg); } break; case HUB_MSG_TYPE_SET_OUT_OPTS: if (pMsg->u.val) { cerr << name << " WARNING: Requested output option(s) [0x" << hex << pMsg->u.val << dec << "] will be ignored by driver" << endl; } break; case HUB_MSG_TYPE_ADD_XOFF_XON: if (pMsg->u.val) { if (countXoff++ != 0) break; for (Ports::const_iterator i = connectedFlowControlPorts.begin() ; i != connectedFlowControlPorts.end() ; i++) { HUB_MSG msg; msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; msg.u.val = TRUE; pOnRead((*i)->hMasterPort, &msg); } } else { if (--countXoff != 0) break; for (Ports::const_iterator i = connectedFlowControlPorts.begin() ; i != connectedFlowControlPorts.end() ; i++) { HUB_MSG msg; msg.type = HUB_MSG_TYPE_ADD_XOFF_XON; msg.u.val = FALSE; pOnRead((*i)->hMasterPort, &msg); } } break; } return TRUE; } /////////////////////////////////////////////////////////////// } // end namespace /////////////////////////////////////////////////////////////// --- NEW FILE: port.cpp --- /* * $Id: port.cpp,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: port.cpp,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #include "precomp.h" #include "../plugins_api.h" /////////////////////////////////////////////////////////////// namespace PortConnector { /////////////////////////////////////////////////////////////// #include "comport.h" #include "import.h" /////////////////////////////////////////////////////////////// class Params { public: void AddPort(ComPort *pPort) { ports.insert(pPort); } void Connect(const char *pParam, BOOL biDirection); void Connect() const; protected: typedef set<string> PortNames; typedef map<string, PortNames> PortNameMap; typedef pair<string, PortNames> PortNamePair; void Connect(PortNameMap &portMap, const PortNames &listR, const PortNames &listL); void Connect(BOOL flowControl) const; ComPort *Find(const string &name) const; Ports ports; PortNameMap portDataMap; PortNameMap portFlowControlMap; }; ComPort *Params::Find(const string &name) const { for (Ports::const_iterator i = ports.begin() ; i != ports.end() ; i++) { if ((*i)->Name() == name) return *i; } return NULL; } void Params::Connect() const { Connect(FALSE); Connect(TRUE); } void Params::Connect(BOOL flowControl) const { const PortNameMap &portMap = (flowControl ? portFlowControlMap : portDataMap); for (PortNameMap::const_iterator i = portMap.begin() ; i != portMap.end() ; i++) { cout << "Connect fake port " << (flowControl ? "flow control" : "data") << " " << i->first << " -->"; ComPort *pFrom = Find(i->first); if (!pFrom) { cout << endl; cerr << "Can't find fake port " << i->first << endl; exit(1); } for (PortNames::const_iterator j = i->second.begin() ; j != i->second.end() ; j++) { cout << " " << *j; ComPort *pTo = Find(*j); if (!pTo) { cout << endl; cerr << "Can't find fake port " << *j << endl; exit(1); } if (flowControl) pFrom->ConnectFlowControlPort(pTo); else pFrom->ConnectDataPort(pTo); } cout << endl; } } void Params::Connect(PortNameMap &portMap, const PortNames &listR, const PortNames &listL) { for (PortNames::const_iterator i = listR.begin() ; i != listR.end() ; i++) { PortNameMap::iterator iPair = portMap.find(*i); if (iPair == portMap.end()) { portMap.insert(PortNamePair(*i, PortNames())); iPair = portMap.find(*i); if (iPair == portMap.end()) { cerr << "Can't add port " << *i << endl; exit(2); } } for (PortNames::const_iterator j = listL.begin() ; j != listL.end() ; j++) iPair->second.insert(*j); } } void Params::Connect(const char *pParam, BOOL biDirection) { string par(pParam); PortNames listR; for (;;) { string::size_type n = par.find_first_of(",:"); if (n == 0) { cerr << "Empty token in " << pParam << endl; exit(1); } if (n == string::npos) { cerr << "Missing colon in " << pParam << endl; exit(1); } listR.insert(par.substr(0, n)); BOOL last = (par[n] == ':'); par.erase(0, n + 1); if (last) break; } PortNames listL; for (;;) { string::size_type n = par.find_first_of(","); if (n == 0 || par.empty()) { cerr << "Empty token in " << pParam << endl; exit(1); } listL.insert(par.substr(0, n)); if (n == string::npos) break; par.erase(0, n + 1); } Connect(portDataMap, listR, listL); Connect(portFlowControlMap, listL, listR); if (biDirection) { Connect(portDataMap, listL, listR); Connect(portFlowControlMap, listR, listL); } } /////////////////////////////////////////////////////////////// static const char *GetParam(const char *pArg, const char *pPattern) { size_t lenPattern = strlen(pPattern); if (_strnicmp(pArg, pPattern, lenPattern) != 0) return NULL; return pArg + lenPattern; } /////////////////////////////////////////////////////////////// static PLUGIN_TYPE CALLBACK GetPluginType() { return PLUGIN_TYPE_DRIVER; } /////////////////////////////////////////////////////////////// static const PLUGIN_ABOUT_A about = { sizeof(PLUGIN_ABOUT_A), "connector", "Copyright (c) 2008 Vyacheslav Frolov", "GNU General Public License", "Connectable fake port driver", }; static const PLUGIN_ABOUT_A * CALLBACK GetPluginAbout() { return &about; } /////////////////////////////////////////////////////////////// static void CALLBACK Help(const char *pProgPath) { cerr << "Usage:" << endl << " " << pProgPath << " ... --use-driver=" << GetPluginAbout()->pName << " <port1> <port2> ..." << endl << endl << "Connect options:" << endl << " --connect=<LstR>:<LstL> - handle data sent to any port listed in <LstR>" << endl << " as data received by all ports listed in <LstL>." << endl << " --bi-connect=<LstR>:<LstL> - handle data sent to any port listed in <LstR>" << endl << " as data received by all ports listed in <LstL>" << endl << " and vice versa." << endl << endl << "The syntax of <LstR> and <LstL> above is <port1>[,<port2>...], where <portN> is" << endl << "a name of connectable fake port." << endl << endl << "Output data stream description:" << endl << " LINE_DATA(<data>) - write <data> to serial port." << endl << " CONNECT(TRUE) - serial port started." << endl << endl << "Input data stream description:" << endl << " LINE_DATA(<data>) - readed <data> from serial port." << endl << " CONNECT(TRUE) - serial port started." << endl << endl << "Examples:" << endl ; } /////////////////////////////////////////////////////////////// static HCONFIG CALLBACK ConfigStart() { Params *pParams = new Params; if (!pParams) { cerr << "No enough memory." << endl; exit(2); } return (HCONFIG)pParams; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK Config( HCONFIG hConfig, const char *pArg) { _ASSERTE(hConfig != NULL); const char *pParam; if ((pParam = GetParam(pArg, "--connect=")) != NULL) ((Params *)hConfig)->Connect(pParam, FALSE); else if ((pParam = GetParam(pArg, "--bi-connect=")) != NULL) ((Params *)hConfig)->Connect(pParam, TRUE); else return FALSE; return TRUE; } /////////////////////////////////////////////////////////////// static void CALLBACK ConfigStop( HCONFIG hConfig) { _ASSERTE(hConfig != NULL); ((Params *)hConfig)->Connect(); delete (Params *)hConfig; } /////////////////////////////////////////////////////////////// static HPORT CALLBACK Create( HCONFIG hConfig, const char *pPath) { _ASSERTE(hConfig != NULL); ComPort *pPort = new ComPort(pPath); if (!pPort) return NULL; ((Params *)hConfig)->AddPort(pPort); return (HPORT)pPort; } /////////////////////////////////////////////////////////////// static const char *CALLBACK GetPortName( HPORT hPort) { _ASSERTE(hPort != NULL); return ((ComPort *)hPort)->Name().c_str(); } /////////////////////////////////////////////////////////////// static BOOL CALLBACK Init( HPORT hPort, HMASTERPORT hMasterPort) { _ASSERTE(hPort != NULL); _ASSERTE(hMasterPort != NULL); return ((ComPort *)hPort)->Init(hMasterPort); } /////////////////////////////////////////////////////////////// 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, HUB_MSG *pMsg) { _ASSERTE(hPort != NULL); _ASSERTE(pMsg != NULL); return ((ComPort *)hPort)->Write(pMsg); } /////////////////////////////////////////////////////////////// static const PORT_ROUTINES_A routines = { sizeof(PORT_ROUTINES_A), GetPluginType, GetPluginAbout, Help, ConfigStart, Config, ConfigStop, Create, GetPortName, NULL, // SetPortName Init, NULL, // Start FakeReadFilter, Write, NULL, // LostReport }; static const PLUGIN_ROUTINES_A *const plugins[] = { (const PLUGIN_ROUTINES_A *)&routines, NULL }; /////////////////////////////////////////////////////////////// ROUTINE_BUF_ALLOC *pBufAlloc; ROUTINE_ON_READ *pOnRead; /////////////////////////////////////////////////////////////// PLUGIN_INIT_A InitA; const PLUGIN_ROUTINES_A *const * CALLBACK InitA( const HUB_ROUTINES_A * pHubRoutines) { if (!ROUTINE_IS_VALID(pHubRoutines, pBufAlloc) || !ROUTINE_IS_VALID(pHubRoutines, pOnRead)) { return NULL; } pBufAlloc = pHubRoutines->pBufAlloc; pOnRead = pHubRoutines->pOnRead; return plugins; } /////////////////////////////////////////////////////////////// } // end namespace /////////////////////////////////////////////////////////////// --- NEW FILE: comport.h --- /* * $Id: comport.h,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: comport.h,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #ifndef _COMPORT_H #define _COMPORT_H /////////////////////////////////////////////////////////////// class ComPort; typedef set<ComPort *> Ports; /////////////////////////////////////////////////////////////// class ComPort { public: ComPort(const char *pPath); BOOL Init(HMASTERPORT _hMasterPort); BOOL FakeReadFilter(HUB_MSG *pInMsg); BOOL Write(HUB_MSG *pMsg); void ConnectDataPort(ComPort *pPort) { connectedDataPorts.insert(pPort); } void ConnectFlowControlPort(ComPort *pPort) { connectedFlowControlPorts.insert(pPort); } const string &Name() const { return name; } private: string name; HMASTERPORT hMasterPort; Ports connectedDataPorts; Ports connectedFlowControlPorts; int countConnections; int countXoff; }; /////////////////////////////////////////////////////////////// #endif // _COMPORT_H --- NEW FILE: connector.vcproj --- <?xml version="1.0" encoding="windows-1251"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="port-connector" ProjectGUID="{630AEA21-57A9-4803-BA9A-F85DCB73CD5D}" RootNamespace="hub4com" Keyword="Win32Proj" > <Platforms> <Platform Name="Win32" /> </Platforms> <ToolFiles> </ToolFiles> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="2" UseOfMFC="0" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="0" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" UsePrecompiledHeader="2" PrecompiledHeaderThrough="precomp.h" PrecompiledHeaderFile="$(IntDir)\precomp.pch" WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" OutputFile="..\..\$(OutDir)\plugins\$(ProjectName).dll" LinkIncremental="2" ModuleDefinitionFile="..\plugins.def" GenerateDebugInformation="true" SubSystem="1" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="2" UseOfMFC="0" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="0" UsePrecompiledHeader="2" PrecompiledHeaderThrough="precomp.h" PrecompiledHeaderFile="$(IntDir)\precomp.pch" WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" OutputFile="..\..\$(OutDir)\plugins\$(ProjectName).dll" LinkIncremental="2" ModuleDefinitionFile="..\plugins.def" GenerateDebugInformation="true" SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File RelativePath=".\comport.h" > </File> <File RelativePath=".\import.h" > </File> <File RelativePath="..\plugins_api.h" > </File> <File RelativePath=".\precomp.h" > </File> </Filter> <Filter Name="Source Files" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File RelativePath=".\comport.cpp" > </File> <File RelativePath="..\plugins.def" > </File> <File RelativePath=".\port.cpp" > </File> <File RelativePath=".\precomp.cpp" > <FileConfiguration Name="Debug|Win32" > <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="1" /> </FileConfiguration> <FileConfiguration Name="Release|Win32" > <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="1" /> </FileConfiguration> </File> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: precomp.h --- /* * $Id: precomp.h,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: precomp.h,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #ifndef _PRECOMP_H_ #define _PRECOMP_H_ #include <windows.h> #include <crtdbg.h> #include <map> #include <set> #include <vector> #include <string> #include <iostream> using namespace std; #pragma warning(disable:4512) // assignment operator could not be generated #endif /* _PRECOMP_H_ */ --- NEW FILE: import.h --- /* * $Id: import.h,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: import.h,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #ifndef _IMPORT_H #define _IMPORT_H /////////////////////////////////////////////////////////////// extern ROUTINE_BUF_ALLOC *pBufAlloc; extern ROUTINE_ON_READ *pOnRead; /////////////////////////////////////////////////////////////// #endif // _IMPORT_H |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:38:11
|
Update of /cvsroot/com0com/hub4com/plugins/tag In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16861/tag Added Files: filter.cpp precomp.cpp precomp.h tag.vcproj Log Message: Initial revision --- NEW FILE: tag.vcproj --- <?xml version="1.0" encoding="windows-1251"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="filter-tag" ProjectGUID="{523E524B-786C-45AB-A393-5135706449BC}" RootNamespace="hub4com" Keyword="Win32Proj" > <Platforms> <Platform Name="Win32" /> </Platforms> <ToolFiles> </ToolFiles> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="2" UseOfMFC="0" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="0" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" UsePrecompiledHeader="2" PrecompiledHeaderThrough="precomp.h" PrecompiledHeaderFile="$(IntDir)\precomp.pch" WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" OutputFile="..\..\$(OutDir)\plugins\$(ProjectName).dll" LinkIncremental="2" ModuleDefinitionFile="..\plugins.def" GenerateDebugInformation="true" SubSystem="1" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="2" UseOfMFC="0" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="0" UsePrecompiledHeader="2" PrecompiledHeaderThrough="precomp.h" PrecompiledHeaderFile="$(IntDir)\precomp.pch" WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" OutputFile="..\..\$(OutDir)\plugins\$(ProjectName).dll" LinkIncremental="2" ModuleDefinitionFile="..\plugins.def" GenerateDebugInformation="true" SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File RelativePath="..\plugins_api.h" > </File> <File RelativePath=".\precomp.h" > </File> </Filter> <Filter Name="Source Files" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File RelativePath=".\filter.cpp" > </File> <File RelativePath="..\plugins.def" > </File> <File RelativePath=".\precomp.cpp" > <FileConfiguration Name="Debug|Win32" > <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="1" /> </FileConfiguration> <FileConfiguration Name="Release|Win32" > <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="1" /> </FileConfiguration> </File> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: precomp.h --- /* * $Id: precomp.h,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: precomp.h,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #ifndef _PRECOMP_H_ #define _PRECOMP_H_ #include <windows.h> #include <crtdbg.h> #include <iostream> using namespace std; #pragma warning(disable:4512) // assignment operator could not be generated #endif /* _PRECOMP_H_ */ --- NEW FILE: precomp.cpp --- /* * $Id: precomp.cpp,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /////////////////////////////////////////////////////////////// #include "precomp.h" /////////////////////////////////////////////////////////////// --- NEW FILE: filter.cpp --- /* * $Id: filter.cpp,v 1.1 2008/11/27 16:38:05 vfrolov Exp $ * * Copyright (c) 2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: filter.cpp,v $ * Revision 1.1 2008/11/27 16:38:05 vfrolov * Initial revision * */ #include "precomp.h" #include "../plugins_api.h" /////////////////////////////////////////////////////////////// namespace FilterTag { /////////////////////////////////////////////////////////////// static ROUTINE_MSG_REPLACE_BUF *pMsgReplaceBuf; /////////////////////////////////////////////////////////////// #ifndef _DEBUG #define DEBUG_PARAM(par) #else /* _DEBUG */ #define DEBUG_PARAM(par) par #endif /* _DEBUG */ /////////////////////////////////////////////////////////////// static const char *GetParam(const char *pArg, const char *pPattern) { size_t lenPattern = strlen(pPattern); if (_strnicmp(pArg, pPattern, lenPattern) != 0) return NULL; return pArg + lenPattern; } /////////////////////////////////////////////////////////////// static BOOL StrToInt(const char *pStr, int *pNum) { BOOL res = FALSE; int num; int sign = 1; switch (*pStr) { case '-': sign = -1; case '+': pStr++; break; } for (num = 0 ;; pStr++) { switch (*pStr) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': num = num*10 + (*pStr - '0'); res = TRUE; continue; case 0: break; default: res = FALSE; } break; } if (pNum) *pNum = num*sign; return res; } /////////////////////////////////////////////////////////////// class Valid { public: Valid() : isValid(TRUE) {} void Invalidate() { isValid = FALSE; } BOOL IsValid() const { return isValid; } private: BOOL isValid; }; /////////////////////////////////////////////////////////////// class Filter : public Valid { public: Filter(int argc, const char *const argv[]); int inTag; int outTag; enum OutTagState {No, My, Alien} outTagState; }; Filter::Filter(int argc, const char *const argv[]) : inTag(-1), outTag(-1), outTagState(No) { for (const char *const *pArgs = &argv[1] ; argc > 1 ; pArgs++, argc--) { const char *pArg = GetParam(*pArgs, "--"); if (!pArg) { cerr << "Unknown option " << *pArgs << endl; Invalidate(); continue; } const char *pParam; if ((pParam = GetParam(pArg, "tag=")) != NULL) { int tag; if (!StrToInt(pParam, &tag) || tag < 0 || tag > 254) { cerr << "Invalid tag in " << pParam << endl; Invalidate(); continue; } inTag = outTag = tag; } else { cerr << "Unknown option " << pArg << endl; Invalidate(); } } if (inTag < 0) { cerr << "IN tag was not set" << endl; Invalidate(); } if (outTag < 0) { cerr << "OUT tag was not set" << endl; Invalidate(); } } /////////////////////////////////////////////////////////////// static PLUGIN_TYPE CALLBACK GetPluginType() { return PLUGIN_TYPE_FILTER; } /////////////////////////////////////////////////////////////// static const PLUGIN_ABOUT_A about = { sizeof(PLUGIN_ABOUT_A), "tag", "Copyright (c) 2008 Vyacheslav Frolov", "GNU General Public License", "Tag filter", }; static const PLUGIN_ABOUT_A * CALLBACK GetPluginAbout() { return &about; } /////////////////////////////////////////////////////////////// static void CALLBACK Help(const char *pProgPath) { cerr << "Usage:" << endl << " " << pProgPath << " ... --create-filter=" << GetPluginAbout()->pName << "[,<FID>][:<options>] ... --add-filters=<ports>:[...,]<FID>[,...] ..." << endl << endl << "Options:" << endl << " --tag=<tag> - set IN and OUT tags to <tag> (number from 0 to 254)." << endl << endl << "IN method input data stream description:" << endl << " LINE_DATA - raw data." << endl << endl << "IN method output data stream description:" << endl << " LINE_DATA - tagged by IN tag data." << endl << endl << "OUT method input data stream description:" << endl << " LINE_DATA - tagged data (tagged by not OUT tag data will be discarded)." << endl << endl << "OUT method output data stream description:" << endl << " LINE_DATA - raw data (untagged tagged by OUT tag data)." << endl << endl << "Examples:" << endl ; } /////////////////////////////////////////////////////////////// static HFILTER CALLBACK Create( HCONFIG /*hConfig*/, int argc, const char *const argv[]) { Filter *pFilter = new Filter(argc, argv); if (!pFilter) return NULL; if (!pFilter->IsValid()) { delete pFilter; return NULL; } return (HFILTER)pFilter; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK InMethod( HFILTER hFilter, HMASTERPORT hFromPort, HUB_MSG *pInMsg, HUB_MSG **DEBUG_PARAM(ppEchoMsg)) { _ASSERTE(hFilter != NULL); _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); _ASSERTE(*ppEchoMsg == NULL); switch (pInMsg->type) { case HUB_MSG_TYPE_LINE_DATA: { _ASSERTE(pInMsg->u.buf.pBuf != NULL || pInMsg->u.buf.size == 0); DWORD len = pInMsg->u.buf.size; if (len == 0) break; BYTE tag = (BYTE)((Filter *)hFilter)->inTag; basic_string<BYTE> line_data; for (const BYTE *pBuf = pInMsg->u.buf.pBuf ; len ; len--) { line_data.append(&tag, 1); line_data.append(pBuf++, 1); } if (!pMsgReplaceBuf(pInMsg, HUB_MSG_TYPE_LINE_DATA, line_data.data(), (DWORD)line_data.size())) return FALSE; break; } } return TRUE; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK OutMethod( HFILTER hFilter, HMASTERPORT DEBUG_PARAM(hFromPort), HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(hFromPort != NULL); _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); switch (pOutMsg->type) { case HUB_MSG_TYPE_LINE_DATA: { _ASSERTE(pOutMsg->u.buf.pBuf != NULL || pOutMsg->u.buf.size == 0); DWORD len = pOutMsg->u.buf.size; if (len == 0) break; BYTE tag = (BYTE)((Filter *)hFilter)->outTag; Filter::OutTagState tagState = ((Filter *)hFilter)->outTagState; basic_string<BYTE> line_data; for (const BYTE *pBuf = pOutMsg->u.buf.pBuf ; len ; len--) { BYTE ch = *pBuf++; switch (tagState) { case Filter::No: tagState = (ch == tag ? Filter::My : Filter::Alien); break; case Filter::My: line_data.append(&ch, 1); case Filter::Alien: tagState = Filter::No; break; } } ((Filter *)hFilter)->outTagState = tagState; if (!pMsgReplaceBuf(pOutMsg, HUB_MSG_TYPE_LINE_DATA, line_data.data(), (DWORD)line_data.size())) return FALSE; break; } } return pOutMsg != NULL; } /////////////////////////////////////////////////////////////// static const FILTER_ROUTINES_A routines = { sizeof(FILTER_ROUTINES_A), GetPluginType, GetPluginAbout, Help, NULL, // ConfigStart NULL, // Config NULL, // ConfigStop Create, NULL, // Init InMethod, OutMethod, }; static const PLUGIN_ROUTINES_A *const plugins[] = { (const PLUGIN_ROUTINES_A *)&routines, NULL }; /////////////////////////////////////////////////////////////// PLUGIN_INIT_A InitA; const PLUGIN_ROUTINES_A *const * CALLBACK InitA( const HUB_ROUTINES_A * pHubRoutines) { if (!ROUTINE_IS_VALID(pHubRoutines, pMsgReplaceBuf)) return NULL; pMsgReplaceBuf = pHubRoutines->pMsgReplaceBuf; return plugins; } /////////////////////////////////////////////////////////////// } // end namespace /////////////////////////////////////////////////////////////// |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:35:23
|
Update of /cvsroot/com0com/hub4com/plugins/connector In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16478/connector Log Message: Directory /cvsroot/com0com/hub4com/plugins/connector added to the repository |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:35:23
|
Update of /cvsroot/com0com/hub4com/plugins/tag In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16478/tag Log Message: Directory /cvsroot/com0com/hub4com/plugins/tag added to the repository |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:25:15
|
Update of /cvsroot/com0com/hub4com/plugins/serial In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15436 Modified Files: comport.cpp comport.h import.h port.cpp Log Message: Improved write buffering Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** comport.cpp 27 Nov 2008 13:44:52 -0000 1.18 --- comport.cpp 27 Nov 2008 16:25:08 -0000 1.19 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.19 2008/11/27 16:25:08 vfrolov + * Improved write buffering + * * Revision 1.18 2008/11/27 13:44:52 vfrolov * Added --write-limit option *************** *** 117,124 **** --- 120,130 ---- const char *pPath) : hMasterPort(NULL), + countWriteOverlapped(0), countReadOverlapped(0), countWaitCommEventOverlapped(0), countXoff(0), filterX(FALSE), + pWriteBuf(NULL), + lenWriteBuf(0), intercepted_options(0), inOptions(0), *************** *** 505,526 **** } ! WriteOverlapped *pOverlapped; ! pOverlapped = new WriteOverlapped(*pComIo, pBuf, len); ! if (!pOverlapped) { ! writeLost += len; ! return FALSE; } ! pMsg->type = HUB_MSG_TYPE_EMPTY; ! if (writeQueued > writeQueueLimit) ! pComIo->PurgeWrite(); ! if (!pOverlapped->StartWrite()) { ! writeLost += len; ! delete pOverlapped; ! return FALSE; } --- 511,555 ---- } ! if (writeQueued > writeQueueLimit) { ! pComIo->PurgeWrite(); ! if (lenWriteBuf) { ! _ASSERTE(pWriteBuf != NULL); ! writeLost += lenWriteBuf; ! writeQueued -= lenWriteBuf; ! lenWriteBuf = 0; ! pBufFree(pWriteBuf); ! pWriteBuf = NULL; ! } } ! if (countWriteOverlapped < 3) { ! _ASSERTE(pWriteBuf == NULL); ! _ASSERTE(lenWriteBuf == 0); ! WriteOverlapped *pOverlapped; ! pOverlapped = new WriteOverlapped(*pComIo, pBuf, len); ! ! if (!pOverlapped) { ! writeLost += len; ! return FALSE; ! } ! ! pMsg->type = HUB_MSG_TYPE_EMPTY; ! ! if (!pOverlapped->StartWrite()) { ! writeLost += len; ! delete pOverlapped; ! return FALSE; ! } ! ! countWriteOverlapped++; ! } else { ! _ASSERTE((pWriteBuf == NULL && lenWriteBuf == 0) || (pWriteBuf != NULL && lenWriteBuf != 0)); ! ! pBufAppend(&pWriteBuf, lenWriteBuf, pBuf, len); ! lenWriteBuf += len; } *************** *** 733,736 **** --- 762,766 ---- //cout << name << " OnWrite " << ::GetCurrentThreadId() << " len=" << len << " done=" << done << " queued=" << writeQueued << endl; + countWriteOverlapped--; delete pOverlapped; *************** *** 740,743 **** --- 770,799 ---- writeQueued -= len; + _ASSERTE(pComIo != NULL); + + if (lenWriteBuf) { + _ASSERTE(pWriteBuf != NULL); + + pOverlapped = new WriteOverlapped(*pComIo, pWriteBuf, lenWriteBuf); + + if (pOverlapped) { + if (pOverlapped->StartWrite()) { + countWriteOverlapped++; + } else { + delete pOverlapped; + + writeLost += lenWriteBuf; + writeQueued -= lenWriteBuf; + } + } else { + writeLost += lenWriteBuf; + writeQueued -= lenWriteBuf; + pBufFree(pWriteBuf); + } + + lenWriteBuf = 0; + pWriteBuf = NULL; + } + if (writeQueued <= writeQueueLimitSendXon && writeSuspended) { writeSuspended = FALSE; Index: import.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/import.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** import.h 24 Nov 2008 16:30:56 -0000 1.5 --- import.h 27 Nov 2008 16:25:08 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2008/11/27 16:25:08 vfrolov + * Improved write buffering + * * Revision 1.5 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 43,46 **** --- 46,50 ---- extern ROUTINE_BUF_ALLOC *pBufAlloc; extern ROUTINE_BUF_FREE *pBufFree; + extern ROUTINE_BUF_APPEND *pBufAppend; extern ROUTINE_MSG_INSERT_NONE *pMsgInsertNone; extern ROUTINE_ON_READ *pOnRead; Index: port.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/port.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** port.cpp 27 Nov 2008 13:44:52 -0000 1.12 --- port.cpp 27 Nov 2008 16:25:08 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/11/27 16:25:08 vfrolov + * Improved write buffering + * * Revision 1.12 2008/11/27 13:44:52 vfrolov * Added --write-limit option *************** *** 373,376 **** --- 376,380 ---- ROUTINE_BUF_ALLOC *pBufAlloc; ROUTINE_BUF_FREE *pBufFree; + ROUTINE_BUF_APPEND *pBufAppend; ROUTINE_MSG_INSERT_NONE *pMsgInsertNone; ROUTINE_ON_READ *pOnRead; *************** *** 382,385 **** --- 386,390 ---- if (!ROUTINE_IS_VALID(pHubRoutines, pBufAlloc) || !ROUTINE_IS_VALID(pHubRoutines, pBufFree) || + !ROUTINE_IS_VALID(pHubRoutines, pBufAppend) || !ROUTINE_IS_VALID(pHubRoutines, pMsgInsertNone) || !ROUTINE_IS_VALID(pHubRoutines, pOnRead)) *************** *** 390,393 **** --- 395,399 ---- pBufAlloc = pHubRoutines->pBufAlloc; pBufFree = pHubRoutines->pBufFree; + pBufAppend = pHubRoutines->pBufAppend; pMsgInsertNone = pHubRoutines->pMsgInsertNone; pOnRead = pHubRoutines->pOnRead; Index: comport.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** comport.h 24 Nov 2008 16:30:56 -0000 1.12 --- comport.h 27 Nov 2008 16:25:08 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/11/27 16:25:08 vfrolov + * Improved write buffering + * * Revision 1.12 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 119,122 **** --- 122,126 ---- string name; HMASTERPORT hMasterPort; + int countWriteOverlapped; int countReadOverlapped; int countWaitCommEventOverlapped; *************** *** 124,127 **** --- 128,134 ---- BOOL filterX; + BYTE *pWriteBuf; + DWORD lenWriteBuf; + DWORD intercepted_options; DWORD inOptions; |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:19:27
|
Update of /cvsroot/com0com/hub4com/plugins In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14769/plugins Modified Files: plugins_api.h Log Message: Added pBufAppend() Index: plugins_api.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/plugins_api.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** plugins_api.h 24 Nov 2008 16:30:56 -0000 1.19 --- plugins_api.h 27 Nov 2008 16:19:16 -0000 1.20 *************** *** 150,153 **** --- 150,158 ---- typedef VOID (CALLBACK ROUTINE_BUF_FREE)( BYTE *pBuf); + typedef VOID (CALLBACK ROUTINE_BUF_APPEND)( + BYTE **ppBuf, + DWORD offset, + const BYTE *pSrc, + DWORD sizeSrc); typedef BOOL (CALLBACK ROUTINE_MSG_REPLACE_BUF)( HUB_MSG *pMsg, *************** *** 186,189 **** --- 191,195 ---- ROUTINE_BUF_ALLOC *pBufAlloc; ROUTINE_BUF_FREE *pBufFree; + ROUTINE_BUF_APPEND *pBufAppend; ROUTINE_MSG_REPLACE_BUF *pMsgReplaceBuf; ROUTINE_MSG_INSERT_BUF *pMsgInsertBuf; |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 16:19:22
|
Update of /cvsroot/com0com/hub4com In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14769 Modified Files: export.cpp Log Message: Added pBufAppend() Index: export.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/export.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** export.cpp 24 Nov 2008 16:30:56 -0000 1.7 --- export.cpp 27 Nov 2008 16:19:16 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2008/11/27 16:19:16 vfrolov + * Added pBufAppend() + * * Revision 1.7 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 64,67 **** --- 67,75 ---- } /////////////////////////////////////////////////////////////// + static VOID CALLBACK buf_append(BYTE **ppBuf, DWORD offset, const BYTE *pSrc, DWORD sizeSrc) + { + BufAppend(ppBuf, offset, pSrc, sizeSrc); + } + /////////////////////////////////////////////////////////////// static BOOL CALLBACK msg_replace_buf(HUB_MSG *pMsg, WORD type, const BYTE *pSrc, DWORD sizeSrc) { *************** *** 223,226 **** --- 231,235 ---- buf_alloc, buf_free, + buf_append, msg_replace_buf, msg_insert_buf, |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 13:46:37
|
Update of /cvsroot/com0com/hub4com/plugins/tcp In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1400 Modified Files: comparams.cpp comparams.h comport.cpp port.cpp Log Message: Added --write-limit option Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comport.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** comport.cpp 24 Nov 2008 16:30:56 -0000 1.10 --- comport.cpp 27 Nov 2008 13:46:29 -0000 1.11 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.11 2008/11/27 13:46:29 vfrolov + * Added --write-limit option + * * Revision 1.10 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 133,137 **** countReadOverlapped(0), countXoff(0), ! writeQueueLimit(256), writeQueued(0), writeSuspended(FALSE), --- 136,140 ---- countReadOverlapped(0), countXoff(0), ! writeQueueLimit(comParams.WriteQueueLimit()), writeQueued(0), writeSuspended(FALSE), Index: comparams.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comparams.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comparams.h 6 Oct 2008 12:15:14 -0000 1.2 --- comparams.h 27 Nov 2008 13:46:29 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/11/27 13:46:29 vfrolov + * Added --write-limit option + * * Revision 1.2 2008/10/06 12:15:14 vfrolov * Added --reconnect option *************** *** 44,47 **** --- 47,56 ---- int GetReconnectTime() const { return reconnectTime; } + BOOL SetWriteQueueLimit(const char *pWriteQueueLimit); + static string WriteQueueLimitStr(long writeQueueLimit); + string WriteQueueLimitStr() const { return WriteQueueLimitStr(writeQueueLimit); } + static const char *WriteQueueLimitLst(); + long WriteQueueLimit() const { return writeQueueLimit; } + enum { rtDefault = -1, *************** *** 52,55 **** --- 61,65 ---- char *pIF; int reconnectTime; + long writeQueueLimit; }; /////////////////////////////////////////////////////////////// Index: port.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/port.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** port.cpp 24 Nov 2008 16:30:56 -0000 1.9 --- port.cpp 27 Nov 2008 13:46:29 -0000 1.10 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.10 2008/11/27 13:46:29 vfrolov + * Added --write-limit option + * * Revision 1.9 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 104,107 **** --- 107,113 ---- << " or n[o]. If sign * is not used then d[efault]" << endl << " means n[o] else d[efault] means 0." << endl + << " --write-limit=<s> - set write queue limit to <s> (" << ComParams().WriteQueueLimitStr() << " by default)," << endl + << " where <s> is " << ComParams::WriteQueueLimitLst() << ". The queue will be" << endl + << " purged with data lost on overruning." << endl << endl << "Output data stream description:" << endl *************** *** 179,187 **** } else { ! cerr << "Unknown reconnect value in " << pArg << endl; exit(1); } comParams.SetReconnectTime(reconnectTime); } else { return FALSE; --- 185,199 ---- } else { ! cerr << "Invalid reconnect value in " << pArg << endl; exit(1); } comParams.SetReconnectTime(reconnectTime); + } else + if ((pParam = GetParam(pArg, "--write-limit=")) != NULL) { + if (!comParams.SetWriteQueueLimit(pParam)) { + cerr << "Invalid write limit value in " << pArg << endl; + exit(1); + } } else { return FALSE; Index: comparams.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comparams.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** comparams.cpp 13 Nov 2008 07:41:09 -0000 1.3 --- comparams.cpp 27 Nov 2008 13:46:29 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2008/11/27 13:46:29 vfrolov + * Added --write-limit option + * * Revision 1.3 2008/11/13 07:41:09 vfrolov * Changed for staticaly linking *************** *** 39,43 **** ComParams::ComParams() : pIF(NULL), ! reconnectTime(rtDefault) { } --- 42,47 ---- ComParams::ComParams() : pIF(NULL), ! reconnectTime(rtDefault), ! writeQueueLimit(256) { } *************** *** 59,62 **** --- 63,92 ---- } /////////////////////////////////////////////////////////////// + BOOL ComParams::SetWriteQueueLimit(const char *pWriteQueueLimit) + { + if (isdigit(*pWriteQueueLimit)) { + writeQueueLimit = atol(pWriteQueueLimit); + return writeQueueLimit > 0; + } + + return FALSE; + } + + string ComParams::WriteQueueLimitStr(long writeQueueLimit) + { + if (writeQueueLimit > 0) { + stringstream buf; + buf << writeQueueLimit; + return buf.str(); + } + + return "?"; + } + + const char *ComParams::WriteQueueLimitLst() + { + return "a positive number"; + } + /////////////////////////////////////////////////////////////// } // end namespace /////////////////////////////////////////////////////////////// |
From: Vyacheslav F. <vf...@us...> - 2008-11-27 13:45:05
|
Update of /cvsroot/com0com/hub4com/plugins/serial In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1004 Modified Files: comparams.cpp comparams.h comport.cpp port.cpp Log Message: Added --write-limit option Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** comport.cpp 24 Nov 2008 16:30:56 -0000 1.17 --- comport.cpp 27 Nov 2008 13:44:52 -0000 1.18 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.18 2008/11/27 13:44:52 vfrolov + * Added --write-limit option + * * Revision 1.17 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 121,125 **** inOptions(0), outOptions(0), ! writeQueueLimit(256), writeQueued(0), writeSuspended(FALSE), --- 124,128 ---- inOptions(0), outOptions(0), ! writeQueueLimit(comParams.WriteQueueLimit()), writeQueued(0), writeSuspended(FALSE), *************** *** 728,732 **** void ComPort::OnWrite(WriteOverlapped *pOverlapped, DWORD len, DWORD done) { ! //cout << name << " OnWrite " << ::GetCurrentThreadId() << endl; delete pOverlapped; --- 731,735 ---- void ComPort::OnWrite(WriteOverlapped *pOverlapped, DWORD len, DWORD done) { ! //cout << name << " OnWrite " << ::GetCurrentThreadId() << " len=" << len << " done=" << done << " queued=" << writeQueued << endl; delete pOverlapped; Index: comparams.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comparams.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comparams.h 7 Apr 2008 12:28:03 -0000 1.2 --- comparams.h 27 Nov 2008 13:44:52 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/11/27 13:44:52 vfrolov + * Added --write-limit option + * * Revision 1.2 2008/04/07 12:28:03 vfrolov * Replaced --rt-events option by SET_RT_EVENTS message *************** *** 60,63 **** --- 63,67 ---- BOOL SetInDsr(const char *pInDsr) { return SetFlag(pInDsr, &inDsr); } BOOL SetIntervalTimeout(const char *pIntervalTimeout); + BOOL SetWriteQueueLimit(const char *pWriteQueueLimit); static string BaudRateStr(long baudRate); *************** *** 71,74 **** --- 75,79 ---- static string InDsrStr(int inDsr) { return FlagStr(inDsr); } static string IntervalTimeoutStr(long intervalTimeout); + static string WriteQueueLimitStr(long writeQueueLimit); string BaudRateStr() const { return BaudRateStr(baudRate); } *************** *** 82,85 **** --- 87,91 ---- string InDsrStr() const { return InDsrStr(inDsr); } string IntervalTimeoutStr() const { return IntervalTimeoutStr(intervalTimeout); } + string WriteQueueLimitStr() const { return WriteQueueLimitStr(writeQueueLimit); } static const char *BaudRateLst(); *************** *** 93,96 **** --- 99,103 ---- static const char *InDsrLst() { return FlagLst(); } static const char *IntervalTimeoutLst(); + static const char *WriteQueueLimitLst(); long BaudRate() const { return baudRate; } *************** *** 104,107 **** --- 111,115 ---- int InDsr() const { return inDsr; } long IntervalTimeout() const { return intervalTimeout; } + long WriteQueueLimit() const { return writeQueueLimit; } private: *************** *** 120,123 **** --- 128,132 ---- int inDsr; long intervalTimeout; + long writeQueueLimit; }; /////////////////////////////////////////////////////////////// Index: port.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/port.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** port.cpp 24 Nov 2008 16:30:56 -0000 1.11 --- port.cpp 27 Nov 2008 13:44:52 -0000 1.12 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.12 2008/11/27 13:44:52 vfrolov + * Added --write-limit option + * * Revision 1.11 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 128,131 **** --- 131,137 ---- << " --ito=<t> - set read interval timeout to <t> (" << ComParams().IntervalTimeoutStr() << " by default)," << endl << " where <t> is " << ComParams::IntervalTimeoutLst() << "." << endl + << " --write-limit=<s> - set write queue limit to <s> (" << ComParams().WriteQueueLimitStr() << " by default)," << endl + << " where <s> is " << ComParams::WriteQueueLimitLst() << ". The queue will be" << endl + << " purged with data lost on overruning." << endl << endl << " The value c[urrent] above means to use current COM port settings." << endl *************** *** 187,191 **** if ((pParam = GetParam(pArg, "--baud=")) != NULL) { if (!comParams.SetBaudRate(pParam)) { ! cerr << "Unknown baud rate value in " << pArg << endl; exit(1); } --- 193,197 ---- if ((pParam = GetParam(pArg, "--baud=")) != NULL) { if (!comParams.SetBaudRate(pParam)) { ! cerr << "Invalid baud rate value in " << pArg << endl; exit(1); } *************** *** 193,197 **** if ((pParam = GetParam(pArg, "--data=")) != NULL) { if (!comParams.SetByteSize(pParam)) { ! cerr << "Unknown data bits value in " << pArg << endl; exit(1); } --- 199,203 ---- if ((pParam = GetParam(pArg, "--data=")) != NULL) { if (!comParams.SetByteSize(pParam)) { ! cerr << "Invalid data bits value in " << pArg << endl; exit(1); } *************** *** 199,203 **** if ((pParam = GetParam(pArg, "--parity=")) != NULL) { if (!comParams.SetParity(pParam)) { ! cerr << "Unknown parity value in " << pArg << endl; exit(1); } --- 205,209 ---- if ((pParam = GetParam(pArg, "--parity=")) != NULL) { if (!comParams.SetParity(pParam)) { ! cerr << "Invalid parity value in " << pArg << endl; exit(1); } *************** *** 205,209 **** if ((pParam = GetParam(pArg, "--stop=")) != NULL) { if (!comParams.SetStopBits(pParam)) { ! cerr << "Unknown stop bits value in " << pArg << endl; exit(1); } --- 211,215 ---- if ((pParam = GetParam(pArg, "--stop=")) != NULL) { if (!comParams.SetStopBits(pParam)) { ! cerr << "Invalid stop bits value in " << pArg << endl; exit(1); } *************** *** 211,215 **** if ((pParam = GetParam(pArg, "--octs=")) != NULL) { if (!comParams.SetOutCts(pParam)) { ! cerr << "Unknown CTS handshaking on output value in " << pArg << endl; exit(1); } --- 217,221 ---- if ((pParam = GetParam(pArg, "--octs=")) != NULL) { if (!comParams.SetOutCts(pParam)) { ! cerr << "Invalid CTS handshaking on output value in " << pArg << endl; exit(1); } *************** *** 217,221 **** if ((pParam = GetParam(pArg, "--odsr=")) != NULL) { if (!comParams.SetOutDsr(pParam)) { ! cerr << "Unknown DSR handshaking on output value in " << pArg << endl; exit(1); } --- 223,227 ---- if ((pParam = GetParam(pArg, "--odsr=")) != NULL) { if (!comParams.SetOutDsr(pParam)) { ! cerr << "Invalid DSR handshaking on output value in " << pArg << endl; exit(1); } *************** *** 223,227 **** if ((pParam = GetParam(pArg, "--ox=")) != NULL) { if (!comParams.SetOutX(pParam)) { ! cerr << "Unknown XON/XOFF handshaking on output value in " << pArg << endl; exit(1); } --- 229,233 ---- if ((pParam = GetParam(pArg, "--ox=")) != NULL) { if (!comParams.SetOutX(pParam)) { ! cerr << "Invalid XON/XOFF handshaking on output value in " << pArg << endl; exit(1); } *************** *** 229,233 **** if ((pParam = GetParam(pArg, "--ix=")) != NULL) { if (!comParams.SetInX(pParam)) { ! cerr << "Unknown XON/XOFF handshaking on input value in " << pArg << endl; exit(1); } --- 235,239 ---- if ((pParam = GetParam(pArg, "--ix=")) != NULL) { if (!comParams.SetInX(pParam)) { ! cerr << "Invalid XON/XOFF handshaking on input value in " << pArg << endl; exit(1); } *************** *** 235,239 **** if ((pParam = GetParam(pArg, "--idsr=")) != NULL) { if (!comParams.SetInDsr(pParam)) { ! cerr << "Unknown DSR sensitivity value in " << pArg << endl; exit(1); } --- 241,245 ---- if ((pParam = GetParam(pArg, "--idsr=")) != NULL) { if (!comParams.SetInDsr(pParam)) { ! cerr << "Invalid DSR sensitivity value in " << pArg << endl; exit(1); } *************** *** 241,245 **** if ((pParam = GetParam(pArg, "--ito=")) != NULL) { if (!comParams.SetIntervalTimeout(pParam)) { ! cerr << "Unknown read interval timeout value in " << pArg << endl; exit(1); } --- 247,257 ---- if ((pParam = GetParam(pArg, "--ito=")) != NULL) { if (!comParams.SetIntervalTimeout(pParam)) { ! cerr << "Invalid read interval timeout value in " << pArg << endl; ! exit(1); ! } ! } else ! if ((pParam = GetParam(pArg, "--write-limit=")) != NULL) { ! if (!comParams.SetWriteQueueLimit(pParam)) { ! cerr << "Invalid write limit value in " << pArg << endl; exit(1); } Index: comparams.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comparams.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** comparams.cpp 13 Nov 2008 07:35:10 -0000 1.5 --- comparams.cpp 27 Nov 2008 13:44:52 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2008/11/27 13:44:52 vfrolov + * Added --write-limit option + * * Revision 1.5 2008/11/13 07:35:10 vfrolov * Changed for staticaly linking *************** *** 66,70 **** inX(0), inDsr(0), ! intervalTimeout(0) { } --- 69,74 ---- inX(0), inDsr(0), ! intervalTimeout(0), ! writeQueueLimit(256) { } *************** *** 140,143 **** --- 144,157 ---- } + BOOL ComParams::SetWriteQueueLimit(const char *pWriteQueueLimit) + { + if (isdigit(*pWriteQueueLimit)) { + writeQueueLimit = atol(pWriteQueueLimit); + return writeQueueLimit > 0; + } + + return FALSE; + } + BOOL ComParams::SetFlag(const char *pFlagStr, int *pFlag) { *************** *** 216,219 **** --- 230,244 ---- } + string ComParams::WriteQueueLimitStr(long writeQueueLimit) + { + if (writeQueueLimit > 0) { + stringstream buf; + buf << writeQueueLimit; + return buf.str(); + } + + return "?"; + } + string ComParams::FlagStr(int flag) { *************** *** 251,254 **** --- 276,284 ---- } + const char *ComParams::WriteQueueLimitLst() + { + return "a positive number"; + } + const char *ComParams::FlagLst() { |
From: Vyacheslav F. <vf...@us...> - 2008-11-26 15:55:29
|
Update of /cvsroot/com0com/hub4com In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15249 Modified Files: comhub.h hub4com.cpp Log Message: Changed port number to unsigned Index: hub4com.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/hub4com.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** hub4com.cpp 24 Nov 2008 12:36:59 -0000 1.18 --- hub4com.cpp 26 Nov 2008 15:55:24 -0000 1.19 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.19 2008/11/26 15:55:24 vfrolov + * Changed port number to unsigned + * * Revision 1.18 2008/11/24 12:36:59 vfrolov * Changed plugin API *************** *** 202,213 **** if (_stricmp(p, "All") == 0) { ! for (i = 0 ; i < hub.NumPorts() ; i++) { if (!pFunc(hub, hub.GetPort(i), p0, p1, p2)) res = FALSE; } ! } else if (StrToInt(p, &i) && i >= 0 && i < hub.NumPorts()) { if (!pFunc(hub, hub.GetPort(i), p0, p1, p2)) res = FALSE; ! } else { cerr << "Invalid port " << p << endl; res = FALSE; --- 205,219 ---- if (_stricmp(p, "All") == 0) { ! for (i = 0 ; (unsigned)i < hub.NumPorts() ; i++) { if (!pFunc(hub, hub.GetPort(i), p0, p1, p2)) res = FALSE; } ! } ! else ! if (StrToInt(p, &i) && i >= 0 && (unsigned)i < hub.NumPorts()) { if (!pFunc(hub, hub.GetPort(i), p0, p1, p2)) res = FALSE; ! } ! else { cerr << "Invalid port " << p << endl; res = FALSE; *************** *** 373,377 **** } break; ! } else if (StrToInt(p, &i) && i >= 0 && i < hub.NumPorts()) { if (!pSrcPorts) { pSrcPorts = new SetOfPorts; --- 379,385 ---- } break; ! } ! else ! if (StrToInt(p, &i) && i >= 0 && (unsigned)i < hub.NumPorts()) { if (!pSrcPorts) { pSrcPorts = new SetOfPorts; *************** *** 384,388 **** pSrcPorts->insert(hub.GetPort(i)); ! } else { cerr << "Invalid port " << p << endl; exit(1); --- 392,397 ---- pSrcPorts->insert(hub.GetPort(i)); ! } ! else { cerr << "Invalid port " << p << endl; exit(1); Index: comhub.h =================================================================== RCS file: /cvsroot/com0com/hub4com/comhub.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** comhub.h 24 Nov 2008 16:30:56 -0000 1.10 --- comhub.h 26 Nov 2008 15:55:24 -0000 1.11 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.11 2008/11/26 15:55:24 vfrolov + * Changed port number to unsigned + * * Revision 1.10 2008/11/24 16:30:56 vfrolov * Removed pOnXoffXon *************** *** 94,98 **** void SetFlowControlRoute(const PortMap &map) { routeFlowControlMap = map; } void RouteReport() const; ! int NumPorts() const { return (int)ports.size(); } Filters *SetFilters(Filters *_pFilters) { --- 97,101 ---- void SetFlowControlRoute(const PortMap &map) { routeFlowControlMap = map; } void RouteReport() const; ! unsigned NumPorts() const { return (unsigned)ports.size(); } Filters *SetFilters(Filters *_pFilters) { *************** *** 102,107 **** } ! Port *ComHub::GetPort(int n) const { ! _ASSERTE(n >= 0 && n < NumPorts()); return ports.at(n); } --- 105,110 ---- } ! Port *ComHub::GetPort(unsigned n) const { ! _ASSERTE(n < NumPorts()); return ports.at(n); } |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:52
|
Update of /cvsroot/com0com/hub4com/plugins/escparse In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/escparse Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/escparse/filter.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.7 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.7 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 475,478 **** --- 478,482 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/awakseq In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/awakseq Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/awakseq/filter.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** filter.cpp 24 Nov 2008 12:36:59 -0000 1.9 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.10 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.10 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.9 2008/11/24 12:36:59 vfrolov * Changed plugin API *************** *** 214,217 **** --- 217,221 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); *************** *** 309,317 **** static BOOL CALLBACK OutMethod( HFILTER hFilter, ! HMASTERPORT /*nFromPort*/, HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pOutMsg != NULL); --- 313,323 ---- static BOOL CALLBACK OutMethod( HFILTER hFilter, ! HMASTERPORT DEBUG_PARAM(hFromPort), HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); + _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/pinmap In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/pinmap Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/pinmap/filter.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.12 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.12 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 409,412 **** --- 412,417 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); + _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/linectl In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/linectl Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/linectl/filter.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.7 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.7 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 233,236 **** --- 236,241 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); + _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/pin2con In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/pin2con Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/pin2con/filter.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.12 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.12 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 287,290 **** --- 290,294 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/trace In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/trace Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/trace/filter.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.10 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.11 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.11 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.10 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 708,711 **** --- 711,715 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); *************** *** 732,735 **** --- 736,741 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); + _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/telnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/telnet Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/telnet/filter.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** filter.cpp 24 Nov 2008 16:39:58 -0000 1.8 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.9 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.9 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.8 2008/11/24 16:39:58 vfrolov * Implemented FLOWCONTROL-SUSPEND and FLOWCONTROL-RESUME commands (RFC 2217) *************** *** 59,62 **** --- 62,71 ---- static ROUTINE_FILTER_NAME_A *pFilterName; /////////////////////////////////////////////////////////////// + #ifndef _DEBUG + #define DEBUG_PARAM(par) + #else /* _DEBUG */ + #define DEBUG_PARAM(par) par + #endif /* _DEBUG */ + /////////////////////////////////////////////////////////////// const char *GetParam(const char *pArg, const char *pPattern) { *************** *** 359,362 **** --- 368,372 ---- << "IN method output data stream description:" << endl << " LINE_DATA - raw data." << endl + << " ADD_XOFF_XON - flow control." << endl << " " << endl << " Notifications about events on the server side (RFC 2217 client mode):" << endl *************** *** 379,382 **** --- 389,393 ---- << "OUT method input data stream description:" << endl << " LINE_DATA - raw data." << endl + << " ADD_XOFF_XON - flow control." << endl << " " << endl << " RFC 2217 client mode:" << endl *************** *** 446,449 **** --- 457,461 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); *************** *** 563,571 **** static BOOL CALLBACK OutMethod( HFILTER hFilter, ! HMASTERPORT /*nFromPort*/, HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pOutMsg != NULL); --- 575,585 ---- static BOOL CALLBACK OutMethod( HFILTER hFilter, ! HMASTERPORT DEBUG_PARAM(hFromPort), HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); + _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/lsrmap In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/lsrmap Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/lsrmap/filter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.3 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.3 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 159,162 **** --- 162,167 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); + _ASSERTE(hToPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/echo In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/echo Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/echo/filter.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** filter.cpp 24 Nov 2008 12:36:59 -0000 1.4 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.4 2008/11/24 12:36:59 vfrolov * Changed plugin API *************** *** 103,111 **** static BOOL CALLBACK InMethod( HFILTER DEBUG_PARAM(hFilter), ! HMASTERPORT /*nFromPort*/, HUB_MSG *pInMsg, HUB_MSG **ppEchoMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); --- 106,115 ---- static BOOL CALLBACK InMethod( HFILTER DEBUG_PARAM(hFilter), ! HMASTERPORT DEBUG_PARAM(hFromPort), HUB_MSG *pInMsg, HUB_MSG **ppEchoMsg) { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-25 16:40:47
|
Update of /cvsroot/com0com/hub4com/plugins/escinsert In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18667/plugins/escinsert Modified Files: filter.cpp Log Message: Added assert for port handle Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/escinsert/filter.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.6 --- filter.cpp 25 Nov 2008 16:40:40 -0000 1.7 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.7 2008/11/25 16:40:40 vfrolov + * Added assert for port handle + * * Revision 1.6 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 50,53 **** --- 53,62 ---- static ROUTINE_MSG_REPLACE_NONE *pMsgReplaceNone; /////////////////////////////////////////////////////////////// + #ifndef _DEBUG + #define DEBUG_PARAM(par) + #else /* _DEBUG */ + #define DEBUG_PARAM(par) par + #endif /* _DEBUG */ + /////////////////////////////////////////////////////////////// const char *GetParam(const char *pArg, const char *pPattern) { *************** *** 265,268 **** --- 274,278 ---- { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); *************** *** 314,322 **** static BOOL CALLBACK OutMethod( HFILTER hFilter, ! HMASTERPORT /*nFromPort*/, HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pOutMsg != NULL); --- 324,333 ---- static BOOL CALLBACK OutMethod( HFILTER hFilter, ! HMASTERPORT DEBUG_PARAM(hFromPort), HMASTERPORT hToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); + _ASSERTE(hFromPort != NULL); _ASSERTE(pOutMsg != NULL); |
From: Vyacheslav F. <vf...@us...> - 2008-11-24 16:40:06
|
Update of /cvsroot/com0com/hub4com/plugins/telnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2546 Modified Files: filter.cpp opt_comport.cpp opt_comport.h Log Message: Implemented FLOWCONTROL-SUSPEND and FLOWCONTROL-RESUME commands (RFC 2217) Index: opt_comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/telnet/opt_comport.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** opt_comport.cpp 13 Nov 2008 07:44:12 -0000 1.2 --- opt_comport.cpp 24 Nov 2008 16:39:58 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/11/24 16:39:58 vfrolov + * Implemented FLOWCONTROL-SUSPEND and FLOWCONTROL-RESUME commands (RFC 2217) + * * Revision 1.2 2008/11/13 07:44:12 vfrolov * Changed for staticaly linking *************** *** 124,136 **** } /////////////////////////////////////////////////////////////// ! TelnetOptionComPort::TelnetOptionComPort(TelnetProtocol &_telnet, DWORD &_goMask, DWORD &_soMask) : TelnetOption(_telnet, 44 /*COM-PORT-OPTION*/), goMask(_goMask), ! soMask(_soMask) { } /////////////////////////////////////////////////////////////// TelnetOptionComPortClient::TelnetOptionComPortClient(TelnetProtocol &_telnet, DWORD &_goMask, DWORD &_soMask) ! : TelnetOptionComPort(_telnet, _goMask, _soMask) { } --- 127,175 ---- } /////////////////////////////////////////////////////////////// ! TelnetOptionComPort::TelnetOptionComPort(TelnetProtocol &_telnet, BOOL _isClient, DWORD &_goMask, DWORD &_soMask) : TelnetOption(_telnet, 44 /*COM-PORT-OPTION*/), + isClient(_isClient), goMask(_goMask), ! soMask(_soMask), ! countXoff(0), ! suspended(FALSE) { } + + void TelnetOptionComPort::AddXoffXon(BOOL xoff) + { + if (xoff) { + if (countXoff++ == 0) { + BYTE_vector params; + + params.push_back((BYTE)(cpcFlowControlSuspend + (isClient ? 0 : cpcServerBase))); + SendSubNegotiation(params); + } + } else { + if (--countXoff == 0) { + BYTE_vector params; + + params.push_back((BYTE)(cpcFlowControlResume + (isClient ? 0 : cpcServerBase))); + SendSubNegotiation(params); + } + } + } + + void TelnetOptionComPort::OnSuspendResume(BOOL suspend, HUB_MSG **ppMsg) + { + if (suspended != suspend) { + suspended = suspend; + + *ppMsg = FlushDecodedStream(*ppMsg); + + if (!*ppMsg) + return; + + *ppMsg = pMsgInsertVal(*ppMsg, HUB_MSG_TYPE_ADD_XOFF_XON, suspended); + } + } /////////////////////////////////////////////////////////////// TelnetOptionComPortClient::TelnetOptionComPortClient(TelnetProtocol &_telnet, DWORD &_goMask, DWORD &_soMask) ! : TelnetOptionComPort(_telnet, TRUE, _goMask, _soMask) { } *************** *** 362,365 **** --- 401,418 ---- break; } + case cpcFlowControlSuspend + cpcServerBase: { + if (params.size() != (1 + 0)) + return FALSE; + + OnSuspendResume(TRUE, ppMsg); + break; + } + case cpcFlowControlResume + cpcServerBase: { + if (params.size() != (1 + 0)) + return FALSE; + + OnSuspendResume(FALSE, ppMsg); + break; + } default: return FALSE; *************** *** 370,374 **** /////////////////////////////////////////////////////////////// TelnetOptionComPortServer::TelnetOptionComPortServer(TelnetProtocol &_telnet, DWORD &_goMask, DWORD &_soMask) ! : TelnetOptionComPort(_telnet, _goMask, _soMask), br(0), brSend(FALSE), --- 423,427 ---- /////////////////////////////////////////////////////////////// TelnetOptionComPortServer::TelnetOptionComPortServer(TelnetProtocol &_telnet, DWORD &_goMask, DWORD &_soMask) ! : TelnetOptionComPort(_telnet, FALSE, _goMask, _soMask), br(0), brSend(FALSE), *************** *** 730,739 **** break; } ! case cpcFlowControlSuspend: ! return FALSE; break; ! case cpcFlowControlResume: ! return FALSE; break; case cpcSetLineStateMask: { if (params.size() != (1 + 1)) --- 783,800 ---- break; } ! case cpcFlowControlSuspend: { ! if (params.size() != (1 + 0)) ! return FALSE; ! ! OnSuspendResume(TRUE, ppMsg); break; ! } ! case cpcFlowControlResume: { ! if (params.size() != (1 + 0)) ! return FALSE; ! ! OnSuspendResume(FALSE, ppMsg); break; + } case cpcSetLineStateMask: { if (params.size() != (1 + 1)) Index: opt_comport.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/telnet/opt_comport.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** opt_comport.h 24 Oct 2008 06:51:23 -0000 1.1 --- opt_comport.h 24 Nov 2008 16:39:58 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/11/24 16:39:58 vfrolov + * Implemented FLOWCONTROL-SUSPEND and FLOWCONTROL-RESUME commands (RFC 2217) + * * Revision 1.1 2008/10/24 06:51:23 vfrolov * Initial revision *************** *** 34,38 **** { public: ! TelnetOptionComPort(TelnetProtocol &_telnet, DWORD &_goMask, DWORD &_soMask); virtual void SetBR(DWORD br) = 0; --- 37,43 ---- { public: ! TelnetOptionComPort(TelnetProtocol &_telnet, BOOL _isClient, DWORD &_goMask, DWORD &_soMask); ! ! void AddXoffXon(BOOL xoff); virtual void SetBR(DWORD br) = 0; *************** *** 46,51 **** --- 51,63 ---- protected: + void OnSuspendResume(BOOL suspend, HUB_MSG **ppMsg); + + BOOL isClient; + DWORD &goMask; DWORD &soMask; + + int countXoff; + BOOL suspended; }; /////////////////////////////////////////////////////////////// Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/telnet/filter.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** filter.cpp 24 Nov 2008 12:37:00 -0000 1.7 --- filter.cpp 24 Nov 2008 16:39:58 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2008/11/24 16:39:58 vfrolov + * Implemented FLOWCONTROL-SUSPEND and FLOWCONTROL-RESUME commands (RFC 2217) + * * Revision 1.7 2008/11/24 12:37:00 vfrolov * Changed plugin API *************** *** 725,728 **** --- 728,745 ---- break; } + case HUB_MSG_TYPE_ADD_XOFF_XON: { + State *pState = ((Filter *)hFilter)->GetState(hToPort); + + if (!pState) + return FALSE; + + if (pState->pComPort) { + pState->pComPort->AddXoffXon(pOutMsg->u.val); + _ASSERTE(pState->pTelnetProtocol != NULL); + pState->pTelnetProtocol->FlushEncodedStream(&pOutMsg); + } + + break; + } case HUB_MSG_TYPE_LINE_DATA: { _ASSERTE(pOutMsg->u.buf.pBuf != NULL || pOutMsg->u.buf.size == 0); |