com0com-cvs Mailing List for Null-modem emulator (Page 18)
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-09-30 08:33:02
|
Update of /cvsroot/com0com/hub4com/plugins/escinsert In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15183 Added Files: .cvsignore escinsert.vcproj filter.cpp precomp.cpp precomp.h Log Message: Initial revision --- NEW FILE: precomp.cpp --- /* * $Id: precomp.cpp,v 1.1 2008/09/30 08:32:38 vfrolov Exp $ * * Copyright (c) 2007-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 * */ /////////////////////////////////////////////////////////////// #include "precomp.h" /////////////////////////////////////////////////////////////// --- NEW FILE: precomp.h --- /* * $Id: precomp.h,v 1.1 2008/09/30 08:32:38 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/09/30 08:32:38 vfrolov * Initial revision * */ #ifndef _PRECOMP_H_ #define _PRECOMP_H_ #include <windows.h> #include <crtdbg.h> #include <map> #include <iostream> using namespace std; #pragma warning(disable:4512) // assignment operator could not be generated #endif /* _PRECOMP_H_ */ --- NEW FILE: escinsert.vcproj --- <?xml version="1.0" encoding="windows-1251"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="filter-escinsert" ProjectGUID="{4BFE1E9D-47D4-4172-A749-9AC2626C88F3}" 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: filter.cpp --- /* * $Id: filter.cpp,v 1.1 2008/09/30 08:32:38 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/09/30 08:32:38 vfrolov * Initial revision * */ #include "precomp.h" #include "../plugins_api.h" #include "../cncext.h" /////////////////////////////////////////////////////////////// static ROUTINE_MSG_INSERT_BUF *pMsgInsertBuf = NULL; static ROUTINE_MSG_REPLACE_BUF *pMsgReplaceBuf = NULL; static ROUTINE_PORT_NAME_A *pPortName = NULL; static ROUTINE_FILTER_NAME_A *pFilterName = NULL; /////////////////////////////////////////////////////////////// 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; } /////////////////////////////////////////////////////////////// class Valid { public: Valid() : isValid(TRUE) {} void Invalidate() { isValid = FALSE; } BOOL IsValid() const { return isValid; } private: BOOL isValid; }; /////////////////////////////////////////////////////////////// class State { public: State() : isConnected(FALSE), mstInVal(0), rbr(CBR_19200), rlc(VAL2LC_BYTESIZE(8)|VAL2LC_PARITY(NOPARITY)|VAL2LC_STOPBITS(ONESTOPBIT)) {} BOOL isConnected; BYTE mstInVal; ULONG rbr; DWORD rlc; }; /////////////////////////////////////////////////////////////// class Filter : public Valid { public: Filter(int argc, const char *const argv[]); void SetHub(HHUB _hHub) { hHub = _hHub; } State *GetState(int nPort); const char *PortName(int nPort) const { return pPortName(hHub, nPort); } const char *FilterName() const { return pFilterName(hHub, (HFILTER)this); } DWORD goInMask; BYTE escapeChar; private: HHUB hHub; typedef map<int, State*> PortsMap; typedef pair<int, State*> PortPair; PortsMap portsMap; }; Filter::Filter(int argc, const char *const argv[]) : goInMask(GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS|MODEM_STATUS_DSR|MODEM_STATUS_DCD|MODEM_STATUS_RI) | GO_V2O_LINE_STATUS(LINE_STATUS_OE|LINE_STATUS_PE|LINE_STATUS_FE|LINE_STATUS_BI|LINE_STATUS_FIFOERR) | GO_RBR_STATUS|GO_RLC_STATUS|GO_BREAK_STATUS), escapeChar(0xFF), hHub(NULL) { 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; } { cerr << "Unknown option --" << pArg << endl; Invalidate(); } } } State *Filter::GetState(int nPort) { PortsMap::iterator iPair = portsMap.find(nPort); if (iPair == portsMap.end()) { portsMap.insert(PortPair(nPort, NULL)); iPair = portsMap.find(nPort); if (iPair == portsMap.end()) return NULL; } if (!iPair->second) iPair->second = new State(); return iPair->second; } /////////////////////////////////////////////////////////////// static PLUGIN_TYPE CALLBACK GetPluginType() { return PLUGIN_TYPE_FILTER; } /////////////////////////////////////////////////////////////// static const PLUGIN_ABOUT_A about = { sizeof(PLUGIN_ABOUT_A), "escinsert", "Copyright (c) 2008 Vyacheslav Frolov", "GNU General Public License", "Escaped datastream generating 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 << endl << "Examples:" << endl << " " << pProgPath << " --load=,,_END_" << endl << " --create-filter=escparse" << endl << " --add-filters=0:escparse" << endl << " \\\\.\\CNCB0" << endl << " --create-filter=escinsert" << endl << " --add-filters=1:escinsert" << endl << " --use-driver=tcp" << endl << " 222.22.22.22:2222" << endl << " _END_" << endl << " - transfer data, signals, baudrate and line control info from serial port" << endl << " CNCB0 to TCP port 222.22.22.22:2222 via escaped datastream." << 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 Init( HFILTER hFilter, HHUB hHub) { _ASSERTE(hFilter != NULL); _ASSERTE(hHub != NULL); ((Filter *)hFilter)->SetHub(hHub); return TRUE; } /////////////////////////////////////////////////////////////// static void InsertStatus( Filter &filter, BYTE code, BYTE val, HUB_MSG **ppMsg) { BYTE insert[3]; insert[0] = filter.escapeChar; insert[1] = code; insert[2] = val; *ppMsg = pMsgInsertBuf(*ppMsg, HUB_MSG_TYPE_LINE_DATA, insert, sizeof(insert)); } /////////////////////////////////////////////////////////////// static void InsertRBR( Filter &filter, ULONG rbr, HUB_MSG **ppMsg) { BYTE insert[2 + sizeof(ULONG)]; insert[0] = filter.escapeChar; insert[1] = C0CE_INSERT_RBR; *(ULONG *)&insert[2] = rbr; *ppMsg = pMsgInsertBuf(*ppMsg, HUB_MSG_TYPE_LINE_DATA, insert, sizeof(insert)); } /////////////////////////////////////////////////////////////// static void InsertRLC( Filter &filter, DWORD rlc, HUB_MSG **ppMsg) { BYTE insert[2 + 3]; insert[0] = filter.escapeChar; insert[1] = C0CE_INSERT_RLC; insert[2] = LC2VAL_BYTESIZE(rlc); insert[3] = LC2VAL_PARITY(rlc); insert[4] = LC2VAL_STOPBITS(rlc); *ppMsg = pMsgInsertBuf(*ppMsg, HUB_MSG_TYPE_LINE_DATA, insert, sizeof(insert)); } /////////////////////////////////////////////////////////////// static BOOL CALLBACK InMethod( HFILTER hFilter, int nFromPort, HUB_MSG *pInMsg, HUB_MSG **ppEchoMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); _ASSERTE(*ppEchoMsg == NULL); switch (pInMsg->type) { case HUB_MSG_TYPE_CONNECT: { State *pState = ((Filter *)hFilter)->GetState(nFromPort); if (!pState) return FALSE; if (pInMsg->u.val) { pState->isConnected = TRUE; } else { pState->isConnected = FALSE; break; } // init state if (((Filter *)hFilter)->goInMask & GO_O2V_MODEM_STATUS(-1)) InsertStatus(*(Filter *)hFilter, SERIAL_LSRMST_MST, pState->mstInVal, ppEchoMsg); if (((Filter *)hFilter)->goInMask & (GO_V2O_LINE_STATUS(-1) | GO_BREAK_STATUS)) InsertStatus(*(Filter *)hFilter, SERIAL_LSRMST_LSR_NODATA, 0, ppEchoMsg); if (((Filter *)hFilter)->goInMask & GO_RBR_STATUS) InsertRBR(*(Filter *)hFilter, pState->rbr, ppEchoMsg); if (((Filter *)hFilter)->goInMask & GO_RLC_STATUS) InsertRLC(*(Filter *)hFilter, pState->rlc, ppEchoMsg); break; } } return pInMsg != NULL; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK OutMethod( HFILTER hFilter, int nFromPort, int nToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pOutMsg != NULL); switch (pOutMsg->type) { case HUB_MSG_TYPE_GET_IN_OPTS: { _ASSERTE(pOutMsg->u.pv.pVal != NULL); // or'e with the required mask to get line status and modem status *pOutMsg->u.pv.pVal |= (((Filter *)hFilter)->goInMask & pOutMsg->u.pv.val); break; } case HUB_MSG_TYPE_FAIL_IN_OPTS: { DWORD fail_options = (pOutMsg->u.val & ((Filter *)hFilter)->goInMask); if (fail_options) { cerr << ((Filter *)hFilter)->PortName(nFromPort) << " WARNING: Requested by filter " << ((Filter *)hFilter)->FilterName() << " option(s) 0x" << hex << fail_options << dec << " not accepted" << endl; } break; } case HUB_MSG_TYPE_RBR_STATUS: if (((Filter *)hFilter)->goInMask & GO_RBR_STATUS) { State *pState = ((Filter *)hFilter)->GetState(nToPort); if (!pState) return FALSE; if (pState->rbr != pOutMsg->u.val) { pState->rbr = pOutMsg->u.val; if (pState->isConnected) InsertRBR(*(Filter *)hFilter, pState->rbr, &pOutMsg); } } break; case HUB_MSG_TYPE_RLC_STATUS: _ASSERTE((pOutMsg->u.val & ~(VAL2LC_BYTESIZE(-1)|VAL2LC_PARITY(-1)|VAL2LC_STOPBITS(-1))) == 0); if (((Filter *)hFilter)->goInMask & GO_RLC_STATUS) { State *pState = ((Filter *)hFilter)->GetState(nToPort); if (!pState) return FALSE; if (pState->rlc != pOutMsg->u.val) { pState->rlc = pOutMsg->u.val; if (pState->isConnected) InsertRLC(*(Filter *)hFilter, pState->rlc, &pOutMsg); } } break; case HUB_MSG_TYPE_BREAK_STATUS: if (((Filter *)hFilter)->goInMask & GO_BREAK_STATUS) { State *pState = ((Filter *)hFilter)->GetState(nToPort); if (!pState) return FALSE; if (!pState->isConnected) break; if (pOutMsg->u.val) { if ((((Filter *)hFilter)->goInMask & GO_V2O_LINE_STATUS(LINE_STATUS_BI)) == 0) InsertStatus(*(Filter *)hFilter, SERIAL_LSRMST_LSR_NODATA, LINE_STATUS_BI, &pOutMsg); } else { InsertStatus(*(Filter *)hFilter, SERIAL_LSRMST_LSR_NODATA, 0, &pOutMsg); } } break; case HUB_MSG_TYPE_LINE_STATUS: { BYTE lsr; lsr = (BYTE)pOutMsg->u.val & (BYTE)MASK2VAL(pOutMsg->u.val) & GO_O2V_LINE_STATUS(((Filter *)hFilter)->goInMask); if (lsr) { State *pState = ((Filter *)hFilter)->GetState(nToPort); if (!pState) return FALSE; if (pState->isConnected) InsertStatus(*(Filter *)hFilter, SERIAL_LSRMST_LSR_NODATA, lsr, &pOutMsg); } break; } case HUB_MSG_TYPE_MODEM_STATUS: { BYTE mstInMask; mstInMask = (BYTE)MASK2VAL(pOutMsg->u.val) & GO_O2V_MODEM_STATUS(((Filter *)hFilter)->goInMask); if (mstInMask) { State *pState = ((Filter *)hFilter)->GetState(nToPort); if (!pState) return FALSE; BYTE mstInVal; mstInVal = (((BYTE)pOutMsg->u.val & mstInMask) | (pState->mstInVal & ~mstInMask)); mstInMask = pState->mstInVal ^ mstInVal; if (!mstInMask) break; if (pState->isConnected) InsertStatus(*(Filter *)hFilter, SERIAL_LSRMST_MST, mstInVal, &pOutMsg); pState->mstInVal = mstInVal; } break; } case HUB_MSG_TYPE_LINE_DATA: { // escape escape characters _ASSERTE(pOutMsg->u.buf.pBuf != NULL || pOutMsg->u.buf.size == 0); DWORD len = pOutMsg->u.buf.size; if (len == 0) return TRUE; basic_string<BYTE> line_data; const BYTE *pBuf = pOutMsg->u.buf.pBuf; BYTE escapeChar = ((Filter *)hFilter)->escapeChar; for (; len ; len--) { BYTE ch = *pBuf++; line_data.append(&ch, 1); if (ch == escapeChar) { BYTE escape = SERIAL_LSRMST_ESCAPE; line_data.append(&escape, 1); } } pOutMsg = pMsgReplaceBuf(pOutMsg, HUB_MSG_TYPE_LINE_DATA, line_data.data(), (DWORD)line_data.size()); break; } } return pOutMsg != NULL; } /////////////////////////////////////////////////////////////// static const FILTER_ROUTINES_A routines = { sizeof(FILTER_ROUTINES_A), GetPluginType, GetPluginAbout, Help, NULL, // ConfigStart NULL, // Config NULL, // ConfigStop Create, 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, pMsgInsertBuf) || !ROUTINE_IS_VALID(pHubRoutines, pMsgReplaceBuf) || !ROUTINE_IS_VALID(pHubRoutines, pPortName) || !ROUTINE_IS_VALID(pHubRoutines, pFilterName)) { return NULL; } pMsgInsertBuf = pHubRoutines->pMsgInsertBuf; pMsgReplaceBuf = pHubRoutines->pMsgReplaceBuf; pPortName = pHubRoutines->pPortName; pFilterName = pHubRoutines->pFilterName; return plugins; } /////////////////////////////////////////////////////////////// --- NEW FILE: .cvsignore --- *.user Release Debug |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 08:30:31
|
Update of /cvsroot/com0com/hub4com/plugins/linectl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14393/linectl Log Message: Directory /cvsroot/com0com/hub4com/plugins/linectl added to the repository |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 08:30:03
|
Update of /cvsroot/com0com/hub4com/plugins/escinsert In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14003/escinsert Log Message: Directory /cvsroot/com0com/hub4com/plugins/escinsert added to the repository |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 08:29:18
|
Update of /cvsroot/com0com/hub4com/plugins/serial In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13607/serial Modified Files: comio.cpp comio.h comport.cpp comport.h Log Message: Added ability to control OUT1 and OUT2 pins Added ability to get remote baud rate and line control settings Added ability to set baud rate and line control Added fallback to non escape mode Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** comport.cpp 29 Aug 2008 13:02:37 -0000 1.11 --- comport.cpp 30 Sep 2008 08:28:32 -0000 1.12 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.12 2008/09/30 08:28:32 vfrolov + * Added ability to control OUT1 and OUT2 pins + * Added ability to get remote baud rate and line control settings + * Added ability to set baud rate and line control + * Added fallback to non escape mode + * * Revision 1.11 2008/08/29 13:02:37 vfrolov * Added ESC_OPTS_MAP_EO2GO() and ESC_OPTS_MAP_GO2EO() *************** *** 95,117 **** countXoff(0), filterX(FALSE), - maskOutPins(0), - maskMst(0), intercepted_options(0), writeQueueLimit(256), writeQueued(0), writeLost(0), writeLostTotal(0), ! errors(0), ! _inOptions(0) { filterX = comParams.InX(); string path(pPath); name = path.substr(path.rfind('\\') + 1); ! handle = ::OpenComPort(pPath, comParams); } BOOL ComPort::Init(HMASTERPORT _hMasterPort, HHUB _hHub) { ! if (handle == INVALID_HANDLE_VALUE) { cerr << "ComPort::Init(): Invalid handle" << endl; return FALSE; --- 101,132 ---- countXoff(0), filterX(FALSE), intercepted_options(0), + inOptions(0), + outOptions(0), writeQueueLimit(256), writeQueued(0), writeLost(0), writeLostTotal(0), ! errors(0) { filterX = comParams.InX(); string path(pPath); name = path.substr(path.rfind('\\') + 1); ! pComIo = new ComIo(*this); ! ! if (!pComIo) { ! cerr << "No enough memory." << endl; ! exit(2); ! } ! ! if (!pComIo->Open(pPath, comParams)) { ! delete pComIo; ! pComIo = NULL; ! } } BOOL ComPort::Init(HMASTERPORT _hMasterPort, HHUB _hHub) { ! if (!pComIo) { cerr << "ComPort::Init(): Invalid handle" << endl; return FALSE; *************** *** 214,218 **** if (goOptions) { ! cerr << pHead << " WARNING: Requested option(s) [" << FieldToName(codeNameTableGoOptions, goOptions) << "] will be ignored by driver" << pTail << endl; --- 229,233 ---- if (goOptions) { ! cerr << pHead << " WARNING: Requested input option(s) [" << FieldToName(codeNameTableGoOptions, goOptions) << "] will be ignored by driver" << pTail << endl; *************** *** 220,224 **** if (otherOptions) { ! cerr << pHead << " WARNING: Requested option(s) [0x" << hex << otherOptions << dec << "] will be ignored by driver" << pTail << endl; --- 235,239 ---- if (otherOptions) { ! cerr << pHead << " WARNING: Requested input option(s) [0x" << hex << otherOptions << dec << "] will be ignored by driver" << pTail << endl; *************** *** 240,246 **** _ASSERTE(hMasterPort != NULL); _ASSERTE(hHub != NULL); ! _ASSERTE(handle != INVALID_HANDLE_VALUE); - DWORD events = 0; BYTE *pBuf = NULL; DWORD done = 0; --- 255,260 ---- _ASSERTE(hMasterPort != NULL); _ASSERTE(hHub != NULL); ! _ASSERTE(pComIo != NULL); BYTE *pBuf = NULL; DWORD done = 0; *************** *** 255,259 **** pOnRead(hHub, hMasterPort, &msg); ! escapeOptions = SetEscMode(handle, escapeOptions, &pBuf, &done); if (escapeOptions & ~ESC_OPTS_V2O_ESCCHAR(-1)) { --- 269,273 ---- pOnRead(hHub, hMasterPort, &msg); ! escapeOptions = pComIo->SetEscMode(escapeOptions, &pBuf, &done); if (escapeOptions & ~ESC_OPTS_V2O_ESCCHAR(-1)) { *************** *** 264,296 **** if ((escapeOptions & ESC_OPTS_V2O_ESCCHAR(-1)) == 0) { ! InOptionsAdd(GO_ESCAPE_MODE); msg.type = HUB_MSG_TYPE_FAIL_ESC_OPTS; ! msg.u.val = escapeOptions; pOnRead(hHub, hMasterPort, &msg); } } ! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS)) { ! events |= EV_CTS; ! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS)); ! } ! ! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)) { ! events |= EV_DSR; ! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)); ! } ! ! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_DCD)) { ! events |= EV_RLSD; ! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_DCD)); ! } ! ! if (intercepted_options & GO_V2O_MODEM_STATUS(MODEM_STATUS_RI)) { ! events |= EV_RING; ! InOptionsAdd(GO_V2O_MODEM_STATUS(MODEM_STATUS_RI)); ! } ! DWORD fail_options = (intercepted_options & ~InOptions()); if (fail_options) --- 278,299 ---- if ((escapeOptions & ESC_OPTS_V2O_ESCCHAR(-1)) == 0) { ! inOptions |= GO_ESCAPE_MODE; msg.type = HUB_MSG_TYPE_FAIL_ESC_OPTS; ! msg.u.pv.pVal = &intercepted_options; ! msg.u.pv.val = escapeOptions; pOnRead(hHub, hMasterPort, &msg); } } ! inOptions |= (intercepted_options & ( ! GO_RBR_STATUS | ! GO_RLC_STATUS | ! MODEM_STATUS_CTS | ! MODEM_STATUS_DSR | ! MODEM_STATUS_DCD | ! MODEM_STATUS_RI)); ! DWORD fail_options = (intercepted_options & ~inOptions); if (fail_options) *************** *** 301,306 **** pOnRead(hHub, hMasterPort, &msg); ! if (events) { ! if (!SetComEvents(handle, &events) || !StartWaitCommEvent()) { pBufFree(pBuf); return FALSE; --- 304,328 ---- pOnRead(hHub, hMasterPort, &msg); ! if (inOptions & GO_V2O_MODEM_STATUS( ! MODEM_STATUS_CTS | ! MODEM_STATUS_DSR | ! MODEM_STATUS_DCD | ! MODEM_STATUS_RI)) ! { ! DWORD events = 0; ! ! if (inOptions & GO_V2O_MODEM_STATUS(MODEM_STATUS_CTS)) ! events |= EV_CTS; ! ! if (inOptions & GO_V2O_MODEM_STATUS(MODEM_STATUS_DSR)) ! events |= EV_DSR; ! ! if (inOptions & GO_V2O_MODEM_STATUS(MODEM_STATUS_DCD)) ! events |= EV_RLSD; ! ! if (inOptions & GO_V2O_MODEM_STATUS(MODEM_STATUS_RI)) ! events |= EV_RING; ! ! if (!pComIo->SetComEvents(&events) || !StartWaitCommEvent()) { pBufFree(pBuf); return FALSE; *************** *** 321,324 **** --- 343,362 ---- pOnRead(hHub, hMasterPort, &msg); + if (inOptions & GO_RBR_STATUS) { + cerr << name << " WARNING: Suppose remote baud rate is equal local settings" << endl; + + msg.type = HUB_MSG_TYPE_RBR_STATUS; + msg.u.val = pComIo->GetBaudRate(); + pOnRead(hHub, hMasterPort, &msg); + } + + if (inOptions & GO_RLC_STATUS) { + cerr << name << " WARNING: Suppose remote byte size, parity and stop bits are equal local settings" << endl; + + msg.type = HUB_MSG_TYPE_RLC_STATUS; + msg.u.val = pComIo->GetLineControl(); + pOnRead(hHub, hMasterPort, &msg); + } + if (pBuf) { msg.type = HUB_MSG_TYPE_LINE_DATA; *************** *** 338,347 **** return TRUE; ! if (handle == INVALID_HANDLE_VALUE) return FALSE; ReadOverlapped *pOverlapped; ! pOverlapped = new ReadOverlapped(*this); if (!pOverlapped) --- 376,385 ---- return TRUE; ! if (!pComIo) return FALSE; ReadOverlapped *pOverlapped; ! pOverlapped = new ReadOverlapped(*pComIo); if (!pOverlapped) *************** *** 422,426 **** return TRUE; ! if (handle == INVALID_HANDLE_VALUE) { writeLost += len; return FALSE; --- 460,464 ---- return TRUE; ! if (!pComIo) { writeLost += len; return FALSE; *************** *** 429,433 **** WriteOverlapped *pOverlapped; ! pOverlapped = new WriteOverlapped(*this, pBuf, len); if (!pOverlapped) { --- 467,471 ---- WriteOverlapped *pOverlapped; ! pOverlapped = new WriteOverlapped(*pComIo, pBuf, len); if (!pOverlapped) { *************** *** 439,443 **** if (writeQueued > writeQueueLimit) ! ::PurgeComm(handle, PURGE_TXABORT|PURGE_TXCLEAR); if (!pOverlapped->StartWrite()) { --- 477,481 ---- if (writeQueued > writeQueueLimit) ! pComIo->PurgeWrite(); if (!pOverlapped->StartWrite()) { *************** *** 456,512 **** else if (pMsg->type == HUB_MSG_TYPE_SET_PIN_STATE) { ! if (handle == INVALID_HANDLE_VALUE) return FALSE; ! WORD mask = MASK2VAL(pMsg->u.val) & maskOutPins; ! if (mask & PIN_STATE_RTS) { ! if (!CommFunction(handle, (pMsg->u.val & PIN_STATE_RTS) ? SETRTS : CLRRTS)) ! cerr << name << " WARNING! can't change RTS state" << endl; ! } ! if (mask & PIN_STATE_DTR) { ! if (!CommFunction(handle, (pMsg->u.val & PIN_STATE_DTR) ? SETDTR : CLRDTR)) ! cerr << name << " WARNING! can't change DTR state" << endl; } ! if (mask & PIN_STATE_OUT1) { ! cerr << name << " WARNING! can't change OUT1 state" << endl; } ! if (mask & PIN_STATE_OUT2) { ! cerr << name << " WARNING! can't change OUT2 state" << endl; } ! if (mask & PIN_STATE_BREAK) { ! if (!CommFunction(handle, (pMsg->u.val & PIN_STATE_BREAK) ? SETBREAK : CLRBREAK)) ! cerr << name << " WARNING! can't change BREAK state" << endl; } } else if (pMsg->type == HUB_MSG_TYPE_SET_OUT_OPTS) { ! if (handle == INVALID_HANDLE_VALUE) return FALSE; ! WORD addedPins = (~maskOutPins & SO_O2V_PIN_STATE(pMsg->u.val)); ! if (addedPins & PIN_STATE_RTS) { ! if (!SetManualRtsControl(handle)) { ! addedPins &= ~PIN_STATE_RTS; ! cerr << name << " WARNING! can't set manual RTS state mode" << endl; ! } } ! if (addedPins & PIN_STATE_DTR) { ! if (!SetManualDtrControl(handle)) { ! addedPins &= ~PIN_STATE_DTR; ! cerr << name << " WARNING! can't set manual DTR state mode" << endl; ! } } ! if (addedPins & PIN_STATE_OUT1) { ! addedPins &= ~PIN_STATE_OUT1; ! cerr << name << " WARNING! can't set manual OUT1 state mode" << endl; } ! if (addedPins & PIN_STATE_OUT2) { ! addedPins &= ~PIN_STATE_OUT2; ! cerr << name << " WARNING! can't set manual OUT2 state mode" << endl; } ! maskOutPins |= addedPins; } --- 494,596 ---- else if (pMsg->type == HUB_MSG_TYPE_SET_PIN_STATE) { ! if (!pComIo) return FALSE; ! pComIo->SetPinState((WORD)pMsg->u.val, MASK2VAL(pMsg->u.val) & SO_O2V_PIN_STATE(outOptions)); ! } ! else ! if (pMsg->type == HUB_MSG_TYPE_SET_BR) { ! if (!pComIo) ! return FALSE; ! DWORD oldVal = pComIo->GetBaudRate(); ! DWORD curVal = pComIo->SetBaudRate(pMsg->u.val); ! ! if (curVal != pMsg->u.val) { ! cerr << name << " WARNING: can't change" ! << " baud rate " << oldVal ! << " to " << pMsg->u.val ! << " (current=" << curVal << ")" ! << endl; } ! ! if ((inOptions & GO_RBR_STATUS) && oldVal != curVal) { ! HUB_MSG msg; ! ! msg.type = HUB_MSG_TYPE_RBR_STATUS; ! msg.u.val = curVal; // suppose remote equal local ! pOnRead(hHub, hMasterPort, &msg); } ! } ! else ! if (pMsg->type == HUB_MSG_TYPE_SET_LC) { ! if (!pComIo) ! return FALSE; ! ! DWORD oldVal = pComIo->GetLineControl();; ! DWORD curVal = pComIo->SetLineControl(pMsg->u.val); ! ! if (curVal != pMsg->u.val) { ! cerr << name << " WARNING: can't change" ! << hex ! << " line control 0x" << oldVal ! << " to 0x" << pMsg->u.val ! << " (current=0x" << curVal << ")" ! << dec ! << endl; } ! ! if ((inOptions & GO_RLC_STATUS) && oldVal != curVal) { ! HUB_MSG msg; ! ! msg.type = HUB_MSG_TYPE_RLC_STATUS; ! msg.u.val = curVal; // suppose remote equal local ! pOnRead(hHub, hMasterPort, &msg); } } else if (pMsg->type == HUB_MSG_TYPE_SET_OUT_OPTS) { ! if (!pComIo) return FALSE; ! pMsg->u.val &= ~outOptions; ! if (pMsg->u.val & SO_V2O_PIN_STATE(PIN_STATE_RTS)) { ! if (pComIo->SetManualRtsControl()) ! outOptions |= SO_V2O_PIN_STATE(PIN_STATE_RTS); ! else ! cerr << name << " WARNING: can't set manual RTS state mode" << endl; } ! if (pMsg->u.val & SO_V2O_PIN_STATE(PIN_STATE_DTR)) { ! if (pComIo->SetManualDtrControl()) ! outOptions |= SO_V2O_PIN_STATE(PIN_STATE_DTR); ! else ! cerr << name << " WARNING: can't set manual DTR state mode" << endl; } ! if (pMsg->u.val & SO_V2O_PIN_STATE(PIN_STATE_OUT1)) { ! if (pComIo->SetManualOut1Control()) ! outOptions |= SO_V2O_PIN_STATE(PIN_STATE_OUT1); ! else ! cerr << name << " WARNING: can't set manual OUT1 state mode" << endl; } ! if (pMsg->u.val & SO_V2O_PIN_STATE(PIN_STATE_OUT2)) { ! if (pComIo->SetManualOut2Control()) ! outOptions |= SO_V2O_PIN_STATE(PIN_STATE_OUT2); ! else ! cerr << name << " WARNING: can't set manual OUT2 state mode" << endl; } ! outOptions |= ( ! SO_V2O_PIN_STATE(PIN_STATE_BREAK) | ! SO_SET_BR | ! SO_SET_LC); ! ! pMsg->u.val &= ~outOptions; ! ! if (pMsg->u.val) { ! cerr << name << " WARNING: Requested output option(s) [0x" ! << hex << pMsg->u.val << dec ! << "] will be ignored by driver" << endl; ! } } *************** *** 519,528 **** return TRUE; ! if (handle == INVALID_HANDLE_VALUE) return FALSE; WaitCommEventOverlapped *pOverlapped; ! pOverlapped = new WaitCommEventOverlapped(*this); if (!pOverlapped) --- 603,612 ---- return TRUE; ! if (!pComIo) return FALSE; WaitCommEventOverlapped *pOverlapped; ! pOverlapped = new WaitCommEventOverlapped(*pComIo); if (!pOverlapped) *************** *** 577,581 **** countReadOverlapped--; ! cout << name << " Stopped Read " << countReadOverlapped << endl; } } --- 661,666 ---- countReadOverlapped--; ! if (countXoff <= 0) ! cout << name << " Stopped Read " << countReadOverlapped << endl; } } *************** *** 603,614 **** void ComPort::CheckComEvents(DWORD eMask) { ! if (maskMst && (eMask & (EV_CTS|EV_DSR|EV_RLSD|EV_RING)) != 0) { DWORD stat; ! if (::GetCommModemStatus(handle, &stat)) { HUB_MSG msg; msg.type = HUB_MSG_TYPE_MODEM_STATUS; ! msg.u.val = ((DWORD)(BYTE)stat | VAL2MASK(maskMst)); pOnRead(hHub, hMasterPort, &msg); --- 688,699 ---- void ComPort::CheckComEvents(DWORD eMask) { ! if (GO_O2V_MODEM_STATUS(inOptions) && (eMask & (EV_CTS|EV_DSR|EV_RLSD|EV_RING)) != 0) { DWORD stat; ! if (::GetCommModemStatus(pComIo->Handle(), &stat)) { HUB_MSG msg; msg.type = HUB_MSG_TYPE_MODEM_STATUS; ! msg.u.val = ((DWORD)(BYTE)stat | VAL2MASK(GO_O2V_MODEM_STATUS(inOptions))); pOnRead(hHub, hMasterPort, &msg); *************** *** 619,623 **** DWORD errs; ! if (::ClearCommError(handle, &errs, NULL)) errors |= errs; } --- 704,708 ---- DWORD errs; ! if (::ClearCommError(pComIo->Handle(), &errs, NULL)) errors |= errs; } *************** *** 626,630 **** void ComPort::AddXoff(int count) { ! _ASSERTE(handle != INVALID_HANDLE_VALUE); countXoff += count; --- 711,715 ---- void ComPort::AddXoff(int count) { ! _ASSERTE(pComIo != NULL); countXoff += count; *************** *** 646,650 **** void ComPort::LostReport() { ! _ASSERTE(handle != INVALID_HANDLE_VALUE); if (writeLost) { --- 731,735 ---- void ComPort::LostReport() { ! _ASSERTE(pComIo != NULL); if (writeLost) { *************** *** 674,678 **** DWORD size; ! if (DeviceIoControl(handle, IOCTL_SERIAL_GET_STATS, NULL, 0, &stats, sizeof(stats), &size, NULL)) { cout << ", total" << " RXOVER=" << stats.BufferOverrunErrorCount --- 759,763 ---- DWORD size; ! if (DeviceIoControl(pComIo->Handle(), IOCTL_SERIAL_GET_STATS, NULL, 0, &stats, sizeof(stats), &size, NULL)) { cout << ", total" << " RXOVER=" << stats.BufferOverrunErrorCount Index: comport.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comport.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** comport.h 22 Aug 2008 16:57:12 -0000 1.8 --- comport.h 30 Sep 2008 08:28:32 -0000 1.9 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.9 2008/09/30 08:28:32 vfrolov + * Added ability to control OUT1 and OUT2 pins + * Added ability to get remote baud rate and line control settings + * Added ability to set baud rate and line control + * Added fallback to non escape mode + * * Revision 1.8 2008/08/22 16:57:12 vfrolov * Added *************** *** 77,80 **** --- 83,87 ---- class ReadOverlapped; class WaitCommEventOverlapped; + class ComIo; /////////////////////////////////////////////////////////////// class ComPort *************** *** 97,101 **** const string &Name() const { return name; } void Name(const char *pName) { name = pName; } - HANDLE Handle() const { return handle; } private: --- 104,107 ---- *************** *** 104,109 **** void CheckComEvents(DWORD eMask); string name; - HANDLE handle; HMASTERPORT hMasterPort; HHUB hHub; --- 110,115 ---- void CheckComEvents(DWORD eMask); + ComIo *pComIo; string name; HMASTERPORT hMasterPort; HHUB hHub; *************** *** 112,118 **** int countXoff; BOOL filterX; ! WORD maskOutPins; ! WORD maskMst; DWORD intercepted_options; DWORD writeQueueLimit; --- 118,125 ---- int countXoff; BOOL filterX; ! DWORD intercepted_options; + DWORD inOptions; + DWORD outOptions; DWORD writeQueueLimit; *************** *** 121,141 **** DWORD writeLostTotal; DWORD errors; - - private: - DWORD _inOptions; - - DWORD InOptions() const { - return _inOptions; - } - - void InOptionsDel(DWORD opts) { - _inOptions &= ~opts; - maskMst = GO_O2V_MODEM_STATUS(_inOptions); - } - - void InOptionsAdd(DWORD opts) { - _inOptions |= opts; - maskMst = GO_O2V_MODEM_STATUS(_inOptions); - } }; /////////////////////////////////////////////////////////////// --- 128,131 ---- Index: comio.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comio.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** comio.h 22 Aug 2008 16:57:12 -0000 1.6 --- comio.h 30 Sep 2008 08:28:32 -0000 1.7 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.7 2008/09/30 08:28:32 vfrolov + * Added ability to control OUT1 and OUT2 pins + * Added ability to get remote baud rate and line control settings + * Added ability to set baud rate and line control + * Added fallback to non escape mode + * * Revision 1.6 2008/08/22 16:57:12 vfrolov * Added *************** *** 63,81 **** #define _COMIO_H /////////////////////////////////////////////////////////////// class ComPort; class ComParams; /////////////////////////////////////////////////////////////// ! extern HANDLE OpenComPort(const char *pPath, const ComParams &comParams); ! extern BOOL SetManualRtsControl(HANDLE handle); ! extern BOOL SetManualDtrControl(HANDLE handle); ! extern BOOL SetComEvents(HANDLE handle, DWORD *events); ! extern BOOL CommFunction(HANDLE handle, DWORD func); ! extern DWORD SetEscMode(HANDLE handle, DWORD escOptions, BYTE **ppBuf, DWORD *pDone); /////////////////////////////////////////////////////////////// class ReadOverlapped : private OVERLAPPED { public: ! ReadOverlapped(ComPort &_port); ~ReadOverlapped(); BOOL StartRead(); --- 69,119 ---- #define _COMIO_H + #include "../plugins_api.h" + /////////////////////////////////////////////////////////////// class ComPort; class ComParams; /////////////////////////////////////////////////////////////// ! class ComIo ! { ! public: ! ComIo(ComPort &_port) : port(_port), handle(INVALID_HANDLE_VALUE) {} ! ~ComIo() { Close(); } ! ! BOOL Open(const char *pPath, const ComParams &comParams); ! void Close(); ! ! BOOL SetManualRtsControl(); ! BOOL SetManualDtrControl(); ! BOOL SetManualOut1Control() { return hasExtendedModemControl; } ! BOOL SetManualOut2Control() { return hasExtendedModemControl; } ! BOOL SetComEvents(DWORD *pEvents); ! void SetPinState(WORD value, WORD mask); ! DWORD SetBaudRate(DWORD baudRate); ! DWORD SetLineControl(DWORD lineControl); ! DWORD SetEscMode(DWORD escOptions, BYTE **ppBuf, DWORD *pDone); ! void PurgeWrite() { ::PurgeComm(handle, PURGE_TXABORT|PURGE_TXCLEAR); } ! ! HANDLE Handle() const { return handle; } ! DWORD GetBaudRate() const { return dcb.BaudRate; } ! DWORD GetLineControl() const { ! return (VAL2LC_BYTESIZE(dcb.ByteSize) ! |VAL2LC_PARITY(dcb.Parity) ! |VAL2LC_STOPBITS(dcb.StopBits)); ! } ! ! public: ! ComPort &port; ! ! private: ! HANDLE handle; ! BOOL hasExtendedModemControl; ! DCB dcb; ! }; /////////////////////////////////////////////////////////////// class ReadOverlapped : private OVERLAPPED { public: ! ReadOverlapped(ComIo &_comIo); ~ReadOverlapped(); BOOL StartRead(); *************** *** 87,91 **** LPOVERLAPPED pOverlapped); ! ComPort &port; BYTE *pBuf; }; --- 125,129 ---- LPOVERLAPPED pOverlapped); ! ComIo &comIo; BYTE *pBuf; }; *************** *** 94,98 **** { public: ! WriteOverlapped(ComPort &_port, BYTE *_pBuf, DWORD _len); ~WriteOverlapped(); BOOL StartWrite(); --- 132,136 ---- { public: ! WriteOverlapped(ComIo &_comIo, BYTE *_pBuf, DWORD _len); ~WriteOverlapped(); BOOL StartWrite(); *************** *** 104,108 **** LPOVERLAPPED pOverlapped); ! ComPort &port; BYTE *pBuf; DWORD len; --- 142,146 ---- LPOVERLAPPED pOverlapped); ! ComIo &comIo; BYTE *pBuf; DWORD len; *************** *** 112,116 **** { public: ! WaitCommEventOverlapped(ComPort &_port); ~WaitCommEventOverlapped(); BOOL StartWaitCommEvent(); --- 150,154 ---- { public: ! WaitCommEventOverlapped(ComIo &_comIo); ~WaitCommEventOverlapped(); BOOL StartWaitCommEvent(); *************** *** 122,126 **** static VOID CALLBACK OnCommEvent(ULONG_PTR pOverlapped); ! ComPort &port; HANDLE hWait; DWORD eMask; --- 160,164 ---- static VOID CALLBACK OnCommEvent(ULONG_PTR pOverlapped); ! ComIo &comIo; HANDLE hWait; DWORD eMask; Index: comio.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/serial/comio.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** comio.cpp 29 Aug 2008 13:02:37 -0000 1.8 --- comio.cpp 30 Sep 2008 08:28:32 -0000 1.9 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.9 2008/09/30 08:28:32 vfrolov + * Added ability to control OUT1 and OUT2 pins + * Added ability to get remote baud rate and line control settings + * Added ability to set baud rate and line control + * Added fallback to non escape mode + * * Revision 1.8 2008/08/29 13:02:37 vfrolov * Added ESC_OPTS_MAP_EO2GO() and ESC_OPTS_MAP_GO2EO() *************** *** 90,112 **** } /////////////////////////////////////////////////////////////// ! static BOOL myGetCommState(HANDLE handle, DCB *dcb) { ! dcb->DCBlength = sizeof(*dcb); ! if (!::GetCommState(handle, dcb)) { TraceError(GetLastError(), "GetCommState()"); return FALSE; } return TRUE; } ! static BOOL mySetCommState(HANDLE handle, DCB *dcb) { ! if (!::SetCommState(handle, dcb)) { TraceError(GetLastError(), "SetCommState()"); ! myGetCommState(handle, dcb); return FALSE; } ! return myGetCommState(handle, dcb); } /////////////////////////////////////////////////////////////// --- 96,126 ---- } /////////////////////////////////////////////////////////////// ! static BOOL myGetCommState(HANDLE handle, DCB *pDcb) { ! DCB dcb; ! dcb.DCBlength = sizeof(dcb); ! ! if (!::GetCommState(handle, &dcb)) { TraceError(GetLastError(), "GetCommState()"); return FALSE; } + + *pDcb = dcb; + return TRUE; } ! static BOOL mySetCommState(HANDLE handle, DCB *pDcb) { ! if (!::SetCommState(handle, pDcb)) { TraceError(GetLastError(), "SetCommState()"); ! myGetCommState(handle, pDcb); return FALSE; } ! ! myGetCommState(handle, pDcb); ! ! return TRUE; } /////////////////////////////////////////////////////////////// *************** *** 138,164 **** return TRUE; } ! ! BOOL SetComEvents(HANDLE handle, DWORD *events) { ! if (!::SetCommMask(handle, *events)) { ! TraceError(GetLastError(), "SetCommMask()"); ! myGetCommMask(handle, events); return FALSE; } ! return myGetCommMask(handle, events); } /////////////////////////////////////////////////////////////// ! BOOL CommFunction(HANDLE handle, DWORD func) { ! if (!::EscapeCommFunction(handle, func)) { ! TraceError(GetLastError(), "EscapeCommFunction(%lu)", (long)func); return FALSE; } return TRUE; } /////////////////////////////////////////////////////////////// ! HANDLE OpenComPort(const char *pPath, const ComParams &comParams) { ! HANDLE handle = CreateFile(pPath, GENERIC_READ|GENERIC_WRITE, 0, --- 152,222 ---- return TRUE; } ! /////////////////////////////////////////////////////////////// ! static BOOL CommFunction(HANDLE handle, DWORD func) { ! if (!::EscapeCommFunction(handle, func)) { ! TraceError(GetLastError(), "EscapeCommFunction(%lu)", (long)func); return FALSE; } ! return TRUE; } /////////////////////////////////////////////////////////////// ! #define IOCTL_SERIAL_GET_MODEM_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT,37,METHOD_BUFFERED,FILE_ANY_ACCESS) ! #define IOCTL_SERIAL_SET_MODEM_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT,38,METHOD_BUFFERED,FILE_ANY_ACCESS) ! ! static BOOL HasExtendedModemControl(HANDLE handle) { ! BYTE inBufIoctl[C0CE_SIGNATURE_SIZE]; ! memcpy(inBufIoctl, C0CE_SIGNATURE, C0CE_SIGNATURE_SIZE); ! ! BYTE outBuf[sizeof(ULONG) + C0CE_SIGNATURE_SIZE]; ! ! DWORD returned; ! ! if (!DeviceIoControl(handle, ! IOCTL_SERIAL_GET_MODEM_CONTROL, ! inBufIoctl, sizeof(inBufIoctl), ! outBuf, sizeof(outBuf), &returned, ! NULL)) ! { ! TraceError(GetLastError(), "IOCTL_SERIAL_GET_MODEM_CONTROL"); ! return FALSE; ! } ! ! if (returned < (sizeof(ULONG) + C0CE_SIGNATURE_SIZE) || ! memcmp(outBuf + sizeof(ULONG), C0CE_SIGNATURE, C0CE_SIGNATURE_SIZE) != 0) ! { ! return FALSE; // standard functionality ! } ! ! return TRUE; ! } ! ! static BOOL SetModemControl(HANDLE handle, BYTE control, BYTE mask) ! { ! BYTE inBufIoctl[sizeof(ULONG) + sizeof(ULONG) + C0CE_SIGNATURE_SIZE]; ! ((ULONG *)inBufIoctl)[0] = control; ! ((ULONG *)inBufIoctl)[1] = mask; ! memcpy(inBufIoctl + sizeof(ULONG) + sizeof(ULONG), C0CE_SIGNATURE, C0CE_SIGNATURE_SIZE); ! ! DWORD returned; ! ! if (!DeviceIoControl(handle, ! IOCTL_SERIAL_SET_MODEM_CONTROL, ! inBufIoctl, sizeof(inBufIoctl), ! NULL, 0, &returned, ! NULL)) ! { ! TraceError(GetLastError(), "IOCTL_SERIAL_SET_MODEM_CONTROL"); return FALSE; } + return TRUE; } /////////////////////////////////////////////////////////////// ! BOOL ComIo::Open(const char *pPath, const ComParams &comParams) { ! handle = CreateFile( ! pPath, GENERIC_READ|GENERIC_WRITE, 0, *************** *** 169,181 **** if (handle == INVALID_HANDLE_VALUE) { ! TraceError(GetLastError(), "OpenComPort(): CreateFile(\"%s\")", pPath); ! return INVALID_HANDLE_VALUE; } - DCB dcb; - if (!myGetCommState(handle, &dcb)) { ! CloseHandle(handle); ! return INVALID_HANDLE_VALUE; } --- 227,237 ---- if (handle == INVALID_HANDLE_VALUE) { ! TraceError(GetLastError(), "ComIo::Open(): CreateFile(\"%s\")", pPath); ! return FALSE; } if (!myGetCommState(handle, &dcb)) { ! Close(); ! return FALSE; } *************** *** 216,221 **** if (!mySetCommState(handle, &dcb)) { ! CloseHandle(handle); ! return INVALID_HANDLE_VALUE; } --- 272,277 ---- if (!mySetCommState(handle, &dcb)) { ! Close(); ! return FALSE; } *************** *** 223,228 **** if (!myGetCommTimeouts(handle, &timeouts)) { ! CloseHandle(handle); ! return INVALID_HANDLE_VALUE; } --- 279,284 ---- if (!myGetCommTimeouts(handle, &timeouts)) { ! Close(); ! return FALSE; } *************** *** 241,246 **** if (!mySetCommTimeouts(handle, &timeouts)) { ! CloseHandle(handle); ! return INVALID_HANDLE_VALUE; } --- 297,302 ---- if (!mySetCommTimeouts(handle, &timeouts)) { ! Close(); ! return FALSE; } *************** *** 258,286 **** << ", ito=" << ComParams::IntervalTimeoutStr(timeouts.ReadIntervalTimeout) << ") - OK" << endl; ! return handle; } /////////////////////////////////////////////////////////////// ! BOOL SetManualRtsControl(HANDLE handle) { ! DCB dcb; ! if (!myGetCommState(handle, &dcb)) return FALSE; ! dcb.fRtsControl = RTS_CONTROL_DISABLE; ! return mySetCommState(handle, &dcb); } ! BOOL SetManualDtrControl(HANDLE handle) { ! DCB dcb; ! if (!myGetCommState(handle, &dcb)) ! return FALSE; ! dcb.fDtrControl = DTR_CONTROL_DISABLE; ! return mySetCommState(handle, &dcb); } /////////////////////////////////////////////////////////////// --- 314,416 ---- << ", ito=" << ComParams::IntervalTimeoutStr(timeouts.ReadIntervalTimeout) << ") - OK" << endl; ! ! hasExtendedModemControl = HasExtendedModemControl(handle); ! ! return TRUE; } /////////////////////////////////////////////////////////////// ! void ComIo::Close() { ! if (handle != INVALID_HANDLE_VALUE) { ! CloseHandle(handle); ! handle = INVALID_HANDLE_VALUE; ! } ! } ! /////////////////////////////////////////////////////////////// ! BOOL ComIo::SetManualRtsControl() ! { ! if (dcb.fRtsControl == RTS_CONTROL_DISABLE) ! return TRUE; ! dcb.fRtsControl = RTS_CONTROL_DISABLE; ! mySetCommState(handle, &dcb); ! ! return (dcb.fRtsControl == RTS_CONTROL_DISABLE); ! } ! /////////////////////////////////////////////////////////////// ! BOOL ComIo::SetManualDtrControl() ! { ! if (dcb.fDtrControl == DTR_CONTROL_DISABLE) ! return TRUE; ! ! dcb.fDtrControl = DTR_CONTROL_DISABLE; ! mySetCommState(handle, &dcb); ! ! return (dcb.fDtrControl == DTR_CONTROL_DISABLE); ! } ! /////////////////////////////////////////////////////////////// ! BOOL ComIo::SetComEvents(DWORD *pEvents) ! { ! if (!::SetCommMask(handle, *pEvents)) { ! TraceError(GetLastError(), "SetCommMask() %s", port.Name().c_str()); ! myGetCommMask(handle, pEvents); return FALSE; + } ! return myGetCommMask(handle, pEvents); ! } ! /////////////////////////////////////////////////////////////// ! void ComIo::SetPinState(WORD value, WORD mask) ! { ! if (mask & SPS_V2P_MCR(-1)) { ! if (hasExtendedModemControl) { ! if (!::SetModemControl(handle, SPS_P2V_MCR(value), SPS_P2V_MCR(mask))) ! cerr << port.Name() << " WARNING: can't change MCR state" << endl; ! } else { ! _ASSERTE((mask & SPS_V2P_MCR(-1) & ~(PIN_STATE_RTS|PIN_STATE_DTR)) == 0); ! if (mask & PIN_STATE_RTS) { ! if (!::CommFunction(handle, (value & PIN_STATE_RTS) ? SETRTS : CLRRTS)) ! cerr << port.Name() << " WARNING: can't change RTS state" << endl; ! } ! if (mask & PIN_STATE_DTR) { ! if (!::CommFunction(handle, (value & PIN_STATE_DTR) ? SETDTR : CLRDTR)) ! cerr << port.Name() << " WARNING: can't change DTR state" << endl; ! } ! } ! } ! ! _ASSERTE((mask & ~SPS_V2P_MCR(-1) & ~(PIN_STATE_BREAK)) == 0); ! ! if (mask & PIN_STATE_BREAK) { ! if (!::CommFunction(handle, (value & PIN_STATE_BREAK) ? SETBREAK : CLRBREAK)) ! cerr << port.Name() << " WARNING: can't change BREAK state" << endl; ! } } + /////////////////////////////////////////////////////////////// + DWORD ComIo::SetBaudRate(DWORD baudRate) + { + if (GetBaudRate() == baudRate) + return baudRate; ! dcb.BaudRate = baudRate; ! mySetCommState(handle, &dcb); ! ! return GetBaudRate(); ! } ! /////////////////////////////////////////////////////////////// ! DWORD ComIo::SetLineControl(DWORD lineControl) { ! _ASSERTE((lineControl & ~(VAL2LC_BYTESIZE(-1)|VAL2LC_PARITY(-1)|VAL2LC_STOPBITS(-1))) == 0); ! if (GetLineControl() == lineControl) ! return lineControl; ! dcb.ByteSize = LC2VAL_BYTESIZE(lineControl); ! dcb.Parity = LC2VAL_PARITY(lineControl); ! dcb.StopBits = LC2VAL_STOPBITS(lineControl); ! mySetCommState(handle, &dcb); ! return GetLineControl(); } /////////////////////////////////////////////////////////////// *************** *** 315,319 **** } ! DWORD SetEscMode(HANDLE handle, DWORD escOptions, BYTE **ppBuf, DWORD *pDone) { _ASSERTE(ppBuf != NULL); --- 445,449 ---- } ! DWORD ComIo::SetEscMode(DWORD escOptions, BYTE **ppBuf, DWORD *pDone) { _ASSERTE(ppBuf != NULL); *************** *** 419,423 **** if (opts & C0CE_INSERT_ENABLE_LSR) ! escOptions &= ~ESC_OPTS_MAP_GO2EO(GO_V2O_LINE_STATUS(LINE_STATUS_BITS & ~LINE_STATUS_BI)); if (opts & C0CE_INSERT_ENABLE_RBR) --- 549,553 ---- if (opts & C0CE_INSERT_ENABLE_LSR) ! escOptions &= ~ESC_OPTS_MAP_GO2EO(GO_V2O_LINE_STATUS(LINE_STATUS_BITS)); if (opts & C0CE_INSERT_ENABLE_RBR) *************** *** 430,435 **** } /////////////////////////////////////////////////////////////// ! WriteOverlapped::WriteOverlapped(ComPort &_port, BYTE *_pBuf, DWORD _len) ! : port(_port), pBuf(_pBuf), len(_len) --- 560,565 ---- } /////////////////////////////////////////////////////////////// ! WriteOverlapped::WriteOverlapped(ComIo &_comIo, BYTE *_pBuf, DWORD _len) ! : comIo(_comIo), pBuf(_pBuf), len(_len) *************** *** 450,456 **** if (err != ERROR_SUCCESS && err != ERROR_OPERATION_ABORTED) ! TraceError(err, "WriteOverlapped::OnWrite: %s", pOver->port.Name().c_str()); ! pOver->port.OnWrite(pOver, pOver->len, done); } --- 580,586 ---- 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); } *************** *** 462,466 **** return FALSE; ! if (!::WriteFileEx(port.Handle(), pBuf, len, this, OnWrite)) return FALSE; --- 592,596 ---- return FALSE; ! if (!::WriteFileEx(comIo.Handle(), pBuf, len, this, OnWrite)) return FALSE; *************** *** 468,473 **** } /////////////////////////////////////////////////////////////// ! ReadOverlapped::ReadOverlapped(ComPort &_port) ! : port(_port), pBuf(NULL) { --- 598,603 ---- } /////////////////////////////////////////////////////////////// ! ReadOverlapped::ReadOverlapped(ComIo &_comIo) ! : comIo(_comIo), pBuf(NULL) { *************** *** 487,491 **** if (err != ERROR_SUCCESS) { ! TraceError(err, "ReadOverlapped::OnRead(): %s", pOver->port.Name().c_str()); done = 0; } --- 617,621 ---- if (err != ERROR_SUCCESS) { ! TraceError(err, "ReadOverlapped::OnRead(): %s", pOver->comIo.port.Name().c_str()); done = 0; } *************** *** 494,498 **** pOver->pBuf = NULL; ! pOver->port.OnRead(pOver, pInBuf, done); } --- 624,628 ---- pOver->pBuf = NULL; ! pOver->comIo.port.OnRead(pOver, pInBuf, done); } *************** *** 508,515 **** return FALSE; ! if (::ReadFileEx(port.Handle(), pBuf, readBufSize, this, OnRead)) return TRUE; ! TraceError(GetLastError(), "ReadOverlapped::StartRead(): ReadFileEx() %s", port.Name().c_str()); return FALSE; } --- 638,645 ---- return FALSE; ! if (::ReadFileEx(comIo.Handle(), pBuf, readBufSize, this, OnRead)) return TRUE; ! TraceError(GetLastError(), "ReadOverlapped::StartRead(): ReadFileEx() %s", comIo.port.Name().c_str()); return FALSE; } *************** *** 517,522 **** static HANDLE hThread = INVALID_HANDLE_VALUE; ! WaitCommEventOverlapped::WaitCommEventOverlapped(ComPort &_port) ! : port(_port), hWait(INVALID_HANDLE_VALUE) { --- 647,652 ---- static HANDLE hThread = INVALID_HANDLE_VALUE; ! WaitCommEventOverlapped::WaitCommEventOverlapped(ComIo &_comIo) ! : comIo(_comIo), hWait(INVALID_HANDLE_VALUE) { *************** *** 545,549 **** GetLastError(), "WaitCommEventOverlapped::WaitCommEventOverlapped(): DuplicateHandle() %s", ! port.Name().c_str()); return; --- 675,679 ---- GetLastError(), "WaitCommEventOverlapped::WaitCommEventOverlapped(): DuplicateHandle() %s", ! comIo.port.Name().c_str()); return; *************** *** 559,563 **** GetLastError(), "WaitCommEventOverlapped::WaitCommEventOverlapped(): CreateEvent() %s", ! port.Name().c_str()); return; --- 689,693 ---- GetLastError(), "WaitCommEventOverlapped::WaitCommEventOverlapped(): CreateEvent() %s", ! comIo.port.Name().c_str()); return; *************** *** 568,572 **** GetLastError(), "WaitCommEventOverlapped::StartWaitCommEvent(): RegisterWaitForSingleObject() %s", ! port.Name().c_str()); hWait = INVALID_HANDLE_VALUE; --- 698,702 ---- GetLastError(), "WaitCommEventOverlapped::StartWaitCommEvent(): RegisterWaitForSingleObject() %s", ! comIo.port.Name().c_str()); hWait = INVALID_HANDLE_VALUE; *************** *** 583,587 **** GetLastError(), "WaitCommEventOverlapped::~WaitCommEventOverlapped(): UnregisterWait() %s", ! port.Name().c_str()); } } --- 713,717 ---- GetLastError(), "WaitCommEventOverlapped::~WaitCommEventOverlapped(): UnregisterWait() %s", ! comIo.port.Name().c_str()); } } *************** *** 592,596 **** GetLastError(), "WaitCommEventOverlapped::~WaitCommEventOverlapped(): CloseHandle(hEvent) %s", ! port.Name().c_str()); } } --- 722,726 ---- GetLastError(), "WaitCommEventOverlapped::~WaitCommEventOverlapped(): CloseHandle(hEvent) %s", ! comIo.port.Name().c_str()); } } *************** *** 610,623 **** DWORD done; ! if (!::GetOverlappedResult(pOver->port.Handle(), pOver, &done, FALSE)) { TraceError( GetLastError(), "WaitCommEventOverlapped::OnCommEvent(): GetOverlappedResult() %s", ! pOver->port.Name().c_str()); pOver->eMask = 0; } ! pOver->port.OnCommEvent(pOver, pOver->eMask); } --- 740,753 ---- DWORD done; ! if (!::GetOverlappedResult(pOver->comIo.Handle(), pOver, &done, FALSE)) { TraceError( GetLastError(), "WaitCommEventOverlapped::OnCommEvent(): GetOverlappedResult() %s", ! pOver->comIo.port.Name().c_str()); pOver->eMask = 0; } ! pOver->comIo.port.OnCommEvent(pOver, pOver->eMask); } *************** *** 627,631 **** return FALSE; ! if (!::WaitCommEvent(port.Handle(), &eMask, this)) { DWORD err = ::GetLastError(); --- 757,761 ---- return FALSE; ! if (!::WaitCommEvent(comIo.Handle(), &eMask, this)) { DWORD err = ::GetLastError(); *************** *** 634,638 **** err, "WaitCommEventOverlapped::StartWaitCommEvent(): WaitCommEvent() %s", ! port.Name().c_str()); return FALSE; } --- 764,768 ---- err, "WaitCommEventOverlapped::StartWaitCommEvent(): WaitCommEvent() %s", ! comIo.port.Name().c_str()); return FALSE; } |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 08:29:05
|
Update of /cvsroot/com0com/hub4com/plugins/escparse In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13607/escparse Modified Files: filter.cpp Log Message: Added ability to control OUT1 and OUT2 pins Added ability to get remote baud rate and line control settings Added ability to set baud rate and line control Added fallback to non escape mode Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/escparse/filter.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** filter.cpp 29 Aug 2008 13:02:37 -0000 1.2 --- filter.cpp 30 Sep 2008 08:28:32 -0000 1.3 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.3 2008/09/30 08:28:32 vfrolov + * Added ability to control OUT1 and OUT2 pins + * Added ability to get remote baud rate and line control settings + * Added ability to set baud rate and line control + * Added fallback to non escape mode + * * Revision 1.2 2008/08/29 13:02:37 vfrolov * Added ESC_OPTS_MAP_EO2GO() and ESC_OPTS_MAP_GO2EO() *************** *** 105,110 **** BYTE escapeChar; ! WORD maskMst; ! WORD maskLsr; int state; BYTE code; --- 111,116 ---- BYTE escapeChar; ! BYTE maskMst; ! BYTE maskLsr; int state; BYTE code; *************** *** 158,202 **** break; case SERIAL_LSRMST_LSR_DATA: - _ASSERTE(subState >= 0 && subState <= 2); - - if (subState == 0) { - subState++; - } else if (subState == 1) { - data[0] = ch; // LSR - subState++; - } else if (subState == 2) { - line_data.append(&ch, 1); - if (Options() & GO_BREAK_STATUS) { - pMsg = Flush(pMsg); - pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_BREAK_STATUS, (data[0] & LINE_STATUS_BI) != 0); - } - if (maskLsr) { - pMsg = Flush(pMsg); - pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_LINE_STATUS, data[0] | VAL2MASK(maskLsr)); - } - Reset(); - } else { - cerr << "ERROR: SERIAL_LSRMST_LSR_DATA subState=" << subState << endl; - Reset(); - } - break; case SERIAL_LSRMST_LSR_NODATA: ! _ASSERTE(subState >= 0 && subState <= 1); ! if (subState == 0) { ! subState++; ! } else if (subState == 1) { ! if (Options() & GO_BREAK_STATUS) { ! pMsg = Flush(pMsg); ! pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_BREAK_STATUS, (ch & LINE_STATUS_BI) != 0); ! } ! if (maskLsr) { ! pMsg = Flush(pMsg); ! pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_LINE_STATUS, ch | VAL2MASK(maskLsr)); ! } ! Reset(); ! } else { ! cerr << "ERROR: SERIAL_LSRMST_LSR_NODATA subState=" << subState << endl; ! Reset(); } break; --- 164,198 ---- break; case SERIAL_LSRMST_LSR_DATA: case SERIAL_LSRMST_LSR_NODATA: ! _ASSERTE(subState >= 0 && (subState <= 1 || (code == SERIAL_LSRMST_LSR_DATA && subState <= 2))); ! switch (subState) { ! case 0: ! subState++; ! break; ! case 1: ! data[0] = ch; ! if (code == SERIAL_LSRMST_LSR_DATA) { ! subState++; ! break; ! } ! case 2: ! if (Options() & GO_BREAK_STATUS) { ! pMsg = Flush(pMsg); ! pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_BREAK_STATUS, (data[0] & LINE_STATUS_BI) != 0); ! } ! if (data[0] & maskLsr) { ! pMsg = Flush(pMsg); ! pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_LINE_STATUS, data[0] | VAL2MASK(maskLsr)); ! } ! if (subState == 2 && ((data[0] & LINE_STATUS_BI) == 0 || ch != 0)) { ! // insert error character if it is not part of break ! line_data.append(&ch, 1); ! } ! Reset(); ! break; ! default: ! cerr << "ERROR: SERIAL_LSRMST_LSR_*DATA subState=" << subState << endl; ! Reset(); } break; *************** *** 250,254 **** if (Options() & GO_RLC_STATUS) { pMsg = Flush(pMsg); ! pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_RLC_STATUS, *(ULONG *)data); } Reset(); --- 246,253 ---- if (Options() & GO_RLC_STATUS) { pMsg = Flush(pMsg); ! pMsg = pMsgInsertVal(pMsg, HUB_MSG_TYPE_RLC_STATUS, ! (VAL2LC_BYTESIZE(data[0]) ! |VAL2LC_PARITY(data[1]) ! |VAL2LC_STOPBITS(data[2]))); } Reset(); *************** *** 324,327 **** --- 323,345 ---- continue; } + + const char *pParam; + + if ((pParam = GetParam(pArg, "request-esc-mode=")) != NULL) { + if (_stricmp(pParam, "yes") == 0) { + requestEscMode = TRUE; + } + else + if (_stricmp(pParam, "no") == 0) { + requestEscMode = FALSE; + } + else { + cerr << "Unknown value --" << pArg << endl; + Invalidate(); + } + } else { + cerr << "Unknown option --" << pArg << endl; + Invalidate(); + } } } *************** *** 371,377 **** << endl << "Options:" << endl << endl << "Examples:" << endl ! << " " << pProgPath << " --create-filter=pinmap --create-filter=" << GetPluginAbout()->pName << " --add-filters=0,1:pinmap," << GetPluginAbout()->pName << " COM1 COM2" << endl << " - transfer data and signals between COM1 and COM2." << endl ; --- 389,403 ---- << endl << "Options:" << endl + << " --request-esc-mode={yes|no} - send request to driver to produce escaped data" << endl + << " (yes by default)." << endl << endl << "Examples:" << endl ! << " " << pProgPath << " --load=,,_END_" << endl ! << " --create-filter=pinmap" << endl ! << " --create-filter=escparse" << endl ! << " --add-filters=0,1:pinmap,escparse" << endl ! << " COM1" << endl ! << " COM2" << endl ! << " _END_" << endl << " - transfer data and signals between COM1 and COM2." << endl ; *************** *** 485,489 **** return FALSE; ! DWORD fail_options = (pInMsg->u.val & ESC_OPTS_MAP_GO2EO(pEscParse->Options())); if (fail_options) { --- 511,515 ---- return FALSE; ! DWORD fail_options = (pInMsg->u.pv.val & ESC_OPTS_MAP_GO2EO(pEscParse->Options())); if (fail_options) { *************** *** 491,497 **** << " WARNING: Requested by filter " << ((Filter *)hFilter)->FilterName() << " escape mode option(s) 0x" << hex << fail_options << dec ! << " not accepted" << endl; pEscParse->OptionsDel(ESC_OPTS_MAP_EO2GO(fail_options)); } --- 517,524 ---- << " WARNING: Requested by filter " << ((Filter *)hFilter)->FilterName() << " escape mode option(s) 0x" << hex << fail_options << dec ! << " not accepted (will try non escape mode option(s))" << endl; pEscParse->OptionsDel(ESC_OPTS_MAP_EO2GO(fail_options)); + *pInMsg->u.pv.pVal |= ESC_OPTS_MAP_EO2GO(fail_options); } *************** *** 518,535 **** pInMsg->u.val &= ~GO_ESCAPE_MODE; // hide from subsequent filters - DWORD fail_options = (pEscParse->intercepted_options & ~pEscParse->Options()); - - if (fail_options) { - cerr << ((Filter *)hFilter)->PortName(nFromPort) - << " WARNING: Intercepted option(s) 0x" - << hex << fail_options << dec << " by filter " - << ((Filter *)hFilter)->FilterName() - << " will be ignored" << endl; - - // report not supported intercepted options to subsequent filters - - pInMsg->u.val |= fail_options; - } - break; } --- 545,548 ---- *************** *** 549,578 **** break; } ! case HUB_MSG_TYPE_MODEM_STATUS: // discard any status settings controlled by this filter ! pInMsg->u.val &= ~VAL2MASK(GO_O2V_MODEM_STATUS(((Filter *)hFilter)->acceptableOptions)); break; ! case HUB_MSG_TYPE_LINE_STATUS: // discard any status settings controlled by this filter ! pInMsg->u.val &= ~VAL2MASK(GO_O2V_LINE_STATUS(((Filter *)hFilter)->acceptableOptions)); break; ! case HUB_MSG_TYPE_RBR_STATUS: ! if (((Filter *)hFilter)->acceptableOptions & GO_RBR_STATUS) { // discard any status settings controlled by this filter pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); } break; ! case HUB_MSG_TYPE_RLC_STATUS: ! if (((Filter *)hFilter)->acceptableOptions & GO_RLC_STATUS) { // discard any status settings controlled by this filter pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); } break; ! case HUB_MSG_TYPE_BREAK_STATUS: ! if (((Filter *)hFilter)->acceptableOptions & GO_BREAK_STATUS) { // discard any status settings controlled by this filter pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); } break; } --- 562,621 ---- break; } ! case HUB_MSG_TYPE_MODEM_STATUS: { ! EscParse *pEscParse = ((Filter *)hFilter)->GetEscParse(nFromPort); ! ! if (!pEscParse) ! return FALSE; ! // discard any status settings controlled by this filter ! pInMsg->u.val &= ~VAL2MASK(GO_O2V_MODEM_STATUS(pEscParse->Options())); break; ! } ! case HUB_MSG_TYPE_LINE_STATUS: { ! EscParse *pEscParse = ((Filter *)hFilter)->GetEscParse(nFromPort); ! ! if (!pEscParse) ! return FALSE; ! // discard any status settings controlled by this filter ! pInMsg->u.val &= ~VAL2MASK(GO_O2V_LINE_STATUS(pEscParse->Options())); break; ! } ! case HUB_MSG_TYPE_RBR_STATUS: { ! EscParse *pEscParse = ((Filter *)hFilter)->GetEscParse(nFromPort); ! ! if (!pEscParse) ! return FALSE; ! ! if (pEscParse->Options() & GO_RBR_STATUS) { // discard any status settings controlled by this filter pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); } break; ! } ! case HUB_MSG_TYPE_RLC_STATUS: { ! EscParse *pEscParse = ((Filter *)hFilter)->GetEscParse(nFromPort); ! ! if (!pEscParse) ! return FALSE; ! ! if (pEscParse->Options() & GO_RLC_STATUS) { // discard any status settings controlled by this filter pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); } break; ! } ! case HUB_MSG_TYPE_BREAK_STATUS: { ! EscParse *pEscParse = ((Filter *)hFilter)->GetEscParse(nFromPort); ! ! if (!pEscParse) ! return FALSE; ! ! if (pEscParse->Options() & GO_BREAK_STATUS) { // discard any status settings controlled by this filter pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); } break; + } } |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 08:28:58
|
Update of /cvsroot/com0com/hub4com/plugins/trace In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13607/trace Modified Files: filter.cpp Log Message: Added ability to control OUT1 and OUT2 pins Added ability to get remote baud rate and line control settings Added ability to set baud rate and line control Added fallback to non escape mode Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/trace/filter.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** filter.cpp 29 Aug 2008 15:17:07 -0000 1.2 --- filter.cpp 30 Sep 2008 08:28:32 -0000 1.3 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.3 2008/09/30 08:28:32 vfrolov + * Added ability to control OUT1 and OUT2 pins + * Added ability to get remote baud rate and line control settings + * Added ability to set baud rate and line control + * Added fallback to non escape mode + * * Revision 1.2 2008/08/29 15:17:07 vfrolov * Added printing command line and config *************** *** 296,300 **** while (pTable->name) { if (pTable->code == code) { ! tout << pTable->name; return; } --- 302,306 ---- while (pTable->name) { if (pTable->code == code) { ! tout << pTable->name; return; } *************** *** 366,373 **** TOCODE2NAME(HUB_MSG_TYPE_, FAIL_ESC_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, BREAK_STATUS), {0, NULL} }; /////////////////////////////////////////////////////////////// ! static FIELD2NAME fieldNameTableModemStatus[] = { TOFIELD2NAME2(MODEM_STATUS_, DCTS), TOFIELD2NAME2(MODEM_STATUS_, DDSR), --- 372,398 ---- TOCODE2NAME(HUB_MSG_TYPE_, FAIL_ESC_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, BREAK_STATUS), + TOCODE2NAME(HUB_MSG_TYPE_, SET_BR), + TOCODE2NAME(HUB_MSG_TYPE_, SET_LC), {0, NULL} }; /////////////////////////////////////////////////////////////// ! static const CODE2NAME codeNameTableParity[] = { ! NOPARITY, "N", ! ODDPARITY, "O", ! EVENPARITY, "E", ! MARKPARITY, "M", ! SPACEPARITY, "S", ! {0, NULL} ! }; ! /////////////////////////////////////////////////////////////// ! static const CODE2NAME codeNameTableStopBits ! [] = { ! ONESTOPBIT, "1", ! ONE5STOPBITS, "1.5", ! TWOSTOPBITS, "2", ! {0, NULL} ! }; ! /////////////////////////////////////////////////////////////// ! static const FIELD2NAME fieldNameTableModemStatus[] = { TOFIELD2NAME2(MODEM_STATUS_, DCTS), TOFIELD2NAME2(MODEM_STATUS_, DDSR), *************** *** 381,385 **** }; /////////////////////////////////////////////////////////////// ! static FIELD2NAME fieldNameTableLineStatus[] = { TOFIELD2NAME2(LINE_STATUS_, DR), TOFIELD2NAME2(LINE_STATUS_, OE), --- 406,410 ---- }; /////////////////////////////////////////////////////////////// ! static const FIELD2NAME fieldNameTableLineStatus[] = { TOFIELD2NAME2(LINE_STATUS_, DR), TOFIELD2NAME2(LINE_STATUS_, OE), *************** *** 393,397 **** }; /////////////////////////////////////////////////////////////// ! static FIELD2NAME fieldNameTableGoOptions[] = { TOFIELD2NAME2(GO_, RBR_STATUS), TOFIELD2NAME2(GO_, RLC_STATUS), --- 418,422 ---- }; /////////////////////////////////////////////////////////////// ! static const FIELD2NAME fieldNameTableGoOptions[] = { TOFIELD2NAME2(GO_, RBR_STATUS), TOFIELD2NAME2(GO_, RLC_STATUS), *************** *** 401,405 **** }; /////////////////////////////////////////////////////////////// ! static FIELD2NAME codeNameTableSetPinState[] = { TOFIELD2NAME2(PIN_STATE_, RTS), TOFIELD2NAME2(PIN_STATE_, DTR), --- 426,430 ---- }; /////////////////////////////////////////////////////////////// ! static const FIELD2NAME codeNameTableSetPinState[] = { TOFIELD2NAME2(PIN_STATE_, RTS), TOFIELD2NAME2(PIN_STATE_, DTR), *************** *** 410,413 **** --- 435,444 ---- }; /////////////////////////////////////////////////////////////// + static const FIELD2NAME fieldNameTableSoOptions[] = { + TOFIELD2NAME2(SO_, SET_BR), + TOFIELD2NAME2(SO_, SET_LC), + {0, 0, NULL} + }; + /////////////////////////////////////////////////////////////// static BOOL PrintGoOptions( ostream &tout, *************** *** 496,499 **** --- 527,536 ---- tout << val; break; + case HUB_MSG_VAL_TYPE_LC: + tout << (unsigned)LC2VAL_BYTESIZE(val) << '-'; + PrintCode(tout, codeNameTableParity, LC2VAL_PARITY(val)); + tout << '-'; + PrintCode(tout, codeNameTableStopBits, LC2VAL_STOPBITS(val)); + break; default: tout << "0x" << hex << val << dec; *************** *** 513,517 **** break; case HUB_MSG_UNION_TYPE_PVAL: ! tout << "&0x" << hex << *pMsg->u.pv.pVal << dec << " "; PrintVal(tout, pMsg->type, pMsg->u.pv.val); break; --- 550,554 ---- break; case HUB_MSG_UNION_TYPE_PVAL: ! tout << hex << "&" << pMsg->u.pv.pVal << "[0x" << *pMsg->u.pv.pVal << dec << "] "; PrintVal(tout, pMsg->type, pMsg->u.pv.val); break; *************** *** 540,550 **** tout << "["; BOOL delimitNext = FALSE; ! delimitNext = PrintFields(tout, codeNameTableSetPinState, SO_O2V_PIN_STATE(pMsg->u.val), delimitNext, "PIN_"); ! PrintFields(tout, NULL, pMsg->u.val & ~SO_V2O_PIN_STATE(-1), delimitNext); tout << "]"; break; } case HUB_MSG_TYPE_GET_IN_OPTS: { ! tout << "&["; PrintGoOptions(tout, *pMsg->u.pv.pVal); tout << "] ["; --- 577,587 ---- tout << "["; BOOL delimitNext = FALSE; ! delimitNext = PrintFields(tout, codeNameTableSetPinState, SO_O2V_PIN_STATE(pMsg->u.val), delimitNext, "SET_"); ! PrintFields(tout, fieldNameTableSoOptions, pMsg->u.val & ~SO_V2O_PIN_STATE(-1), delimitNext); tout << "]"; break; } case HUB_MSG_TYPE_GET_IN_OPTS: { ! tout << hex << "&" << pMsg->u.pv.pVal << "[" << dec; PrintGoOptions(tout, *pMsg->u.pv.pVal); tout << "] ["; *************** *** 560,564 **** } case HUB_MSG_TYPE_GET_ESC_OPTS: { ! tout << "&["; tout << "CHAR_0x" << hex << (unsigned)ESC_OPTS_O2V_ESCCHAR(*pMsg->u.pv.pVal) << dec; PrintEscOptions(tout, *pMsg->u.pv.pVal & ~ESC_OPTS_V2O_ESCCHAR(-1), TRUE); --- 597,601 ---- } case HUB_MSG_TYPE_GET_ESC_OPTS: { ! tout << hex << "&" << pMsg->u.pv.pVal << "[" << dec; tout << "CHAR_0x" << hex << (unsigned)ESC_OPTS_O2V_ESCCHAR(*pMsg->u.pv.pVal) << dec; PrintEscOptions(tout, *pMsg->u.pv.pVal & ~ESC_OPTS_V2O_ESCCHAR(-1), TRUE); *************** *** 567,572 **** } case HUB_MSG_TYPE_FAIL_ESC_OPTS: { ! tout << "["; ! PrintEscOptions(tout, pMsg->u.val & ~ESC_OPTS_V2O_ESCCHAR(-1)); tout << "]"; break; --- 604,611 ---- } case HUB_MSG_TYPE_FAIL_ESC_OPTS: { ! tout << hex << "&" << pMsg->u.pv.pVal << "[" << dec; ! PrintGoOptions(tout, *pMsg->u.pv.pVal); ! tout << "] ["; ! PrintEscOptions(tout, pMsg->u.pv.val & ~ESC_OPTS_V2O_ESCCHAR(-1)); tout << "]"; break; |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 08:28:53
|
Update of /cvsroot/com0com/hub4com/plugins In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13607 Modified Files: plugins_api.h Log Message: Added ability to control OUT1 and OUT2 pins Added ability to get remote baud rate and line control settings Added ability to set baud rate and line control Added fallback to non escape mode Index: plugins_api.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/plugins_api.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** plugins_api.h 29 Aug 2008 13:02:37 -0000 1.11 --- plugins_api.h 30 Sep 2008 08:28:32 -0000 1.12 *************** *** 41,44 **** --- 41,51 ---- #define HUB_MSG_VAL_TYPE_MSG_TYPE 0x0300 #define HUB_MSG_VAL_TYPE_UINT 0x0400 + #define HUB_MSG_VAL_TYPE_LC 0x0500 + #define LC2VAL_BYTESIZE(t) ((BYTE)((t))) + #define VAL2LC_BYTESIZE(v) ((DWORD)(BYTE)(v)) + #define LC2VAL_PARITY(t) ((BYTE)((t) >> 8)) + #define VAL2LC_PARITY(v) ((DWORD)(BYTE)(v) << 8) + #define LC2VAL_STOPBITS(t) ((BYTE)((t) >> 16)) + #define VAL2LC_STOPBITS(v) ((DWORD)(BYTE)(v) << 16) /*******************************************************************/ #define HUB_MSG_TYPE_EMPTY (0 | HUB_MSG_UNION_TYPE_NONE) *************** *** 64,72 **** #define LINE_STATUS_FIFOERR 0x80 #define HUB_MSG_TYPE_SET_PIN_STATE (5 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_MASK_VAL) ! #define PIN_STATE_RTS 0x01 ! #define PIN_STATE_DTR 0x02 ! #define PIN_STATE_OUT1 0x04 ! #define PIN_STATE_OUT2 0x08 ! #define PIN_STATE_BREAK 0x10 #define HUB_MSG_TYPE_GET_IN_OPTS (6 | HUB_MSG_UNION_TYPE_PVAL) #define GO_O2V_MODEM_STATUS(o) ((BYTE)(o)) --- 71,81 ---- #define LINE_STATUS_FIFOERR 0x80 #define HUB_MSG_TYPE_SET_PIN_STATE (5 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_MASK_VAL) ! #define SPS_P2V_MCR(p) ((BYTE)(p)) ! #define SPS_V2P_MCR(v) ((WORD)(BYTE)(v)) ! #define PIN_STATE_DTR 0x0001 ! #define PIN_STATE_RTS 0x0002 ! #define PIN_STATE_OUT1 0x0004 ! #define PIN_STATE_OUT2 0x0008 ! #define PIN_STATE_BREAK 0x0100 #define HUB_MSG_TYPE_GET_IN_OPTS (6 | HUB_MSG_UNION_TYPE_PVAL) #define GO_O2V_MODEM_STATUS(o) ((BYTE)(o)) *************** *** 79,87 **** #define GO_ESCAPE_MODE ((DWORD)1 << 24) #define HUB_MSG_TYPE_SET_OUT_OPTS (7 | HUB_MSG_UNION_TYPE_VAL) ! #define SO_O2V_PIN_STATE(o) ((BYTE)(o)) ! #define SO_V2O_PIN_STATE(v) ((DWORD)(BYTE)(v)) #define HUB_MSG_TYPE_FAIL_IN_OPTS (8 | HUB_MSG_UNION_TYPE_VAL) #define HUB_MSG_TYPE_RBR_STATUS (9 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_UINT) ! #define HUB_MSG_TYPE_RLC_STATUS (10 | HUB_MSG_UNION_TYPE_VAL) #define HUB_MSG_TYPE_COUNT_REPEATS (11 | HUB_MSG_UNION_TYPE_PVAL | HUB_MSG_VAL_TYPE_MSG_TYPE) #define HUB_MSG_TYPE_GET_ESC_OPTS (12 | HUB_MSG_UNION_TYPE_PVAL) --- 88,98 ---- #define GO_ESCAPE_MODE ((DWORD)1 << 24) #define HUB_MSG_TYPE_SET_OUT_OPTS (7 | HUB_MSG_UNION_TYPE_VAL) ! #define SO_O2V_PIN_STATE(o) ((WORD)(o)) ! #define SO_V2O_PIN_STATE(v) ((DWORD)(WORD)(v)) ! #define SO_SET_BR ((DWORD)1 << 16) ! #define SO_SET_LC ((DWORD)1 << 17) #define HUB_MSG_TYPE_FAIL_IN_OPTS (8 | HUB_MSG_UNION_TYPE_VAL) #define HUB_MSG_TYPE_RBR_STATUS (9 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_UINT) ! #define HUB_MSG_TYPE_RLC_STATUS (10 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_LC) #define HUB_MSG_TYPE_COUNT_REPEATS (11 | HUB_MSG_UNION_TYPE_PVAL | HUB_MSG_VAL_TYPE_MSG_TYPE) #define HUB_MSG_TYPE_GET_ESC_OPTS (12 | HUB_MSG_UNION_TYPE_PVAL) *************** *** 90,95 **** #define ESC_OPTS_O2V_ESCCHAR(o) ((BYTE)(o >> 24)) #define ESC_OPTS_V2O_ESCCHAR(v) ((DWORD)(BYTE)(v) << 24) ! #define HUB_MSG_TYPE_FAIL_ESC_OPTS (13 | HUB_MSG_UNION_TYPE_VAL) #define HUB_MSG_TYPE_BREAK_STATUS (14 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_BOOL) /*******************************************************************/ typedef struct _HUB_MSG { --- 101,108 ---- #define ESC_OPTS_O2V_ESCCHAR(o) ((BYTE)(o >> 24)) #define ESC_OPTS_V2O_ESCCHAR(v) ((DWORD)(BYTE)(v) << 24) ! #define HUB_MSG_TYPE_FAIL_ESC_OPTS (13 | HUB_MSG_UNION_TYPE_PVAL) #define HUB_MSG_TYPE_BREAK_STATUS (14 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_BOOL) + #define HUB_MSG_TYPE_SET_BR (15 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_UINT) + #define HUB_MSG_TYPE_SET_LC (16 | HUB_MSG_UNION_TYPE_VAL | HUB_MSG_VAL_TYPE_LC) /*******************************************************************/ typedef struct _HUB_MSG { |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 07:52:24
|
Update of /cvsroot/com0com/hub4com/plugins/pin2con In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32482 Modified Files: filter.cpp Log Message: Removed HUB_MSG_TYPE_LINE_STATUS filtering Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/pin2con/filter.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** filter.cpp 22 Aug 2008 16:57:11 -0000 1.8 --- filter.cpp 30 Sep 2008 07:52:09 -0000 1.9 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.9 2008/09/30 07:52:09 vfrolov + * Removed HUB_MSG_TYPE_LINE_STATUS filtering + * * Revision 1.8 2008/08/22 16:57:11 vfrolov * Added *************** *** 200,208 **** << endl << "IN method input data stream description:" << endl - << " GET_IN_OPTS(<pOpts>) - the value pointed by <pOpts> will be or'ed with" << endl - << " the required mask to get line status and modem" << endl - << " status." << endl << " CONNECT(TRUE/FALSE) - will be discarded from stream." << endl ! << " LINE_STATUS(<val>) - current state of line." << endl << " MODEM_STATUS(<val>) - current state of modem." << endl << endl --- 203,208 ---- << endl << "IN method input data stream description:" << endl << " CONNECT(TRUE/FALSE) - will be discarded from stream." << endl ! << " BREAK_STATUS(<val>) - current state of break." << endl << " MODEM_STATUS(<val>) - current state of modem." << endl << endl *************** *** 211,215 **** << endl << "Examples:" << endl ! << " " << pProgPath << " --create-filter=" << GetPluginAbout()->pName << " --add-filters=0:" << GetPluginAbout()->pName << " COM1 --use-driver=tcp 111.11.11.11:1111" << endl << " - wait DSR ON from COM1 and then establish connection to 111.11.11.11:1111" << endl << " and disconnect on DSR OFF." << endl --- 211,221 ---- << endl << "Examples:" << endl ! << " " << pProgPath << " --load=,,_END_" << endl ! << " --create-filter=pin2con" << endl ! << " --add-filters=0:pin2con" << endl ! << " COM1" << endl ! << " --use-driver=tcp" << endl ! << " 111.11.11.11:1111" << endl ! << " _END_" << endl << " - wait DSR ON from COM1 and then establish connection to 111.11.11.11:1111" << endl << " and disconnect on DSR OFF." << endl *************** *** 289,301 **** pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); break; - case HUB_MSG_TYPE_LINE_STATUS: case HUB_MSG_TYPE_MODEM_STATUS: { WORD pin; ! if (pInMsg->type == HUB_MSG_TYPE_LINE_STATUS) { ! pin = GO_O2V_LINE_STATUS(((Filter *)hFilter)->pin); ! } else { ! pin = GO_O2V_MODEM_STATUS(((Filter *)hFilter)->pin); ! } if ((pin & MASK2VAL(pInMsg->u.val)) == 0) --- 295,302 ---- pMsgReplaceNone(pInMsg, HUB_MSG_TYPE_EMPTY); break; case HUB_MSG_TYPE_MODEM_STATUS: { WORD pin; ! pin = GO_O2V_MODEM_STATUS(((Filter *)hFilter)->pin); if ((pin & MASK2VAL(pInMsg->u.val)) == 0) |
From: Vyacheslav F. <v.f...@or...> - 2008-09-30 07:15:57
|
Update of /cvsroot/com0com/hub4com In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv23919 Modified Files: hub4com.cpp utils.cpp Log Message: Added substitution <PRM0> by <file> for --load=<file> Index: utils.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/utils.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** utils.cpp 28 Aug 2008 15:53:13 -0000 1.4 --- utils.cpp 26 Sep 2008 14:29:13 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2008/09/26 14:29:13 vfrolov + * Added substitution <PRM0> by <file> for --load=<file> + * * Revision 1.4 2008/08/28 15:53:13 vfrolov * Added ability to load arguments from standard input and *************** *** 59,63 **** stringstream par; ! par << (i + 1) << "%%"; if (argBuf.compare(off + 2, par.str().length(), par.str()) == 0) { --- 62,66 ---- stringstream par; ! par << i << "%%"; if (argBuf.compare(off + 2, par.str().length(), par.str()) == 0) { *************** *** 107,110 **** --- 110,115 ---- } + vector<string> paramsLoad; + ifstream ifile; istream *pInStream; *************** *** 118,128 **** } pInStream = &ifile; } else { pInStream = &cin; } - vector<string> paramsLoad; - for (char *p = STRQTOK_R(NULL, ",", &pSave) ; p ; p = STRQTOK_R(NULL, ",", &pSave)) paramsLoad.push_back(p); --- 123,133 ---- } + paramsLoad.push_back(pFile); pInStream = &ifile; } else { + paramsLoad.push_back(""); pInStream = &cin; } for (char *p = STRQTOK_R(NULL, ",", &pSave) ; p ; p = STRQTOK_R(NULL, ",", &pSave)) paramsLoad.push_back(p); Index: hub4com.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/hub4com.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** hub4com.cpp 28 Aug 2008 15:53:13 -0000 1.13 --- hub4com.cpp 26 Sep 2008 14:29:13 -0000 1.14 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.14 2008/09/26 14:29:13 vfrolov + * Added substitution <PRM0> by <file> for --load=<file> + * * Revision 1.13 2008/08/28 15:53:13 vfrolov * Added ability to load arguments from standard input and *************** *** 87,91 **** << " if <begin> is empty. Do loading till end-of-file" << endl << " if <end> is empty. Ignore arguments begining with" << endl ! << " '#'." << endl << " --help - show this help." << endl << " --help=* - show help for all modules." << endl --- 90,94 ---- << " if <begin> is empty. Do loading till end-of-file" << endl << " if <end> is empty. Ignore arguments begining with" << endl ! << " '#'. <file> will replace %%0%% in the arguments." << endl << " --help - show this help." << endl << " --help=* - show help for all modules." << endl ******************************************************************************************************* This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. Messages are susceptible to alteration. Orange Business Services shall not be liable for the message if altered, changed or falsified. If you are not the intended addressee of this message, please cancel it immediately and inform the sender. ******************************************************************************************************* |
From: Vyacheslav F. <vf...@us...> - 2008-09-30 06:44:57
|
Update of /cvsroot/com0com/hub4com/plugins/tcp In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv7270 Modified Files: comport.cpp Log Message: Added warning about ignored output options Index: comport.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comport.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comport.cpp 28 Mar 2008 16:00:19 -0000 1.2 --- comport.cpp 30 Sep 2008 06:44:50 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/09/30 06:44:50 vfrolov + * Added warning about ignored output options + * * Revision 1.2 2008/03/28 16:00:19 vfrolov * Added connectionCounter *************** *** 331,334 **** --- 334,345 ---- } } + else + if (pMsg->type == 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; + } + } return TRUE; |
From: Vyacheslav F. <vf...@us...> - 2008-09-17 00:59:13
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10895/setup Modified Files: params.cpp params.h Log Message: Added AddRTTO and AddRITO parameters Index: params.h =================================================================== RCS file: /cvsroot/com0com/com0com/setup/params.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** params.h 26 Jun 2008 13:39:19 -0000 1.7 --- params.h 17 Sep 2008 07:58:32 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2008/09/17 07:58:32 vfrolov + * Added AddRTTO and AddRITO parameters + * * Revision 1.7 2008/06/26 13:39:19 vfrolov * Implemented noise emulation *************** *** 72,75 **** --- 75,79 ---- BOOL SetPin(const char *pNewVal, DWORD bit); BOOL SetProbability(const char *pNewVal, DWORD bit); + BOOL SetUnsigned(const char *pNewVal, DWORD bit); BOOL SetBit(const char *pVal, const Bit &bit); *************** *** 87,90 **** --- 91,96 ---- DWORD pinRI; DWORD emuNoise; + DWORD addRTTO; + DWORD addRITO; char service[20]; Index: params.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/params.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** params.cpp 26 Jun 2008 13:39:19 -0000 1.12 --- params.cpp 17 Sep 2008 07:58:32 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/09/17 07:58:32 vfrolov + * Added AddRTTO and AddRITO parameters + * * Revision 1.12 2008/06/26 13:39:19 vfrolov * Implemented noise emulation *************** *** 79,82 **** --- 82,87 ---- m_pinRI = 0x00000800, m_emuNoise = 0x00010000, + m_addRTTO = 0x00020000, + m_addRITO = 0x00040000, }; /////////////////////////////////////////////////////////////// *************** *** 89,92 **** --- 94,99 ---- FLAG, PIN, + PROBABILITY, + UNSIGNED, } type; } bits[] = { *************** *** 101,105 **** {m_pinDCD, Bit::PIN}, {m_pinRI, Bit::PIN}, ! {m_emuNoise, Bit::OTHER}, }; /////////////////////////////////////////////////////////////// --- 108,114 ---- {m_pinDCD, Bit::PIN}, {m_pinRI, Bit::PIN}, ! {m_emuNoise, Bit::PROBABILITY}, ! {m_addRTTO, Bit::UNSIGNED}, ! {m_addRITO, Bit::UNSIGNED}, }; /////////////////////////////////////////////////////////////// *************** *** 114,118 **** void PortParameters::Init() { ! SNPRINTF(portName, sizeof(portName)/sizeof(portName[0]), "%s", phPortName); emuBR = 0; emuOverrun = 0; --- 123,127 ---- void PortParameters::Init() { ! portName[0] = 0; emuBR = 0; emuOverrun = 0; *************** *** 127,130 **** --- 136,141 ---- emuNoise = 0; + addRTTO = 0; + addRITO = 0; maskChanged = 0; *************** *** 134,150 **** BOOL PortParameters::SetPortName(const char *pNewPortName) { - if (lstrcmpi(pNewPortName, "-")) { - if ((maskExplicit & m_portName) == 0) { - maskExplicit |= m_portName; - maskChanged |= m_portName; - } - } else { - pNewPortName = phPortName; - if (maskExplicit & m_portName) { - maskExplicit &= ~m_portName; - maskChanged |= m_portName; - } - } - if (lstrcmpi(portName, pNewPortName)) { SNPRINTF(portName, sizeof(portName)/sizeof(portName[0]), "%s", pNewPortName); --- 145,148 ---- *************** *** 168,171 **** --- 166,171 ---- case m_pinRI: return &pinRI; case m_emuNoise: return &emuNoise; + case m_addRTTO: return &addRTTO; + case m_addRITO: return &addRITO; } *************** *** 185,188 **** --- 185,190 ---- static const DWORD pinRI = C0C_DEFAULT_PIN_RI; static const DWORD emuNoise = C0C_DEFAULT_EMUNOISE; + static const DWORD addRTTO = C0C_DEFAULT_ADDRTTO; + static const DWORD addRITO = C0C_DEFAULT_ADDRITO; switch (bit) { *************** *** 197,200 **** --- 199,204 ---- case m_pinRI: return &pinRI; case m_emuNoise: return &emuNoise; + case m_addRTTO: return &addRTTO; + case m_addRITO: return &addRITO; } *************** *** 216,219 **** --- 220,225 ---- case m_pinRI: return "ri"; case m_emuNoise: return "EmuNoise"; + case m_addRTTO: return "AddRTTO"; + case m_addRITO: return "AddRITO"; } *************** *** 232,239 **** newFlag = 0; } - else - if (!lstrcmpi(pNewVal, "-")) { - newFlag = 0; - } else { Trace("Invalid value '%s'\n", pNewVal); --- 238,241 ---- *************** *** 246,261 **** return FALSE; - if (lstrcmpi("-", pNewVal)) { - if ((maskExplicit & bit) == 0) { - maskExplicit |= bit; - maskChanged |= bit; - } - } else { - if (maskExplicit & bit) { - maskExplicit &= ~bit; - maskChanged |= bit; - } - } - if (*pFlag != newFlag) { *pFlag = newFlag; --- 248,251 ---- *************** *** 320,326 **** newPin |= C0C_PIN_ON; } - else - if (!lstrcmpi(pNewVal, "-") && newPin == 0) { - } else { Trace("Invalid value '%s'\n", pNewVal); --- 310,313 ---- *************** *** 333,348 **** return FALSE; - if (lstrcmpi("-", pNewVal)) { - if ((maskExplicit & bit) == 0) { - maskExplicit |= bit; - maskChanged |= bit; - } - } else { - if (maskExplicit & bit) { - maskExplicit &= ~bit; - maskChanged |= bit; - } - } - if (*pPin != newPin) { *pPin = newPin; --- 320,323 ---- *************** *** 357,363 **** DWORD newVal = 0; - if (!lstrcmpi(pNewVal, "-")) { - } - else if (pNewVal[0] == '0' && pNewVal[1] == '.') { const char *p = pNewVal + 2; --- 332,335 ---- *************** *** 398,413 **** return FALSE; ! if (lstrcmpi("-", pNewVal)) { ! if ((maskExplicit & bit) == 0) { ! maskExplicit |= bit; ! maskChanged |= bit; ! } ! } else { ! if (maskExplicit & bit) { ! maskExplicit &= ~bit; ! maskChanged |= bit; } } if (*pVal != newVal) { *pVal = newVal; --- 370,398 ---- return FALSE; ! if (*pVal != newVal) { ! *pVal = newVal; ! maskChanged |= bit; ! } ! ! return TRUE; ! } ! /////////////////////////////////////////////////////////////// ! BOOL PortParameters::SetUnsigned(const char *pNewVal, DWORD bit) ! { ! DWORD newVal = 0; ! ! for (const char *p = pNewVal ; *p ; p++) { ! if (*p < '0' || *p > '9') { ! Trace("Invalid value '%s'\n", pNewVal); ! return FALSE; } + newVal = newVal*10 + (*p - '0'); } + DWORD *pVal = GetDwPtr(bit); + + if (pVal == NULL) + return FALSE; + if (*pVal != newVal) { *pVal = newVal; *************** *** 423,442 **** return TRUE; if (bit.type == Bit::FLAG) { ! return SetFlag(pVal, bit.bit); } else if (bit.type == Bit::PIN) { ! return SetPin(pVal, bit.bit); } else if (bit.type == Bit::OTHER) { ! if (bit.bit == m_portName) ! return SetPortName(pVal); ! if (bit.bit == m_emuNoise) ! return SetProbability(pVal, bit.bit); } ! return FALSE; } /////////////////////////////////////////////////////////////// --- 408,458 ---- return TRUE; + if (!lstrcmpi("-", pVal)) { + if (maskExplicit & bit.bit) { + maskExplicit &= ~bit.bit; + maskChanged |= bit.bit; + } + return TRUE; + } + if (bit.type == Bit::FLAG) { ! if (!SetFlag(pVal, bit.bit)) ! return FALSE; } else if (bit.type == Bit::PIN) { ! if (!SetPin(pVal, bit.bit)) ! return FALSE; ! } ! else ! if (bit.type == Bit::PROBABILITY) { ! if (!SetProbability(pVal, bit.bit)) ! return FALSE; ! } ! else ! if (bit.type == Bit::UNSIGNED) { ! if (!SetUnsigned(pVal, bit.bit)) ! return FALSE; } else if (bit.type == Bit::OTHER) { ! if (bit.bit == m_portName) { ! if (!SetPortName(pVal)) ! return FALSE; ! } ! else { ! return FALSE; ! } ! } ! else { ! return FALSE; } ! if ((maskExplicit & bit.bit) == 0) { ! maskExplicit |= bit.bit; ! maskChanged |= bit.bit; ! } ! ! return TRUE; } /////////////////////////////////////////////////////////////// *************** *** 759,764 **** len = SNPRINTF(pParameters, size, ",%s=%s%s", pName, (*pBit & C0C_PIN_NEGATIVE) == 0 ? "" : "!", pVal); } ! else { ! if (bit == m_emuNoise) { if (*pBit == 0) { len = SNPRINTF(pParameters, size, ",%s=0", pName); --- 775,780 ---- len = SNPRINTF(pParameters, size, ",%s=%s%s", pName, (*pBit & C0C_PIN_NEGATIVE) == 0 ? "" : "!", pVal); } ! else ! if (bits[i].type == Bit::PROBABILITY) { if (*pBit == 0) { len = SNPRINTF(pParameters, size, ",%s=0", pName); *************** *** 797,801 **** len = SNPRINTF(pParameters, size, ",%s=0.%s", pName, strVal); } ! } } --- 813,820 ---- len = SNPRINTF(pParameters, size, ",%s=0.%s", pName, strVal); } ! } ! else ! if (bits[i].type == Bit::UNSIGNED) { ! len = SNPRINTF(pParameters, size, ",%s=%lu", pName, (unsigned long)*pBit); } *************** *** 838,841 **** --- 857,865 ---- " character frame in the direction to the paired port\n" " (0 by default)\n" + " AddRTTO=<n> - add <n> milliseconds to the total time-out period\n" + " for read operations (0 by default)\n" + " AddRITO=<n> - add <n> milliseconds to the ìaximum time allowed to\n" + " elapse between the arrival of two characters for\n" + " read operations (0 by default)\n" " PlugInMode={yes|no} - enable/disable plug-in mode, the plug-in mode port\n" " is hidden and can't be open if the paired port is\n" |
From: Vyacheslav F. <vf...@us...> - 2008-09-17 00:59:12
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10895/sys Modified Files: adddev.c com0com.h timeout.c Log Message: Added AddRTTO and AddRITO parameters Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** adddev.c 26 Jun 2008 13:37:10 -0000 1.34 --- adddev.c 17 Sep 2008 07:58:32 -0000 1.35 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.35 2008/09/17 07:58:32 vfrolov + * Added AddRTTO and AddRITO parameters + * * Revision 1.34 2008/06/26 13:37:10 vfrolov * Implemented noise emulation *************** *** 194,197 **** --- 197,201 ---- ULONG emuBR, emuOverrun, plugInMode, exclusiveMode, hiddenMode; ULONG brokeCharsProbability; + ULONG addRTTO, addRITO; ULONG pinCTS, pinDSR, pinDCD, pinRI; UNICODE_STRING ntDeviceName; *************** *** 277,283 **** pinRI = C0C_DEFAULT_PIN_RI; brokeCharsProbability = C0C_DEFAULT_EMUNOISE; if (NT_SUCCESS(status)) { ! RTL_QUERY_REGISTRY_TABLE queryTable[11]; int i; --- 281,289 ---- pinRI = C0C_DEFAULT_PIN_RI; brokeCharsProbability = C0C_DEFAULT_EMUNOISE; + addRTTO = C0C_DEFAULT_ADDRTTO; + addRITO = C0C_DEFAULT_ADDRITO; if (NT_SUCCESS(status)) { ! RTL_QUERY_REGISTRY_TABLE queryTable[13]; int i; *************** *** 340,343 **** --- 346,359 ---- queryTable[i].DefaultData = &brokeCharsProbability; + i++; + queryTable[i].Name = L"AddRTTO"; + queryTable[i].EntryContext = &addRTTO; + queryTable[i].DefaultData = &addRTTO; + + i++; + queryTable[i].Name = L"AddRITO"; + queryTable[i].EntryContext = &addRITO; + queryTable[i].DefaultData = &addRITO; + RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE, *************** *** 418,421 **** --- 434,451 ---- SetHiddenMode(pDevExt, hiddenMode); + pDevExt->pIoPortLocal->addRTTO = addRTTO; + + #if DBG + if (addRTTO) + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Enabled ReadTotalTimeoutConstant increase"); + #endif /* DBG */ + + pDevExt->pIoPortLocal->addRITO = addRITO; + + #if DBG + if (addRITO) + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Enabled ReadIntervalTimeout increase"); + #endif /* DBG */ + AllocTimeouts(pDevExt->pIoPortLocal); Index: timeout.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/timeout.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** timeout.c 14 Mar 2008 15:28:39 -0000 1.10 --- timeout.c 17 Sep 2008 07:58:32 -0000 1.11 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.11 2008/09/17 07:58:32 vfrolov + * Added AddRTTO and AddRITO parameters + * * Revision 1.10 2008/03/14 15:28:39 vfrolov * Implemented ability to get paired port settings with *************** *** 52,56 **** * Initial revision * - * */ --- 55,58 ---- *************** *** 155,159 **** pIoPort->timeoutInterval.QuadPart = ! ((LONGLONG)timeouts.ReadIntervalTimeout) * -10000; if (pIrp->IoStatus.Information) --- 157,161 ---- pIoPort->timeoutInterval.QuadPart = ! ((LONGLONG)timeouts.ReadIntervalTimeout + pIoPort->addRITO) * -10000; if (pIrp->IoStatus.Information) *************** *** 168,172 **** length = IoGetCurrentIrpStackLocation(pIrp)->Parameters.Read.Length; ! total.QuadPart = ((LONGLONG)(UInt32x32To64(length, multiplier) + constant)) * -10000; KeSetTimer( --- 170,175 ---- length = IoGetCurrentIrpStackLocation(pIrp)->Parameters.Read.Length; ! total.QuadPart = ((LONGLONG)( ! UInt32x32To64(length, multiplier) + constant + pIoPort->addRTTO)) * -10000; KeSetTimer( Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** com0com.h 11 Jul 2008 10:38:00 -0000 1.45 --- com0com.h 17 Sep 2008 07:58:32 -0000 1.46 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.46 2008/09/17 07:58:32 vfrolov + * Added AddRTTO and AddRITO parameters + * * Revision 1.45 2008/07/11 10:38:00 vfrolov * Added nonstandard ability to enable LSR insertion on BREAK OFF *************** *** 280,287 **** --- 283,292 ---- KTIMER timerReadTotal; KDPC timerReadTotalDpc; + ULONG addRTTO; KTIMER timerReadInterval; KDPC timerReadIntervalDpc; LARGE_INTEGER timeoutInterval; + ULONG addRITO; KTIMER timerWriteTotal; |
From: Vyacheslav F. <vf...@us...> - 2008-09-17 00:59:12
|
Update of /cvsroot/com0com/com0com/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10895/include Modified Files: com0com.h Log Message: Added AddRTTO and AddRITO parameters Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/include/com0com.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** com0com.h 26 Jun 2008 13:31:54 -0000 1.9 --- com0com.h 17 Sep 2008 07:58:32 -0000 1.10 *************** *** 18,50 **** * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * $Log$ - * Revision 1.9 2008/06/26 13:31:54 vfrolov - * Implemented noise emulation - * - * Revision 1.8 2008/05/04 09:44:05 vfrolov - * Added C0C_DEFAULT_HIDDENMODE - * - * Revision 1.7 2008/04/08 06:44:35 vfrolov - * Added pin OUT2 - * - * Revision 1.6 2007/10/19 15:58:18 vfrolov - * Added default values - * - * Revision 1.5 2007/09/17 14:28:07 vfrolov - * Implemented pseudo pin OPEN - * - * Revision 1.4 2007/07/03 14:25:12 vfrolov - * Implemented pinout customization - * - * Revision 1.3 2006/11/03 13:06:33 vfrolov - * Moved C0C_PORT_NAME_LEN from sys/com0com.h to include/com0com.h - * - * Revision 1.2 2006/11/02 15:56:38 vfrolov - * Defined C0C_REGSTR_VAL_PORT_NUM - * - * Revision 1.1 2006/10/13 10:06:13 vfrolov - * Initial revision - * */ --- 18,21 ---- *************** *** 90,93 **** --- 61,66 ---- #define C0C_DEFAULT_HIDDENMODE 0x00000000 #define C0C_DEFAULT_EMUNOISE 0x00000000 + #define C0C_DEFAULT_ADDRTTO 0x00000000 + #define C0C_DEFAULT_ADDRITO 0x00000000 #define C0C_PROBABILITY_ONE 100000000 |
From: Vyacheslav F. <vf...@us...> - 2008-09-12 12:29:57
|
Update of /cvsroot/com0com/com0com/NSIS In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15144 Modified Files: install.nsi Log Message: Added --silent option Index: install.nsi =================================================================== RCS file: /cvsroot/com0com/com0com/NSIS/install.nsi,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** install.nsi 30 Nov 2007 09:53:37 -0000 1.12 --- install.nsi 12 Sep 2008 12:29:53 -0000 1.13 *************** *** 2,6 **** * $Id$ * ! * Copyright (c) 2006-2007 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify --- 2,6 ---- * $Id$ * ! * Copyright (c) 2006-2008 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/09/12 12:29:53 vfrolov + * Added --silent option + * * Revision 1.12 2007/11/30 09:53:37 vfrolov * Added license page *************** *** 259,263 **** GetTempFileName $0 ! ExecWait "setupc.exe --output $0 install 0 - -" !insertmacro MoveFileToDetails $0 --- 262,271 ---- GetTempFileName $0 ! ! StrCpy $1 "" ! IfSilent 0 +2 ! StrCpy $1 "--silent" ! ! ExecWait "setupc.exe $1 --output $0 install 0 - -" !insertmacro MoveFileToDetails $0 *************** *** 274,278 **** GetTempFileName $0 ! ExecWait "setupc.exe --output $0 uninstall" !insertmacro MoveFileToDetails $0 --- 282,291 ---- GetTempFileName $0 ! ! StrCpy $1 "" ! IfSilent 0 +2 ! StrCpy $1 "--silent" ! ! ExecWait "setupc.exe $1 --output $0 uninstall" !insertmacro MoveFileToDetails $0 |
From: Vyacheslav F. <vf...@us...> - 2008-09-12 12:21:52
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12216 Modified Files: setup.cpp Log Message: Added --silent option Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** setup.cpp 12 Sep 2008 09:55:59 -0000 1.24 --- setup.cpp 12 Sep 2008 12:21:49 -0000 1.25 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.25 2008/09/12 12:21:49 vfrolov + * Added --silent option + * * Revision 1.24 2008/09/12 09:55:59 vfrolov * Fixed help cutting *************** *** 124,127 **** --- 127,131 ---- /////////////////////////////////////////////////////////////// static BOOL detailPrms = FALSE; + static BOOL silent = FALSE; /////////////////////////////////////////////////////////////// static BOOL IsValidPortNum(int num) *************** *** 782,786 **** if (QueryServiceStatus(hSrv, &srvStatus)) { if (srvStatus.dwCurrentState == SERVICE_STOPPED) { ! if (ShowMsg(MB_YESNO, "The deleting %s service will remove your manual settings.\n" "Would you like to delete service?\n", --- 786,791 ---- if (QueryServiceStatus(hSrv, &srvStatus)) { if (srvStatus.dwCurrentState == SERVICE_STOPPED) { ! if (silent || ! ShowMsg(MB_YESNO, "The deleting %s service will remove your manual settings.\n" "Would you like to delete service?\n", *************** *** 957,960 **** --- 962,966 ---- " --output <file> - file for output, default is console\n" " --detail-prms - show detailed parameters\n" + " --silent - suppress dialogs if possible\n" ); ConsoleWrite( *************** *** 1056,1059 **** --- 1062,1071 ---- argc--; } + else + if (!strcmp(argv[1], "--silent")) { + silent = TRUE; + argv++; + argc--; + } else { ConsoleWrite("Invalid option %s\n", argv[1]); |
From: Vyacheslav F. <vf...@us...> - 2008-09-12 10:07:53
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27437 Modified Files: bufutils.c ioctl.c Log Message: Fixed LSR insertion Index: bufutils.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/bufutils.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** bufutils.c 2 Sep 2008 07:36:22 -0000 1.14 --- bufutils.c 12 Sep 2008 10:07:50 -0000 1.15 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.15 2008/09/12 10:07:50 vfrolov + * Fixed LSR insertion + * * Revision 1.14 2008/09/02 07:36:22 vfrolov * Added missing SERIAL_EV_BREAK *************** *** 235,239 **** if (pIoPort->escapeChar && ! (pIoPort->insertMask & (C0CE_INSERT_ENABLE_LSR|C0CE_INSERT_ENABLE_LSR_BI))) { UCHAR buf[4]; --- 238,243 ---- if (pIoPort->escapeChar && ! ((pIoPort->insertMask & C0CE_INSERT_ENABLE_LSR) != 0 || ! (isBreak && (pIoPort->insertMask & C0CE_INSERT_ENABLE_LSR_BI) != 0))) { UCHAR buf[4]; *************** *** 250,255 **** } ! if (pIoPortRemote->writeHolding & SERIAL_TX_WAITING_ON_BREAK && !pIoPortRemote->sendBreak) lsr |= 0x10; /* break interrupt indicator */ buf[0] = pIoPort->escapeChar; --- 254,263 ---- } ! if ((pIoPort->insertMask & C0CE_INSERT_ENABLE_LSR_BI) != 0 && ! (pIoPortRemote->writeHolding & SERIAL_TX_WAITING_ON_BREAK) != 0 && ! !pIoPortRemote->sendBreak) ! { lsr |= 0x10; /* break interrupt indicator */ + } buf[0] = pIoPort->escapeChar; Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/ioctl.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** ioctl.c 19 Aug 2008 12:40:58 -0000 1.38 --- ioctl.c 12 Sep 2008 10:07:50 -0000 1.39 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.39 2008/09/12 10:07:50 vfrolov + * Fixed LSR insertion + * * Revision 1.38 2008/08/19 12:40:58 vfrolov * Replaces C0CE_INSERT_ENABLE_LSR_NBI (insertion on BREAK OFF) *************** *** 715,720 **** } ! if (pIoPortRemote->writeHolding & SERIAL_TX_WAITING_ON_BREAK && !pIoPortRemote->sendBreak) lsr |= 0x10; /* break interrupt indicator */ *pSysBuf++ = escapeChar; --- 718,727 ---- } ! if ((optsAndBits & C0CE_INSERT_ENABLE_LSR_BI) != 0 && ! (pIoPortRemote->writeHolding & SERIAL_TX_WAITING_ON_BREAK) != 0 && ! !pIoPortRemote->sendBreak) ! { lsr |= 0x10; /* break interrupt indicator */ + } *pSysBuf++ = escapeChar; |
From: Vyacheslav F. <vf...@us...> - 2008-09-12 09:56:04
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22990 Modified Files: setup.cpp Log Message: Fixed help cutting Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** setup.cpp 2 Apr 2008 10:28:24 -0000 1.23 --- setup.cpp 12 Sep 2008 09:55:59 -0000 1.24 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.24 2008/09/12 09:55:59 vfrolov + * Fixed help cutting + * * Revision 1.23 2008/04/02 10:28:24 vfrolov * Added reload command *************** *** 968,971 **** --- 971,976 ---- " disable all - disable all ports in current hardware profile\n" " enable all - enable all ports in current hardware profile\n" + ); + ConsoleWrite( " change <portid> <prms> - set parameters <prms> for port with\n" " identifier <portid>\n" |
From: Vyacheslav F. <vf...@us...> - 2008-09-02 07:37:37
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11128 Modified Files: noise.c Log Message: Fixed bits in BreakError() Index: noise.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/noise.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** noise.c 1 Sep 2008 16:45:12 -0000 1.2 --- noise.c 2 Sep 2008 07:37:34 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/09/02 07:37:34 vfrolov + * Fixed bits in BreakError() + * * Revision 1.2 2008/09/01 16:45:12 vfrolov * Fixed bits in BreakError() *************** *** 55,64 **** { *pLsr |= 0x18; /* break interrupt indicator & framing error */ ! pReadIoPort->errors |= (SERIAL_ERROR_BREAK | SERIAL_ERROR_FRAMING); ! if (pReadIoPort->lineControl.Parity == ODD_PARITY || pReadIoPort->lineControl.Parity == MARK_PARITY) { *pLsr |= 0x04; /* parity error */ - pReadIoPort->errors |= SERIAL_ERROR_PARITY; - } } /********************************************************************/ --- 58,65 ---- { *pLsr |= 0x18; /* break interrupt indicator & framing error */ ! pReadIoPort->errors |= SERIAL_ERROR_BREAK; ! if (pReadIoPort->lineControl.Parity == ODD_PARITY || pReadIoPort->lineControl.Parity == MARK_PARITY) *pLsr |= 0x04; /* parity error */ } /********************************************************************/ |
From: Vyacheslav F. <vf...@us...> - 2008-09-02 07:36:25
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10729 Modified Files: bufutils.c Log Message: Added missing SERIAL_EV_BREAK Index: bufutils.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/bufutils.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** bufutils.c 1 Sep 2008 16:54:28 -0000 1.13 --- bufutils.c 2 Sep 2008 07:36:22 -0000 1.14 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.14 2008/09/02 07:36:22 vfrolov + * Added missing SERIAL_EV_BREAK + * * Revision 1.13 2008/09/01 16:54:28 vfrolov * Replaced SERIAL_LSRMST_LSR_NODATA by SERIAL_LSRMST_LSR_DATA for BREAK *************** *** 210,213 **** --- 213,217 ---- pIoPortRemote->sendBreak = FALSE; BreakError(pIoPort, &lsr); + pFlowFilter->events |= SERIAL_EV_BREAK; } else { if (pIoPortRemote->brokeCharsProbability > 0) |
From: Vyacheslav F. <vf...@us...> - 2008-09-01 16:54:32
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16340 Modified Files: bufutils.c io.c Log Message: Replaced SERIAL_LSRMST_LSR_NODATA by SERIAL_LSRMST_LSR_DATA for BREAK Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/io.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** io.c 19 Aug 2008 12:40:58 -0000 1.39 --- io.c 1 Sep 2008 16:54:28 -0000 1.40 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.40 2008/09/01 16:54:28 vfrolov + * Replaced SERIAL_LSRMST_LSR_NODATA by SERIAL_LSRMST_LSR_DATA for BREAK + * * Revision 1.39 2008/08/19 12:40:58 vfrolov * Replaces C0CE_INSERT_ENABLE_LSR_NBI (insertion on BREAK OFF) *************** *** 944,969 **** } - VOID InsertChar( - PC0C_IO_PORT pIoPortRead, - UCHAR value, - PLIST_ENTRY pQueueToComplete) - { - C0C_RAW_DATA insertData; - - insertData.size = 1; - insertData.data[0] = value; - - if (FdoPortIo( - C0C_IO_TYPE_INSERT, - &insertData, - pIoPortRead, - &pIoPortRead->irpQueues[C0C_QUEUE_READ], - pQueueToComplete) == STATUS_PENDING) - { - AlertOverrun(pIoPortRead, pQueueToComplete); - Trace0((PC0C_COMMON_EXTENSION)pIoPortRead->pDevExt, L"WARNING: Lost char"); - } - } - VOID InsertRemoteBr( PC0C_IO_PORT pIoPortRead, --- 947,950 ---- *************** *** 1392,1424 **** pIoPortWrite->sendXonXoff = 0; break; - case RW_DATA_TYPE_CHR_BREAK: - if (pIoPortWrite->sendBreak) { - pIoPortWrite->sendBreak = FALSE; - - pIoPortRead->errors |= SERIAL_ERROR_BREAK; - pIoPortRead->eventMask |= pIoPortRead->waitMask & (SERIAL_EV_BREAK | SERIAL_EV_ERR); - - if (pIoPortRead->eventMask) - WaitComplete(pIoPortRead, pQueueToComplete); - - if (pIoPortRead->escapeChar && - (pIoPortRead->insertMask & (C0CE_INSERT_ENABLE_LSR|C0CE_INSERT_ENABLE_LSR_BI))) - { - UCHAR lsr = 0x10; /* break interrupt indicator */ - - if (C0C_TX_BUFFER_THR_EMPTY(&pIoPortRead->txBuf)) { - lsr |= 0x20; /* transmit holding register empty */ - - if (C0C_TX_BUFFER_EMPTY(&pIoPortRead->txBuf)) - lsr |= 0x40; /* transmit holding register empty and line is idle */ - } - - InsertLsrMst(pIoPortRead, FALSE, lsr, pQueueToComplete); - } - - if (pIoPortRead->handFlow.FlowReplace & SERIAL_BREAK_CHAR) - InsertChar(pIoPortRead, pIoPortRead->specialChars.BreakChar, pQueueToComplete); - } - break; } } --- 1373,1376 ---- Index: bufutils.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/bufutils.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** bufutils.c 11 Jul 2008 10:30:39 -0000 1.12 --- bufutils.c 1 Sep 2008 16:54:28 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.13 2008/09/01 16:54:28 vfrolov + * Replaced SERIAL_LSRMST_LSR_NODATA by SERIAL_LSRMST_LSR_DATA for BREAK + * * Revision 1.12 2008/07/11 10:30:39 vfrolov * Added missing data available bit to LSR *************** *** 68,71 **** --- 71,75 ---- #include "bufutils.h" #include "noise.h" + #include "../include/cncext.h" /* *************** *** 190,197 **** } } - else - if (pFlowFilter->flags & C0C_FLOW_FILTER_FL_IGNORE_RECEIVED) { - writeDone = writeLength; - } else { PC0C_IO_PORT pIoPort = pFlowFilter->pIoPort; --- 194,197 ---- *************** *** 207,212 **** curChar = *pWriteBuf++; ! if (pIoPortRemote->brokeCharsProbability > 0) ! BrokeChar(pIoPortRemote, pIoPort, &curChar, &lsr); } else { if (pIoPortRemote->writeHolding & SERIAL_TX_WAITING_ON_BREAK && !pIoPortRemote->sendBreak) { --- 207,217 ---- curChar = *pWriteBuf++; ! if (pIoPortRemote->sendBreak) { ! pIoPortRemote->sendBreak = FALSE; ! BreakError(pIoPort, &lsr); ! } else { ! if (pIoPortRemote->brokeCharsProbability > 0) ! BrokeChar(pIoPortRemote, pIoPort, &curChar, &lsr); ! } } else { if (pIoPortRemote->writeHolding & SERIAL_TX_WAITING_ON_BREAK && !pIoPortRemote->sendBreak) { *************** *** 221,244 **** if (lsr) { pFlowFilter->events |= SERIAL_EV_ERR; ! if (pIoPort->handFlow.FlowReplace & SERIAL_ERROR_CHAR) { ! UCHAR errorChar = pIoPort->specialChars.ErrorChar; ! ! if (!readLength--) { ! #if DBG ! SIZE_T done = ! #endif /* DBG */ ! AddRawData(&pBuf->insertData, &errorChar, sizeof(errorChar)); ! HALT_UNLESS1(done == sizeof(errorChar), done); ! ! readLength++; ! } else { ! *pReadBuf++ = errorChar; ! readDone++; ! } ! } ! ! if (pIoPort->escapeChar) { UCHAR buf[4]; SIZE_T length = sizeof(buf); --- 226,236 ---- if (lsr) { + BOOLEAN noCurChar = FALSE; + BOOLEAN isBreak = ((lsr & 0x10) != 0); pFlowFilter->events |= SERIAL_EV_ERR; ! if (pIoPort->escapeChar && ! (pIoPort->insertMask & (C0CE_INSERT_ENABLE_LSR|C0CE_INSERT_ENABLE_LSR_BI))) ! { UCHAR buf[4]; SIZE_T length = sizeof(buf); *************** *** 263,266 **** --- 255,259 ---- writeDone++; + noCurChar = TRUE; if (length > readLength) *************** *** 286,294 **** break; } ! continue; } } if (!curChar && (pFlowFilter->flags & C0C_FLOW_FILTER_FL_NULL_STRIPPING)) { } --- 279,327 ---- break; } + } ! if (isBreak) { ! if (pIoPort->handFlow.FlowReplace & SERIAL_BREAK_CHAR) { ! UCHAR errorChar = pIoPort->specialChars.BreakChar; ! ! if (!readLength--) { ! #if DBG ! SIZE_T done = ! #endif /* DBG */ ! AddRawData(&pBuf->insertData, &errorChar, sizeof(errorChar)); ! HALT_UNLESS1(done == sizeof(errorChar), done); ! ! readLength++; ! } else { ! *pReadBuf++ = errorChar; ! readDone++; ! } ! } } + else + if (pIoPort->handFlow.FlowReplace & SERIAL_ERROR_CHAR) { + UCHAR errorChar = pIoPort->specialChars.ErrorChar; + + if (!readLength--) { + #if DBG + SIZE_T done = + #endif /* DBG */ + AddRawData(&pBuf->insertData, &errorChar, sizeof(errorChar)); + HALT_UNLESS1(done == sizeof(errorChar), done); + + readLength++; + } else { + *pReadBuf++ = errorChar; + readDone++; + } + } + + if (noCurChar) + continue; } + if (pFlowFilter->flags & C0C_FLOW_FILTER_FL_IGNORE_RECEIVED) { + } + else if (!curChar && (pFlowFilter->flags & C0C_FLOW_FILTER_FL_NULL_STRIPPING)) { } |
From: Vyacheslav F. <vf...@us...> - 2008-09-01 16:45:18
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12980 Modified Files: noise.c Log Message: Fixed bits in BreakError() Index: noise.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/noise.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** noise.c 26 Jun 2008 13:37:10 -0000 1.1 --- noise.c 1 Sep 2008 16:45:12 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/09/01 16:45:12 vfrolov + * Fixed bits in BreakError() + * * Revision 1.1 2008/06/26 13:37:10 vfrolov * Implemented noise emulation *************** *** 51,56 **** VOID BreakError(PC0C_IO_PORT pReadIoPort, PUCHAR pLsr) { ! *pLsr |= 0x10; /* break interrupt indicator */ ! pReadIoPort->errors |= SERIAL_ERROR_BREAK; } /********************************************************************/ --- 54,64 ---- VOID BreakError(PC0C_IO_PORT pReadIoPort, PUCHAR pLsr) { ! *pLsr |= 0x18; /* break interrupt indicator & framing error */ ! pReadIoPort->errors |= (SERIAL_ERROR_BREAK | SERIAL_ERROR_FRAMING); ! ! if (pReadIoPort->lineControl.Parity == ODD_PARITY || pReadIoPort->lineControl.Parity == MARK_PARITY) { ! *pLsr |= 0x04; /* parity error */ ! pReadIoPort->errors |= SERIAL_ERROR_PARITY; ! } } /********************************************************************/ |
From: Vyacheslav F. <vf...@us...> - 2008-08-29 15:17:12
|
Update of /cvsroot/com0com/hub4com/plugins/trace In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14204 Modified Files: filter.cpp precomp.h Log Message: Added printing command line and config Index: precomp.h =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/trace/precomp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** precomp.h 29 Aug 2008 13:13:04 -0000 1.1 --- precomp.h 29 Aug 2008 15:17:07 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/08/29 15:17:07 vfrolov + * Added printing command line and config + * * Revision 1.1 2008/08/29 13:13:04 vfrolov * Initial revision *************** *** 35,38 **** --- 38,42 ---- #include <sstream> #include <iomanip> + #include <set> using namespace std; Index: filter.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/trace/filter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** filter.cpp 29 Aug 2008 13:13:04 -0000 1.1 --- filter.cpp 29 Aug 2008 15:17:07 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2008/08/29 15:17:07 vfrolov + * Added printing command line and config + * * Revision 1.1 2008/08/29 13:13:04 vfrolov * Initial revision *************** *** 38,41 **** --- 41,46 ---- static ROUTINE_FILTER_NAME_A *pFilterName = NULL; /////////////////////////////////////////////////////////////// + static void PrintTime(ostream &tout); + /////////////////////////////////////////////////////////////// const char *GetParam(const char *pArg, const char *pPattern) { *************** *** 50,61 **** class TraceConfig { public: ! TraceConfig() : pTraceStream(&cout) {} void SetTracePath(const char *pPath); ostream *GetTraceStream(); private: string path; ostream *pTraceStream; }; --- 55,72 ---- class TraceConfig { public: ! TraceConfig() : pTraceStream(NULL) {} void SetTracePath(const char *pPath); ostream *GetTraceStream(); + void PrintToAllTraceStreams(const char *pStr); + stringstream buf; private: string path; ostream *pTraceStream; + + typedef set<ostream*> Streams; + + Streams traceStreams; }; *************** *** 69,85 **** return pTraceStream; ! ofstream *pStream = new ofstream(path.c_str()); ! if (!pStream) { ! cerr << "No enough memory." << endl; ! exit(2); ! } ! if (!pStream->is_open()) { ! cerr << "Can't open " << path.c_str() << endl; ! exit(2); } ! return pTraceStream = pStream; } /////////////////////////////////////////////////////////////// --- 80,110 ---- return pTraceStream; ! if (path.empty()) { ! pTraceStream = &cout; ! } else { ! ofstream *pStream = new ofstream(path.c_str()); ! if (!pStream) { ! cerr << "No enough memory." << endl; ! exit(2); ! } ! if (!pStream->is_open()) { ! cerr << "Can't open " << path.c_str() << endl; ! exit(2); ! } ! ! pTraceStream = pStream; } ! traceStreams.insert(pTraceStream); ! ! return pTraceStream; ! } ! ! void TraceConfig::PrintToAllTraceStreams(const char *pStr) ! { ! for (Streams::const_iterator iS = traceStreams.begin() ; iS != traceStreams.end() ; iS++) ! (**iS) << pStr; } /////////////////////////////////////////////////////////////// *************** *** 169,172 **** --- 194,204 ---- } + PrintTime(pConfig->buf); + pConfig->buf << "Command Line:" << endl + << " {" << GetCommandLine() << "}" << endl; + + PrintTime(pConfig->buf); + pConfig->buf << "Config: {"; + return (HCONFIG)pConfig; } *************** *** 178,181 **** --- 210,215 ---- _ASSERTE(hConfig != NULL); + ((TraceConfig *)hConfig)->buf << endl << " {" << pArg << "}"; + const char *pParam; *************** *** 194,197 **** --- 228,234 ---- _ASSERTE(hConfig != NULL); + ((TraceConfig *)hConfig)->buf << endl << "}" << endl; + ((TraceConfig *)hConfig)->PrintToAllTraceStreams(((TraceConfig *)hConfig)->buf.str().c_str()); + delete (TraceConfig *)hConfig; } |
From: Vyacheslav F. <vf...@us...> - 2008-08-29 13:14:42
|
Update of /cvsroot/com0com/hub4com In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32515 Modified Files: hub4com.sln Log Message: Added filter-trace Index: hub4com.sln =================================================================== RCS file: /cvsroot/com0com/hub4com/hub4com.sln,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** hub4com.sln 22 Aug 2008 17:05:54 -0000 1.8 --- hub4com.sln 29 Aug 2008 13:14:36 -0000 1.9 *************** *** 20,23 **** --- 20,25 ---- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filter-escparse", "plugins\escparse\escparse.vcproj", "{B56122ED-F2E6-4FA1-8E85-B8C606ED9400}" EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filter-trace", "plugins\trace\trace.vcproj", "{EDA524BD-8193-49E5-995E-9EE533E2641E}" + EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution *************** *** 62,65 **** --- 64,71 ---- {B56122ED-F2E6-4FA1-8E85-B8C606ED9400}.Release|Win32.ActiveCfg = Release|Win32 {B56122ED-F2E6-4FA1-8E85-B8C606ED9400}.Release|Win32.Build.0 = Release|Win32 + {EDA524BD-8193-49E5-995E-9EE533E2641E}.Debug|Win32.ActiveCfg = Debug|Win32 + {EDA524BD-8193-49E5-995E-9EE533E2641E}.Debug|Win32.Build.0 = Debug|Win32 + {EDA524BD-8193-49E5-995E-9EE533E2641E}.Release|Win32.ActiveCfg = Release|Win32 + {EDA524BD-8193-49E5-995E-9EE533E2641E}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution |
From: Vyacheslav F. <vf...@us...> - 2008-08-29 13:13:07
|
Update of /cvsroot/com0com/hub4com/plugins/trace In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31983 Added Files: .cvsignore filter.cpp precomp.cpp precomp.h trace.vcproj Log Message: Initial revision --- NEW FILE: precomp.cpp --- /* * $Id: precomp.cpp,v 1.1 2008/08/29 13:13:04 vfrolov Exp $ * * Copyright (c) 2007-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 * */ /////////////////////////////////////////////////////////////// #include "precomp.h" /////////////////////////////////////////////////////////////// --- NEW FILE: precomp.h --- /* * $Id: precomp.h,v 1.1 2008/08/29 13:13:04 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/08/29 13:13:04 vfrolov * Initial revision * */ #ifndef _PRECOMP_H_ #define _PRECOMP_H_ #include <windows.h> #include <crtdbg.h> #include <fstream> #include <iostream> #include <sstream> #include <iomanip> using namespace std; #pragma warning(disable:4512) // assignment operator could not be generated #endif /* _PRECOMP_H_ */ --- NEW FILE: trace.vcproj --- <?xml version="1.0" encoding="windows-1251"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="filter-trace" ProjectGUID="{EDA524BD-8193-49E5-995E-9EE533E2641E}" 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: filter.cpp --- /* * $Id: filter.cpp,v 1.1 2008/08/29 13:13:04 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/08/29 13:13:04 vfrolov * Initial revision * */ #include "precomp.h" #include "../plugins_api.h" /////////////////////////////////////////////////////////////// #ifndef _DEBUG #define DEBUG_PARAM(par) #else /* _DEBUG */ #define DEBUG_PARAM(par) par #endif /* _DEBUG */ /////////////////////////////////////////////////////////////// static ROUTINE_PORT_NAME_A *pPortName = NULL; static ROUTINE_FILTER_NAME_A *pFilterName = NULL; /////////////////////////////////////////////////////////////// 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; } /////////////////////////////////////////////////////////////// class TraceConfig { public: TraceConfig() : pTraceStream(&cout) {} void SetTracePath(const char *pPath); ostream *GetTraceStream(); private: string path; ostream *pTraceStream; }; void TraceConfig::SetTracePath(const char *pPath) { path = pPath; pTraceStream = NULL; } ostream *TraceConfig::GetTraceStream() { if (pTraceStream) return pTraceStream; ofstream *pStream = new ofstream(path.c_str()); if (!pStream) { cerr << "No enough memory." << endl; exit(2); } if (!pStream->is_open()) { cerr << "Can't open " << path.c_str() << endl; exit(2); } return pTraceStream = pStream; } /////////////////////////////////////////////////////////////// class Valid { public: Valid() : isValid(TRUE) {} void Invalidate() { isValid = FALSE; } BOOL IsValid() const { return isValid; } private: BOOL isValid; }; /////////////////////////////////////////////////////////////// class Filter : public Valid { public: Filter(TraceConfig &config, int argc, const char *const argv[]); void SetHub(HHUB _hHub) { hHub = _hHub; pName = pFilterName(hHub, (HFILTER)this); } const char *PortName(int nPort) const { return pPortName(hHub, nPort); } const char *FilterName() const { return pName; } ostream *pTraceStream; private: HHUB hHub; const char *pName; }; Filter::Filter(TraceConfig &config, int argc, const char *const argv[]) : pTraceStream(NULL), hHub(NULL), pName(NULL) { 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; } { cerr << "Unknown option --" << pArg << endl; Invalidate(); } } if (!pTraceStream) pTraceStream = config.GetTraceStream(); } /////////////////////////////////////////////////////////////// static PLUGIN_TYPE CALLBACK GetPluginType() { return PLUGIN_TYPE_FILTER; } /////////////////////////////////////////////////////////////// static const PLUGIN_ABOUT_A about = { sizeof(PLUGIN_ABOUT_A), "trace", "Copyright (c) 2008 Vyacheslav Frolov", "GNU General Public License", "Trace 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 << endl << "Examples:" << endl ; } /////////////////////////////////////////////////////////////// static HCONFIG CALLBACK ConfigStart() { TraceConfig *pConfig = new TraceConfig; if (!pConfig) { cerr << "No enough memory." << endl; exit(2); } return (HCONFIG)pConfig; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK Config( HCONFIG hConfig, const char *pArg) { _ASSERTE(hConfig != NULL); const char *pParam; if ((pParam = GetParam(pArg, "--trace-file=")) != NULL) { ((TraceConfig *)hConfig)->SetTracePath(pParam); } else { return FALSE; } return TRUE; } /////////////////////////////////////////////////////////////// static void CALLBACK ConfigStop( HCONFIG hConfig) { _ASSERTE(hConfig != NULL); delete (TraceConfig *)hConfig; } /////////////////////////////////////////////////////////////// static HFILTER CALLBACK Create( HCONFIG hConfig, int argc, const char *const argv[]) { _ASSERTE(hConfig != NULL); Filter *pFilter = new Filter(*(TraceConfig *)hConfig, argc, argv); if (!pFilter) return NULL; if (!pFilter->IsValid()) { delete pFilter; return NULL; } return (HFILTER)pFilter; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK Init( HFILTER hFilter, HHUB hHub) { _ASSERTE(hFilter != NULL); _ASSERTE(hHub != NULL); ((Filter *)hFilter)->SetHub(hHub); return TRUE; } /////////////////////////////////////////////////////////////// static void PrintTime(ostream &tout) { char f = tout.fill('0'); SYSTEMTIME time; ::GetLocalTime(&time); tout << setw(4) << time.wYear << "/" << setw(2) << time.wMonth << "/" << setw(2) << time.wDay << " " << setw(2) << time.wHour << ":" << setw(2) << time.wMinute << ":" << setw(2) << time.wSecond << "." << setw(3) << time.wMilliseconds << " "; tout.fill(f); } /////////////////////////////////////////////////////////////// struct CODE2NAME { DWORD code; const char *name; }; #define TOCODE2NAME(p, s) { (ULONG)p##s, #s } static void PrintCode(ostream &tout, const CODE2NAME *pTable, DWORD code) { if (pTable) { while (pTable->name) { if (pTable->code == code) { tout << pTable->name; return; } pTable++; } } tout << "0x" << hex << code << dec; } /////////////////////////////////////////////////////////////// struct FIELD2NAME { DWORD field; DWORD mask; const char *name; }; #define TOFIELD2NAME2(p, s) { (ULONG)p##s, (ULONG)p##s, #s } static BOOL PrintFields( ostream &tout, const FIELD2NAME *pTable, DWORD fields, BOOL delimitNext = FALSE, const char *pUnknownPrefix = "", const char *pDelimiter = "|") { if (pTable) { while (pTable->name) { DWORD field = (fields & pTable->mask); if (field == pTable->field) { fields &= ~pTable->mask; if (delimitNext) tout << pDelimiter; else delimitNext = TRUE; tout << pTable->name; } pTable++; } } if (fields) { if (delimitNext) tout << pDelimiter; else delimitNext = TRUE; tout << pUnknownPrefix << "0x" << hex << fields << dec; } return delimitNext; } /////////////////////////////////////////////////////////////// static const CODE2NAME codeNameTableHubMsg[] = { TOCODE2NAME(HUB_MSG_TYPE_, EMPTY), TOCODE2NAME(HUB_MSG_TYPE_, LINE_DATA), TOCODE2NAME(HUB_MSG_TYPE_, CONNECT), TOCODE2NAME(HUB_MSG_TYPE_, MODEM_STATUS), TOCODE2NAME(HUB_MSG_TYPE_, LINE_STATUS), TOCODE2NAME(HUB_MSG_TYPE_, SET_PIN_STATE), TOCODE2NAME(HUB_MSG_TYPE_, GET_IN_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, SET_OUT_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, FAIL_IN_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, RBR_STATUS), TOCODE2NAME(HUB_MSG_TYPE_, RLC_STATUS), TOCODE2NAME(HUB_MSG_TYPE_, COUNT_REPEATS), TOCODE2NAME(HUB_MSG_TYPE_, GET_ESC_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, FAIL_ESC_OPTS), TOCODE2NAME(HUB_MSG_TYPE_, BREAK_STATUS), {0, NULL} }; /////////////////////////////////////////////////////////////// static FIELD2NAME fieldNameTableModemStatus[] = { TOFIELD2NAME2(MODEM_STATUS_, DCTS), TOFIELD2NAME2(MODEM_STATUS_, DDSR), TOFIELD2NAME2(MODEM_STATUS_, TERI), TOFIELD2NAME2(MODEM_STATUS_, DDCD), TOFIELD2NAME2(MODEM_STATUS_, CTS), TOFIELD2NAME2(MODEM_STATUS_, DSR), TOFIELD2NAME2(MODEM_STATUS_, RI), TOFIELD2NAME2(MODEM_STATUS_, DCD), {0, 0, NULL} }; /////////////////////////////////////////////////////////////// static FIELD2NAME fieldNameTableLineStatus[] = { TOFIELD2NAME2(LINE_STATUS_, DR), TOFIELD2NAME2(LINE_STATUS_, OE), TOFIELD2NAME2(LINE_STATUS_, PE), TOFIELD2NAME2(LINE_STATUS_, FE), TOFIELD2NAME2(LINE_STATUS_, BI), TOFIELD2NAME2(LINE_STATUS_, THRE), TOFIELD2NAME2(LINE_STATUS_, TEMT), TOFIELD2NAME2(LINE_STATUS_, FIFOERR), {0, 0, NULL} }; /////////////////////////////////////////////////////////////// static FIELD2NAME fieldNameTableGoOptions[] = { TOFIELD2NAME2(GO_, RBR_STATUS), TOFIELD2NAME2(GO_, RLC_STATUS), TOFIELD2NAME2(GO_, BREAK_STATUS), TOFIELD2NAME2(GO_, ESCAPE_MODE), {0, 0, NULL} }; /////////////////////////////////////////////////////////////// static FIELD2NAME codeNameTableSetPinState[] = { TOFIELD2NAME2(PIN_STATE_, RTS), TOFIELD2NAME2(PIN_STATE_, DTR), TOFIELD2NAME2(PIN_STATE_, OUT1), TOFIELD2NAME2(PIN_STATE_, OUT2), TOFIELD2NAME2(PIN_STATE_, BREAK), {0, 0, NULL} }; /////////////////////////////////////////////////////////////// static BOOL PrintGoOptions( ostream &tout, DWORD fields, BOOL delimitNext = FALSE, const char *pUnknownPrefix = "") { delimitNext = PrintFields(tout, fieldNameTableModemStatus, GO_O2V_MODEM_STATUS(fields), delimitNext, "MST_"); delimitNext = PrintFields(tout, fieldNameTableLineStatus, GO_O2V_LINE_STATUS(fields), delimitNext, "LSR_"); delimitNext = PrintFields(tout, fieldNameTableGoOptions, fields & ~(GO_V2O_MODEM_STATUS(-1) | GO_V2O_LINE_STATUS(-1)), delimitNext, pUnknownPrefix); return delimitNext; } /////////////////////////////////////////////////////////////// static BOOL PrintEscOptions( ostream &tout, DWORD fields, BOOL delimitNext = FALSE) { PrintGoOptions(tout, ESC_OPTS_MAP_EO2GO(fields), delimitNext, "GO_"); PrintFields(tout, NULL, fields & ~ESC_OPTS_MAP_GO2EO(-1), delimitNext); return delimitNext; } /////////////////////////////////////////////////////////////// static void PrintMaskedFields(ostream &tout, const FIELD2NAME *pTable, DWORD maskedFields) { WORD mask = MASK2VAL(maskedFields); tout << "SET["; PrintFields(tout, pTable, maskedFields & mask); tout << "] CLR["; PrintFields(tout, pTable, ~maskedFields & mask); tout << "]"; } /////////////////////////////////////////////////////////////// static void PrintBuf(ostream &tout, const BYTE *pData, DWORD size) { tout << "[" << size << "]:"; ios_base::fmtflags b = tout.setf(ios_base::hex, ios_base::basefield); char f = tout.fill('0'); while (size) { tout << endl << " "; stringstream buf; int i = 0; for ( ; i < 16 && size ; i++, size--) { BYTE ch = *pData++; tout << setw(2) << (unsigned)ch << " "; buf << (char)((ch >= 0x20 && ch < 0x7F) ? ch : '.'); } for ( ; i < 16 ; i++) { tout << " "; buf << " "; } tout << " * " << buf.str() << " *"; } tout.fill(f); tout.setf(b, ios_base::basefield); } /////////////////////////////////////////////////////////////// static void PrintMsgType(ostream &tout, DWORD msgType) { tout << "MSG_"; PrintCode(tout, codeNameTableHubMsg, msgType); } /////////////////////////////////////////////////////////////// static void PrintVal(ostream &tout, DWORD msgType, DWORD val) { switch (msgType & HUB_MSG_VAL_TYPES_MASK) { case HUB_MSG_VAL_TYPE_BOOL: tout << (val ? "true" : "false"); break; case HUB_MSG_VAL_TYPE_MSG_TYPE: PrintMsgType(tout, val); break; case HUB_MSG_VAL_TYPE_UINT: tout << val; break; default: tout << "0x" << hex << val << dec; } } /////////////////////////////////////////////////////////////// static void PrintMsgBody(ostream &tout, HUB_MSG *pMsg) { switch (pMsg->type & HUB_MSG_UNION_TYPE_MASK) { case HUB_MSG_UNION_TYPE_NONE: break; case HUB_MSG_UNION_TYPE_BUF: PrintBuf(tout, pMsg->u.buf.pBuf, pMsg->u.buf.size); break; case HUB_MSG_UNION_TYPE_VAL: PrintVal(tout, pMsg->type, pMsg->u.val); break; case HUB_MSG_UNION_TYPE_PVAL: tout << "&0x" << hex << *pMsg->u.pv.pVal << dec << " "; PrintVal(tout, pMsg->type, pMsg->u.pv.val); break; default: tout << "???"; } } /////////////////////////////////////////////////////////////// static void PrintMsg(ostream &tout, HUB_MSG *pMsg) { PrintMsgType(tout, pMsg->type); tout << " {"; switch (pMsg->type) { case HUB_MSG_TYPE_MODEM_STATUS: PrintMaskedFields(tout, fieldNameTableModemStatus, pMsg->u.val); break; case HUB_MSG_TYPE_LINE_STATUS: PrintMaskedFields(tout, fieldNameTableLineStatus, pMsg->u.val); break; case HUB_MSG_TYPE_SET_PIN_STATE: PrintMaskedFields(tout, codeNameTableSetPinState, pMsg->u.val); break; case HUB_MSG_TYPE_SET_OUT_OPTS: { tout << "["; BOOL delimitNext = FALSE; delimitNext = PrintFields(tout, codeNameTableSetPinState, SO_O2V_PIN_STATE(pMsg->u.val), delimitNext, "PIN_"); PrintFields(tout, NULL, pMsg->u.val & ~SO_V2O_PIN_STATE(-1), delimitNext); tout << "]"; break; } case HUB_MSG_TYPE_GET_IN_OPTS: { tout << "&["; PrintGoOptions(tout, *pMsg->u.pv.pVal); tout << "] ["; PrintGoOptions(tout, pMsg->u.pv.val); tout << "]"; break; } case HUB_MSG_TYPE_FAIL_IN_OPTS: { tout << "["; PrintGoOptions(tout, pMsg->u.val); tout << "]"; break; } case HUB_MSG_TYPE_GET_ESC_OPTS: { tout << "&["; tout << "CHAR_0x" << hex << (unsigned)ESC_OPTS_O2V_ESCCHAR(*pMsg->u.pv.pVal) << dec; PrintEscOptions(tout, *pMsg->u.pv.pVal & ~ESC_OPTS_V2O_ESCCHAR(-1), TRUE); tout << "]"; break; } case HUB_MSG_TYPE_FAIL_ESC_OPTS: { tout << "["; PrintEscOptions(tout, pMsg->u.val & ~ESC_OPTS_V2O_ESCCHAR(-1)); tout << "]"; break; } default: PrintMsgBody(tout, pMsg); } tout << "}" << endl; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK InMethod( HFILTER hFilter, int nFromPort, HUB_MSG *pInMsg, HUB_MSG **DEBUG_PARAM(ppEchoMsg)) { _ASSERTE(hFilter != NULL); _ASSERTE(pInMsg != NULL); _ASSERTE(ppEchoMsg != NULL); _ASSERTE(*ppEchoMsg == NULL); _ASSERTE(((Filter *)hFilter)->pTraceStream != NULL); ostream &tout = *((Filter *)hFilter)->pTraceStream; PrintTime(tout); tout << ((Filter *)hFilter)->PortName(nFromPort) << "-(" << ((Filter *)hFilter)->FilterName() << ")->: "; PrintMsg(tout, pInMsg); return TRUE; } /////////////////////////////////////////////////////////////// static BOOL CALLBACK OutMethod( HFILTER hFilter, int nFromPort, int nToPort, HUB_MSG *pOutMsg) { _ASSERTE(hFilter != NULL); _ASSERTE(pOutMsg != NULL); _ASSERTE(((Filter *)hFilter)->pTraceStream != NULL); ostream &tout = *((Filter *)hFilter)->pTraceStream; PrintTime(tout); tout << ((Filter *)hFilter)->PortName(nToPort) << "<-(" << ((Filter *)hFilter)->FilterName() << ")-" << ((Filter *)hFilter)->PortName(nFromPort) << ": "; PrintMsg(tout, pOutMsg); return TRUE; } /////////////////////////////////////////////////////////////// static const FILTER_ROUTINES_A routines = { sizeof(FILTER_ROUTINES_A), GetPluginType, GetPluginAbout, Help, ConfigStart, Config, ConfigStop, Create, 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, pPortName) || !ROUTINE_IS_VALID(pHubRoutines, pFilterName)) { return NULL; } pPortName = pHubRoutines->pPortName; pFilterName = pHubRoutines->pFilterName; return plugins; } /////////////////////////////////////////////////////////////// --- NEW FILE: .cvsignore --- *.user Release Debug |
From: Vyacheslav F. <vf...@us...> - 2008-08-29 13:10:53
|
Update of /cvsroot/com0com/hub4com/plugins/trace In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31009/trace Log Message: Directory /cvsroot/com0com/hub4com/plugins/trace added to the repository |