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...> - 2005-06-10 15:51:37
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27338 Modified Files: utils.cxx Log Message: Included precomp.h Index: utils.cxx =================================================================== RCS file: /cvsroot/com0com/com2tcp/utils.cxx,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** utils.cxx 6 Jun 2005 15:19:02 -0000 1.1 --- utils.cxx 10 Jun 2005 15:51:26 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/06/10 15:51:26 vfrolov + * Included precomp.h + * * Revision 1.1 2005/06/06 15:19:02 vfrolov * Initial revision *************** *** 26,33 **** */ ! #include <winsock2.h> ! #include <windows.h> ! ! #include "utils.h" /////////////////////////////////////////////////////////////// --- 29,33 ---- */ ! #include "precomp.h" /////////////////////////////////////////////////////////////// |
From: Vyacheslav F. <vf...@us...> - 2005-06-10 15:49:19
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26049 Modified Files: ReadMe.txt Log Message: Fixed typo Index: ReadMe.txt =================================================================== RCS file: /cvsroot/com0com/com2tcp/ReadMe.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReadMe.txt 7 Jun 2005 10:08:04 -0000 1.1 --- ReadMe.txt 10 Jun 2005 15:49:08 -0000 1.2 *************** *** 5,9 **** INTRODUCTION ! The COM port to TCP redirector is a Windows application and is part of the com0com project. --- 5,9 ---- INTRODUCTION ! The COM port to TCP redirector is a Windows application and is a part of the com0com project. *************** *** 20,24 **** Build com2tcp.exe. ! EXAMPLE You have old TERM95.EXE application from the Norton Commander 5.0 for --- 20,24 ---- Build com2tcp.exe. ! EXAMPLE OF USAGE You have old TERM95.EXE application from the Norton Commander 5.0 for |
From: Vyacheslav F. <vf...@us...> - 2005-06-10 15:48:24
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25310 Added Files: precomp.h Log Message: Initial revision --- NEW FILE: precomp.h --- /* * $Id: precomp.h,v 1.1 2005/06/10 15:48:01 vfrolov Exp $ * * Copyright (c) 2005 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 2005/06/10 15:48:01 vfrolov * Initial revision * * */ #ifndef _PRECOMP_H_ #define _PRECOMP_H_ #include <winsock2.h> #include <windows.h> #include <stdio.h> #pragma warning(disable:4710) #pragma warning(push, 3) #include <vector> #pragma warning(pop) using namespace std; #include "utils.h" #endif /* _PRECOMP_H_ */ |
From: Vyacheslav F. <vf...@us...> - 2005-06-08 15:48:29
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11104 Modified Files: com2tcp.cpp Log Message: Implemented --awak-seq option Index: com2tcp.cpp =================================================================== RCS file: /cvsroot/com0com/com2tcp/com2tcp.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** com2tcp.cpp 7 Jun 2005 10:06:37 -0000 1.4 --- com2tcp.cpp 8 Jun 2005 15:48:17 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2005/06/08 15:48:17 vfrolov + * Implemented --awak-seq option + * * Revision 1.4 2005/06/07 10:06:37 vfrolov * Added ability to use port names *************** *** 306,310 **** break; case WAIT_TIMEOUT: ! break; default: TraceLastError("InOut(): WaitForMultipleObjects()"); --- 309,313 ---- break; case WAIT_TIMEOUT: ! break; default: TraceLastError("InOut(): WaitForMultipleObjects()"); *************** *** 322,328 **** } /////////////////////////////////////////////////////////////// ! static BOOL WaitComReady(HANDLE hC0C) { enum { EVENT_STAT, EVENT_NUM --- 325,332 ---- } /////////////////////////////////////////////////////////////// ! static BOOL WaitComReady(HANDLE hC0C, const BYTE *pAwakSeq) { enum { + EVENT_READ, EVENT_STAT, EVENT_NUM *************** *** 343,349 **** DWORD not_used; ! BOOL waitingStat = FALSE; while (!fault) { if (!waitingStat) { if (!WaitCommEvent(hC0C, ¬_used, &overlaps[EVENT_STAT])) { --- 347,371 ---- DWORD not_used; ! ! const BYTE *pAwakSeqNext = pAwakSeq; ! ! BYTE cbufRead[1]; ! BOOL waitingRead = !(pAwakSeq && *pAwakSeq); ! BOOL waitingStat = !waitingRead; while (!fault) { + if (!waitingRead) { + if (!pAwakSeqNext || !*pAwakSeqNext) + break; + + if (!ReadFile(hC0C, cbufRead, sizeof(cbufRead), ¬_used, &overlaps[EVENT_READ])) { + if (::GetLastError() != ERROR_IO_PENDING) { + TraceLastError("WaitComReady(): ReadFile()"); + break; + } + } + waitingRead = TRUE; + } + if (!waitingStat) { if (!WaitCommEvent(hC0C, ¬_used, &overlaps[EVENT_STAT])) { *************** *** 382,387 **** } ! if (waitingStat) { switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_STAT: if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], ¬_used, FALSE)) { --- 404,429 ---- } ! if (waitingRead && waitingStat) { ! DWORD done; ! switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { + case WAIT_OBJECT_0 + EVENT_READ: + if (!GetOverlappedResult(hC0C, &overlaps[EVENT_READ], &done, FALSE)) { + TraceLastError("WaitComReady(): GetOverlappedResult(EVENT_READ)"); + fault = TRUE; + } + ResetEvent(hEvents[EVENT_READ]); + if (done && pAwakSeqNext) { + if (*pAwakSeqNext == *cbufRead) { + pAwakSeqNext++; + } else { + pAwakSeqNext = pAwakSeq; + if (*pAwakSeqNext == *cbufRead) + pAwakSeqNext++; + } + printf("Skipped character 0x%02.2X\n", (int)*cbufRead); + } + waitingRead = FALSE; + break; case WAIT_OBJECT_0 + EVENT_STAT: if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], ¬_used, FALSE)) { *************** *** 392,396 **** break; case WAIT_TIMEOUT: ! break; default: TraceLastError("WaitComReady(): WaitForMultipleObjects()"); --- 434,438 ---- break; case WAIT_TIMEOUT: ! break; default: TraceLastError("WaitComReady(): WaitForMultipleObjects()"); *************** *** 554,557 **** --- 596,600 ---- fprintf(stderr, "Options:\n"); fprintf(stderr, " --telnet - use Telnet protocol.\n"); + fprintf(stderr, " --awak-seq sequence - wait awakening sequence from com port.\n"); exit(1); } *************** *** 560,563 **** --- 603,607 ---- { enum {prNone, prTelnet} protocol = prNone; + const BYTE *pAwakSeq = NULL; char **pArgs = &argv[1]; *************** *** 570,573 **** --- 614,624 ---- pArgs++; argc--; + } else + if (!strcmp(*pArgs, "--awak-seq")) { + pArgs++; + argc--; + pAwakSeq = (const BYTE *)*pArgs; + pArgs++; + argc--; } else { fprintf(stderr, "Unknown option %s\n", *pArgs); *************** *** 589,593 **** WSAStartup(MAKEWORD(1, 1), &wsaData); ! while (WaitComReady(hC0C)) { SOCKET hSock = Connect(pArgs[1], pArgs[2]); --- 640,644 ---- WSAStartup(MAKEWORD(1, 1), &wsaData); ! while (WaitComReady(hC0C, pAwakSeq)) { SOCKET hSock = Connect(pArgs[1], pArgs[2]); |
From: Vyacheslav F. <vf...@us...> - 2005-06-08 07:40:37
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7055 Modified Files: utils.h Log Message: Added missing DataStream::busy initialization Index: utils.h =================================================================== RCS file: /cvsroot/com0com/com2tcp/utils.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** utils.h 6 Jun 2005 15:19:02 -0000 1.1 --- utils.h 8 Jun 2005 07:40:23 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/06/08 07:40:23 vfrolov + * Added missing DataStream::busy initialization + * * Revision 1.1 2005/06/06 15:19:02 vfrolov * Initial revision *************** *** 68,72 **** public: DataStream(int _threshold = 0) ! : threshold(_threshold), eof(FALSE) {} ~DataStream() { DataStream::Clean(); } --- 71,75 ---- public: DataStream(int _threshold = 0) ! : busy(0), threshold(_threshold), eof(FALSE) {} ~DataStream() { DataStream::Clean(); } |
From: Vyacheslav F. <vf...@us...> - 2005-06-07 15:31:16
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31278 Modified Files: com2tcp.dsp Log Message: Added com2tcp.rc Index: com2tcp.dsp =================================================================== RCS file: /cvsroot/com0com/com2tcp/com2tcp.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** com2tcp.dsp 6 Jun 2005 15:20:46 -0000 1.2 --- com2tcp.dsp 7 Jun 2005 15:31:07 -0000 1.3 *************** *** 94,97 **** --- 94,101 ---- # Begin Source File + SOURCE=.\com2tcp.rc + # End Source File + # Begin Source File + SOURCE=.\telnet.cpp # End Source File |
From: Vyacheslav F. <vf...@us...> - 2005-06-07 15:30:02
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30663 Added Files: com2tcp.rc Log Message: Initial revision --- NEW FILE: com2tcp.rc --- /* * $Id: com2tcp.rc,v 1.1 2005/06/07 15:29:52 vfrolov Exp $ * * Copyright (c) 2005 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: com2tcp.rc,v $ * Revision 1.1 2005/06/07 15:29:52 vfrolov * Initial revision * * */ #include <windows.h> #define VER_FILEVERSION 1,0,0,0 #define VER_PRODUCTVERSION_STR "1.0.0.0" #define VER_LEGALCOPYRIGHT_YEARS "2005" #define VER_COMPANYNAME_STR "Vyacheslav Frolov\0" #define VER_LEGALCOPYRIGHT_STR "Copyright (c) " VER_LEGALCOPYRIGHT_YEARS " " VER_COMPANYNAME_STR #define VER_PRODUCTNAME_STR "COM port to TCP redirector" #ifdef _DEBUG #define VER_DEBUG_STR " (debug version)" #define VER_FILEFLAGS VS_FF_DEBUG #else #define VER_DEBUG_STR "" #define VER_FILEFLAGS 0 #endif #define VER_FILEDESCRIPTION_STR VER_PRODUCTNAME_STR VER_DEBUG_STR #define VER_INTERNALNAME_STR "com2tcp\0" #define VER_ORIGINALFILENAME_STR "com2tcp.exe\0" #define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #define VER_FILEOS VOS_NT_WINDOWS32 #define VER_FILETYPE VFT_APP #define VER_FILESUBTYPE 0 #include <common.ver> |
From: Vyacheslav F. <vf...@us...> - 2005-06-07 10:08:26
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27965 Added Files: ReadMe.txt Log Message: Initial revision --- NEW FILE: ReadMe.txt --- ==================================== COM port to TCP redirector (com2tcp) ==================================== INTRODUCTION The COM port to TCP redirector is a Windows application and is part of the com0com project. In conjunction with the Null-modem emulator (com0com) the com2tcp enables to use a COM port based applications to communicate with the TCP/IP servers. The homepage for com0com project is http://com0com.sourceforge.net/. BUILDING Start MSVC (v5 or v6) with com2tcp.dsw file. Set Active Configuration to com2tcp - Win32 Release". Build com2tcp.exe. EXAMPLE You have old TERM95.EXE application from the Norton Commander 5.0 for MS-DOS and you'd like to use it to communicate with your.telnet.server telnet server. You can do so this way: 1. With the com0com driver create a virtual COM port pair with port names COM2 and CNCB0 (see com0com's ReadMe.txt for details). 2. Start the com2tcp.exe on CNCB0 port. For example: com2tcp --telnet \\.\CNCB0 your.telnet.server telnet 3. Start the TERM95.EXE on COM2 port. |
From: Vyacheslav F. <vf...@us...> - 2005-06-07 10:06:54
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27263 Modified Files: com2tcp.cpp Log Message: Added ability to use port names Index: com2tcp.cpp =================================================================== RCS file: /cvsroot/com0com/com2tcp/com2tcp.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** com2tcp.cpp 6 Jun 2005 15:20:46 -0000 1.3 --- com2tcp.cpp 7 Jun 2005 10:06:37 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2005/06/07 10:06:37 vfrolov + * Added ability to use port names + * * Revision 1.3 2005/06/06 15:20:46 vfrolov * Implemented --telnet option *************** *** 481,489 **** static SOCKET Connect(const char *pAddr, const char *pPort) { struct sockaddr_in sn; memset(&sn, 0, sizeof(sn)); sn.sin_family = AF_INET; ! sn.sin_port = htons((u_short)atoi(pPort)); sn.sin_addr.S_un.S_addr = inet_addr(pAddr); --- 484,498 ---- static SOCKET Connect(const char *pAddr, const char *pPort) { + const char *pProtoName = "tcp"; struct sockaddr_in sn; memset(&sn, 0, sizeof(sn)); sn.sin_family = AF_INET; ! ! struct servent *pServEnt; ! ! pServEnt = getservbyname(pPort, pProtoName); ! ! sn.sin_port = pServEnt ? pServEnt->s_port : htons((u_short)atoi(pPort)); sn.sin_addr.S_un.S_addr = inet_addr(pAddr); *************** *** 502,509 **** const struct protoent *pProtoEnt; ! pProtoEnt = getprotobyname("tcp"); if (!pProtoEnt) { ! TraceLastError("Connect(): getprotobyname(\"tcp\")"); return INVALID_SOCKET; } --- 511,518 ---- const struct protoent *pProtoEnt; ! pProtoEnt = getprotobyname(pProtoName); if (!pProtoEnt) { ! TraceLastError("Connect(): getprotobyname(\"%s\")", pProtoName); return INVALID_SOCKET; } |
From: Vyacheslav F. <vf...@us...> - 2005-06-06 15:20:54
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4874 Modified Files: com2tcp.cpp com2tcp.dsp Log Message: Implemented --telnet option Index: com2tcp.dsp =================================================================== RCS file: /cvsroot/com0com/com2tcp/com2tcp.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** com2tcp.dsp 30 May 2005 10:02:33 -0000 1.1 --- com2tcp.dsp 6 Jun 2005 15:20:46 -0000 1.2 *************** *** 92,99 **** --- 92,115 ---- SOURCE=.\com2tcp.cpp # End Source File + # Begin Source File + + SOURCE=.\telnet.cpp + # End Source File + # Begin Source File + + SOURCE=.\utils.cxx + # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" + # Begin Source File + + SOURCE=.\telnet.h + # End Source File + # Begin Source File + + SOURCE=.\utils.h + # End Source File # End Group # Begin Group "Resource Files" Index: com2tcp.cpp =================================================================== RCS file: /cvsroot/com0com/com2tcp/com2tcp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** com2tcp.cpp 30 May 2005 12:17:32 -0000 1.2 --- com2tcp.cpp 6 Jun 2005 15:20:46 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2005/06/06 15:20:46 vfrolov + * Implemented --telnet option + * * Revision 1.2 2005/05/30 12:17:32 vfrolov * Fixed resolving problem *************** *** 31,36 **** --- 34,43 ---- #include <winsock2.h> #include <windows.h> + #include <stdio.h> + #include "utils.h" + #include "telnet.h" + /////////////////////////////////////////////////////////////// static void TraceLastError(const char *pFmt, ...) *************** *** 93,97 **** } /////////////////////////////////////////////////////////////// ! static void InOut(HANDLE hC0C, SOCKET hSock) { printf("InOut() START\n"); --- 100,104 ---- } /////////////////////////////////////////////////////////////// ! static void InOut(HANDLE hC0C, SOCKET hSock, Protocol &protocol) { printf("InOut() START\n"); *************** *** 119,142 **** } ! char cbufRead[1024]; ! DWORD cbufReadDone = 0; BOOL waitingRead = FALSE; ! DWORD cbufSendDone = 0; BOOL waitingSend = FALSE; - DWORD sent; ! char cbufRecv[1]; ! DWORD cbufRecvDone = 0; BOOL waitingRecv = FALSE; ! DWORD cbufWriteDone = 0; BOOL waitingWrite = FALSE; - DWORD written; BOOL waitingStat = FALSE; while (!stop) { ! if (!waitingRead && !waitingSend) { ! if (cbufSendDone < cbufReadDone) { ! if (!WriteFile((HANDLE)hSock, cbufRead + cbufSendDone, cbufReadDone - cbufSendDone, &sent, &overlaps[EVENT_SENT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WriteFile(hSock)"); --- 126,161 ---- } ! DWORD not_used; ! ! BYTE cbufRead[64]; BOOL waitingRead = FALSE; ! ! BYTE cbufSend[64]; ! int cbufSendSize = 0; ! int cbufSendDone = 0; BOOL waitingSend = FALSE; ! BYTE cbufRecv[64]; BOOL waitingRecv = FALSE; ! ! BYTE cbufWrite[64]; ! int cbufWriteSize = 0; ! int cbufWriteDone = 0; BOOL waitingWrite = FALSE; BOOL waitingStat = FALSE; while (!stop) { ! if (!waitingSend) { ! if (!cbufSendSize) { ! cbufSendSize = protocol.Read(cbufSend, sizeof(cbufSend)); ! if (cbufSendSize < 0) ! break; ! } ! ! DWORD num = cbufSendSize - cbufSendDone; ! ! if (num) { ! if (!WriteFile((HANDLE)hSock, cbufSend + cbufSendDone, num, ¬_used, &overlaps[EVENT_SENT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WriteFile(hSock)"); *************** *** 145,162 **** } waitingSend = TRUE; ! } else { ! if (!ReadFile(hC0C, cbufRead, sizeof(cbufRead), &cbufReadDone, &overlaps[EVENT_READ])) { ! if (::GetLastError() != ERROR_IO_PENDING) { ! TraceLastError("InOut(): ReadFile(hC0C)"); ! break; ! } } - waitingRead = TRUE; } } ! if (!waitingRecv && !waitingWrite) { ! if (cbufWriteDone < cbufRecvDone) { ! if (!WriteFile(hC0C, cbufRecv + cbufWriteDone, cbufRecvDone - cbufWriteDone, &written, &overlaps[EVENT_WRITTEN])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WriteFile(hC0C)"); --- 164,191 ---- } waitingSend = TRUE; ! } ! } ! ! if (!waitingRead && !protocol.isSendFull()) { ! if (!ReadFile(hC0C, cbufRead, sizeof(cbufRead), ¬_used, &overlaps[EVENT_READ])) { ! if (::GetLastError() != ERROR_IO_PENDING) { ! TraceLastError("InOut(): ReadFile(hC0C)"); ! break; } } + waitingRead = TRUE; } ! if (!waitingWrite) { ! if (!cbufWriteSize) { ! cbufWriteSize = protocol.Recv(cbufWrite, sizeof(cbufWrite)); ! if (cbufWriteSize < 0) ! break; ! } ! ! DWORD num = cbufWriteSize - cbufWriteDone; ! ! if (num) { ! if (!WriteFile(hC0C, cbufWrite + cbufWriteDone, num, ¬_used, &overlaps[EVENT_WRITTEN])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WriteFile(hC0C)"); *************** *** 165,183 **** } waitingWrite = TRUE; ! } else { ! if (!ReadFile((HANDLE)hSock, cbufRecv, sizeof(cbufRecv), &cbufRecvDone, &overlaps[EVENT_RECEIVED])) { ! if (::GetLastError() != ERROR_IO_PENDING) { ! TraceLastError("InOut(): ReadFile(hSock)"); ! break; ! } } - waitingRecv = TRUE; } } if (!waitingStat) { ! DWORD maskStat; ! ! if (!WaitCommEvent(hC0C, &maskStat, &overlaps[EVENT_STAT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WaitCommEvent()"); --- 194,212 ---- } waitingWrite = TRUE; ! } ! } ! ! if (!waitingRecv && !protocol.isWriteFull()) { ! if (!ReadFile((HANDLE)hSock, cbufRecv, sizeof(cbufRecv), ¬_used, &overlaps[EVENT_RECEIVED])) { ! if (::GetLastError() != ERROR_IO_PENDING) { ! TraceLastError("InOut(): ReadFile(hSock)"); ! break; } } + waitingRecv = TRUE; } if (!waitingStat) { ! if (!WaitCommEvent(hC0C, ¬_used, &overlaps[EVENT_STAT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WaitCommEvent()"); *************** *** 201,258 **** if ((waitingRead || waitingSend) && (waitingRecv || waitingWrite) && waitingStat) { ! DWORD undef; switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_READ: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_READ], &cbufReadDone, FALSE)) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_READ)"); ! stop = TRUE; ! break; } ResetEvent(hEvents[EVENT_READ]); waitingRead = FALSE; break; case WAIT_OBJECT_0 + EVENT_SENT: ! if (!GetOverlappedResult((HANDLE)hSock, &overlaps[EVENT_SENT], &sent, FALSE)) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_SENT)"); ! stop = TRUE; ! break; } ResetEvent(hEvents[EVENT_SENT]); ! cbufSendDone += sent; ! if (cbufSendDone >= cbufReadDone) ! cbufSendDone = cbufReadDone = 0; waitingSend = FALSE; break; case WAIT_OBJECT_0 + EVENT_RECEIVED: ! if (!GetOverlappedResult((HANDLE)hSock, &overlaps[EVENT_RECEIVED], &cbufRecvDone, FALSE)) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_RECEIVED)"); ! stop = TRUE; ! break; ! } ! ResetEvent(hEvents[EVENT_RECEIVED]); ! if (!cbufRecvDone) { printf("Received EOF\n"); break; } waitingRecv = FALSE; break; case WAIT_OBJECT_0 + EVENT_WRITTEN: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_WRITTEN], &written, FALSE)) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_WRITTEN)"); ! stop = TRUE; ! break; } ResetEvent(hEvents[EVENT_WRITTEN]); ! cbufWriteDone += written; ! if (cbufWriteDone >= cbufRecvDone) ! cbufWriteDone = cbufRecvDone = 0; waitingWrite = FALSE; break; case WAIT_OBJECT_0 + EVENT_STAT: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], &undef, FALSE)) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_STAT)"); ! stop = TRUE; ! break; } waitingStat = FALSE; --- 230,302 ---- if ((waitingRead || waitingSend) && (waitingRecv || waitingWrite) && waitingStat) { ! DWORD done; switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_READ: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_READ], &done, FALSE)) { ! if (::GetLastError() != ERROR_OPERATION_ABORTED) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_READ)"); ! stop = TRUE; ! break; ! } } ResetEvent(hEvents[EVENT_READ]); waitingRead = FALSE; + protocol.Send(cbufRead, done); break; case WAIT_OBJECT_0 + EVENT_SENT: ! if (!GetOverlappedResult((HANDLE)hSock, &overlaps[EVENT_SENT], &done, FALSE)) { ! if (::GetLastError() != ERROR_OPERATION_ABORTED) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_SENT)"); ! stop = TRUE; ! break; ! } ! done = 0; } ResetEvent(hEvents[EVENT_SENT]); ! cbufSendDone += done; ! if (cbufSendDone >= cbufSendSize) ! cbufSendDone = cbufSendSize = 0; waitingSend = FALSE; break; case WAIT_OBJECT_0 + EVENT_RECEIVED: ! if (!GetOverlappedResult((HANDLE)hSock, &overlaps[EVENT_RECEIVED], &done, FALSE)) { ! if (::GetLastError() != ERROR_OPERATION_ABORTED) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_RECEIVED)"); ! stop = TRUE; ! break; ! } ! done = 0; ! } else if (!done) { ! ResetEvent(hEvents[EVENT_RECEIVED]); printf("Received EOF\n"); break; } + ResetEvent(hEvents[EVENT_RECEIVED]); waitingRecv = FALSE; + protocol.Write(cbufRecv, done); break; case WAIT_OBJECT_0 + EVENT_WRITTEN: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_WRITTEN], &done, FALSE)) { ! if (::GetLastError() != ERROR_OPERATION_ABORTED) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_WRITTEN)"); ! stop = TRUE; ! break; ! } ! done = 0; } ResetEvent(hEvents[EVENT_WRITTEN]); ! cbufWriteDone += done; ! if (cbufWriteDone >= cbufWriteSize) ! cbufWriteDone = cbufWriteSize = 0; waitingWrite = FALSE; break; case WAIT_OBJECT_0 + EVENT_STAT: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], &done, FALSE)) { ! if (::GetLastError() != ERROR_OPERATION_ABORTED) { ! TraceLastError("InOut(): GetOverlappedResult(EVENT_STAT)"); ! stop = TRUE; ! break; ! } } waitingStat = FALSE; *************** *** 295,305 **** } BOOL waitingStat = FALSE; while (!fault) { if (!waitingStat) { ! DWORD maskStat; ! ! if (!WaitCommEvent(hC0C, &maskStat, &overlaps[EVENT_STAT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("WaitComReady(): WaitCommEvent()"); --- 339,348 ---- } + DWORD not_used; BOOL waitingStat = FALSE; while (!fault) { if (!waitingStat) { ! if (!WaitCommEvent(hC0C, ¬_used, &overlaps[EVENT_STAT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("WaitComReady(): WaitCommEvent()"); *************** *** 337,345 **** if (waitingStat) { - DWORD undef; - switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_STAT: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], &undef, FALSE)) { TraceLastError("WaitComReady(): GetOverlappedResult(EVENT_STAT)"); fault = TRUE; --- 380,386 ---- if (waitingStat) { switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_STAT: ! if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], ¬_used, FALSE)) { TraceLastError("WaitComReady(): GetOverlappedResult(EVENT_STAT)"); fault = TRUE; *************** *** 392,396 **** dcb.StopBits = ONESTOPBIT; ! dcb.fOutxCtsFlow = TRUE; dcb.fOutxDsrFlow = FALSE; dcb.fDsrSensitivity = TRUE; --- 433,437 ---- dcb.StopBits = ONESTOPBIT; ! dcb.fOutxCtsFlow = FALSE; dcb.fOutxDsrFlow = FALSE; dcb.fDsrSensitivity = TRUE; *************** *** 498,510 **** } /////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { ! if (argc != 4) { ! printf("Usage:\n"); ! printf(" %s \\\\.\\<com port> <host addr> <host port>\n", argv[0]); ! return 1; } ! HANDLE hC0C = OpenC0C(argv[1]); if (hC0C == INVALID_HANDLE_VALUE) { --- 539,574 ---- } /////////////////////////////////////////////////////////////// + static void Usage(const char *pProgName) + { + fprintf(stderr, "Usage:\n"); + fprintf(stderr, " %s [options] \\\\.\\<com port> <host addr> <host port>\n", pProgName); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " --telnet - use Telnet protocol.\n"); + exit(1); + } + /////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { ! enum {prNone, prTelnet} protocol = prNone; ! char **pArgs = &argv[1]; ! ! while (argc > 1) { ! if (**pArgs != '-') ! break; ! ! if (!strcmp(*pArgs, "--telnet")) { ! protocol = prTelnet; ! pArgs++; ! argc--; ! } else { ! fprintf(stderr, "Unknown option %s\n", *pArgs); ! Usage(argv[0]); ! } } ! if (argc != 4) ! Usage(argv[0]); ! ! HANDLE hC0C = OpenC0C(pArgs[0]); if (hC0C == INVALID_HANDLE_VALUE) { *************** *** 517,526 **** while (WaitComReady(hC0C)) { ! SOCKET hSock = Connect(argv[2], argv[3]); if (hSock == INVALID_SOCKET) break; ! InOut(hC0C, hSock); Disconnect(hSock); } --- 581,603 ---- while (WaitComReady(hC0C)) { ! SOCKET hSock = Connect(pArgs[1], pArgs[2]); if (hSock == INVALID_SOCKET) break; ! Protocol *pProtocol; ! ! switch (protocol) { ! case prTelnet: ! pProtocol = new TelnetProtocol(10, 10); ! break; ! default: ! pProtocol = new Protocol(10, 10); ! }; ! ! InOut(hC0C, hSock, *pProtocol); ! ! delete pProtocol; ! Disconnect(hSock); } |
From: Vyacheslav F. <vf...@us...> - 2005-06-06 15:19:10
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3850 Added Files: telnet.cpp telnet.h utils.cxx utils.h Log Message: Initial revision --- NEW FILE: telnet.cpp --- /* * $Id: telnet.cpp,v 1.1 2005/06/06 15:19:02 vfrolov Exp $ * * Copyright (c) 2005 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: telnet.cpp,v $ * Revision 1.1 2005/06/06 15:19:02 vfrolov * Initial revision * * */ #include <winsock2.h> #include <windows.h> #include <stdio.h> #include "utils.h" #include "telnet.h" /////////////////////////////////////////////////////////////// enum { cdWILL = 251, cdWONT = 252, cdDO = 253, cdDONT = 254, cdIAC = 255, }; static const char *code2name(unsigned code) { switch (code) { case cdWILL: return "WILL"; break; case cdWONT: return "WONT"; break; case cdDO: return "DO"; break; case cdDONT: return "DONT"; break; } return "UNKNOWN"; } /////////////////////////////////////////////////////////////// enum { opEcho = 1, }; /////////////////////////////////////////////////////////////// enum { stData, stCode, stOption, }; /////////////////////////////////////////////////////////////// TelnetProtocol::TelnetProtocol(int _thresholdSend, int _thresholdWrite) : Protocol(_thresholdSend, _thresholdWrite), state(stData) { options[opEcho].remoteOptionState = OptionState::osNo; } int TelnetProtocol::Write(const void *pBuf, int count) { for (int i = 0 ; i < count ; i++) { BYTE ch = ((const BYTE *)pBuf)[i]; switch (state) { case stData: if (ch == cdIAC) state = stCode; else WriteRaw(&ch, 1); break; case stCode: switch (ch) { case cdIAC: WriteRaw(&ch, 1); break; case cdWILL: case cdWONT: case cdDO: case cdDONT: code = ch; state = stOption; break; default: printf("RECV: unknown code %u\n", (unsigned)ch); state = stData; } break; case stOption: printf("RECV: %s %u\n", code2name(code), (unsigned)ch); switch (code) { case cdWILL: switch (options[ch].remoteOptionState) { case OptionState::osCant: SendOption(cdDONT, ch); break; case OptionState::osNo: options[ch].remoteOptionState = OptionState::osYes; SendOption(cdDO, ch); break; case OptionState::osYes: break; } break; case cdWONT: switch (options[ch].remoteOptionState) { case OptionState::osCant: case OptionState::osNo: break; case OptionState::osYes: options[ch].remoteOptionState = OptionState::osNo; SendOption(cdDONT, ch); break; } break; case cdDO: switch (options[ch].localOptionState) { case OptionState::osCant: SendOption(cdWONT, ch); break; case OptionState::osNo: options[ch].localOptionState = OptionState::osYes; SendOption(cdWILL, ch); break; case OptionState::osYes: break; } break; case cdDONT: switch (options[ch].localOptionState) { case OptionState::osCant: case OptionState::osNo: break; case OptionState::osYes: options[ch].localOptionState = OptionState::osNo; SendOption(cdWONT, ch); break; } break; default: printf("RECV: %u %u (ignore)\n", (unsigned)code, (unsigned)ch); }; state = stData; break; } } return count; } void TelnetProtocol::SendOption(BYTE code, BYTE option) { BYTE buf[3] = {cdIAC, code, option}; printf("SEND: %s %u\n", code2name(code), (unsigned)option); SendRaw(buf, sizeof(buf)); } /////////////////////////////////////////////////////////////// --- NEW FILE: telnet.h --- /* * $Id: telnet.h,v 1.1 2005/06/06 15:19:02 vfrolov Exp $ * * Copyright (c) 2005 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: telnet.h,v $ * Revision 1.1 2005/06/06 15:19:02 vfrolov * Initial revision * * */ #ifndef _TELNET_H #define _TELNET_H /////////////////////////////////////////////////////////////// class TelnetProtocol : public Protocol { public: TelnetProtocol(int _thresholdSend = 0, int _thresholdWrite = 0); //virtual int Send(const void *pBuf, int count); virtual int Write(const void *pBuf, int count); protected: void SendOption(BYTE code, BYTE option); int state; int code; struct OptionState { OptionState() : localOptionState(osCant), remoteOptionState(osCant) {} enum {osCant, osNo, osYes}; int localOptionState : 2; int remoteOptionState : 2; }; OptionState options[256]; DataStream toTelnet; }; /////////////////////////////////////////////////////////////// #endif // _TELNET_H --- NEW FILE: utils.cxx --- /* * $Id: utils.cxx,v 1.1 2005/06/06 15:19:02 vfrolov Exp $ * * Copyright (c) 2005 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: utils.cxx,v $ * Revision 1.1 2005/06/06 15:19:02 vfrolov * Initial revision * * */ #include <winsock2.h> #include <windows.h> #include "utils.h" /////////////////////////////////////////////////////////////// int ChunkStream::write(const void *pBuf, int count) { int len = sizeof(data) - last; if (!len) return -1; if (len > count) len = count; memcpy(data + last, pBuf, len); last += len; return len; } int ChunkStream::read(void *pBuf, int count) { if (sizeof(data) == first) return -1; int len = last - first; if (len > count) len = count; memcpy(pBuf, data + first, len); first += len; return len; } /////////////////////////////////////////////////////////////// void ChunkStreamQ::toQueue(ChunkStream *pChunk) { if (!pChunk) return; if (pLast) { pChunk->pNext = pLast->pNext; pLast->pNext = pChunk; } else { pChunk->pNext = NULL; pFirst = pChunk; } pLast = pChunk; } ChunkStream *ChunkStreamQ::fromQueue() { ChunkStream *pChunk = pFirst; if (pChunk) { pFirst = pChunk->pNext; if (!pFirst) pLast = NULL; } return pChunk; } /////////////////////////////////////////////////////////////// int DataStream::PutData(const void *_pBuf, int count) { if (eof) return -1; int done = 0; const BYTE *pBuf = (const BYTE *)_pBuf; while (count) { if (!bufQ.last()) bufQ.toQueue(new ChunkStream()); int len = bufQ.last()->write(pBuf, count); if (len < 0) { bufQ.toQueue(new ChunkStream()); continue; } else { pBuf += len; count -= len; done += len; } } busy += done; return done; } int DataStream::GetData(void *_pBuf, int count) { if (!busy) { if (eof) return -1; else return 0; } int done = 0; BYTE *pBuf = (BYTE *)_pBuf; while (count && bufQ.first()) { int len = bufQ.first()->read(pBuf, count); if (len < 0) { delete bufQ.fromQueue(); continue; } else { if (!len) break; pBuf += len; count -= len; done += len; } } busy -= done; return done; } void DataStream::Clean() { while (bufQ.first()) delete bufQ.fromQueue(); busy = 0; eof = FALSE; } /////////////////////////////////////////////////////////////// int Protocol::Send(const void *pBuf, int count) { return SendRaw(pBuf, count); } int Protocol::Write(const void *pBuf, int count) { return WriteRaw(pBuf, count); } /////////////////////////////////////////////////////////////// --- NEW FILE: utils.h --- /* * $Id: utils.h,v 1.1 2005/06/06 15:19:02 vfrolov Exp $ * * Copyright (c) 2005 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: utils.h,v $ * Revision 1.1 2005/06/06 15:19:02 vfrolov * Initial revision * * */ #ifndef _UTILS_H #define _UTILS_H /////////////////////////////////////////////////////////////// class ChunkStream { public: ChunkStream() : first(0), last(0) {} int write(const void *pBuf, int count); int read(void *pBuf, int count); private: char data[256]; int first; int last; ChunkStream *pNext; friend class ChunkStreamQ; }; /////////////////////////////////////////////////////////////// class ChunkStreamQ { public: ChunkStreamQ() : pFirst(NULL), pLast(NULL) {} void toQueue(ChunkStream *pChunk); ChunkStream *fromQueue(); ChunkStream *first() { return pFirst; } ChunkStream *last() { return pLast; } private: ChunkStream *pFirst; ChunkStream *pLast; }; /////////////////////////////////////////////////////////////// class DataStream { public: DataStream(int _threshold = 0) : threshold(_threshold), eof(FALSE) {} ~DataStream() { DataStream::Clean(); } int PutData(const void *pBuf, int count); int GetData(void *pBuf, int count); void PutEof() { eof = TRUE; } BOOL isFull() const { return threshold && threshold < busy; } protected: void Clean(); private: ChunkStreamQ bufQ; int busy; int threshold; BOOL eof; }; /////////////////////////////////////////////////////////////// class Protocol { public: Protocol(int _thresholdSend = 0, int _thresholdWrite = 0) : streamSendRead(_thresholdSend), streamWriteRecv(_thresholdWrite) {} virtual int Send(const void *pBuf, int count); int SendRaw(const void *pBuf, int count) { return streamSendRead.PutData(pBuf, count); } void SendEof() { streamSendRead.PutEof(); } BOOL isSendFull() const { return streamSendRead.isFull(); } int Read(void *pBuf, int count) { return streamSendRead.GetData(pBuf, count); } virtual int Write(const void *pBuf, int count); int WriteRaw(const void *pBuf, int count) { return streamWriteRecv.PutData(pBuf, count); } void WriteEof() { streamWriteRecv.PutEof(); } BOOL isWriteFull() const { return streamWriteRecv.isFull(); } int Recv(void *pBuf, int count) { return streamWriteRecv.GetData(pBuf, count); } private: DataStream streamSendRead; DataStream streamWriteRecv; }; /////////////////////////////////////////////////////////////// #endif // _UTILS_H |
From: Vyacheslav F. <vf...@us...> - 2005-06-02 15:55:41
|
Update of /cvsroot/com0com/homepage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14446 Modified Files: index.html Log Message: Added link to ReadMe.txt Index: index.html =================================================================== RCS file: /cvsroot/com0com/homepage/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** index.html 31 May 2005 08:30:11 -0000 1.1 --- index.html 2 Jun 2005 15:55:20 -0000 1.2 *************** *** 30,39 **** ) to CNCB0 port. </p> ! <p>You can find more information on <a href="http://sourceforge.net/projects/com0com/">SourceForge Project ! page</a> ! and ! <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/com0com/">SourceForge ! Web CVS</a>. </p> <br> --- 30,39 ---- ) to CNCB0 port. </p> ! <p>You can find more information in ! <a href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/com0com/com0com/ReadMe.txt"> ! ReadMe.txt</a> ! and on <a href="http://sourceforge.net/projects/com0com/">SourceForge Project ! page</a>. </p> <br> |
From: Vyacheslav F. <vf...@us...> - 2005-05-31 08:30:23
|
Update of /cvsroot/com0com/homepage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22536 Added Files: index.html favicon.ico Log Message: Initial revision --- NEW FILE: favicon.ico --- (This appears to be a binary file; contents omitted.) --- NEW FILE: index.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=windows-1251" http-equiv="content-type"> <title>Null-modem emulator (com0com)</title> </head> <body> <center> <h1> Null-modem emulator <br> (com0com) </h1> </center> <p> The null-modem emulator is a kernel-mode virtual serial port driver for Windows. You can create with it an unlimited number of virtual COM port pairs and use any pair to connect one application to another. Each COM port pair provides two COM ports with names starting at CNCA0 and CNCB0. The output to one port is the input from other port and vice versa. </p> <p> Usually one port of the pair is used by Windows application that requires a COM port to communicate with a device and other port is used by device emulation program. </p> <p> For example, to send/receive faxes over IP you can connect Windows Fax application to CNCA0 port and t38modem (part of the <a href="http://openh323.sourceforge.net/"> OpenH323 project</a> ) to CNCB0 port. </p> <p>You can find more information on <a href="http://sourceforge.net/projects/com0com/">SourceForge Project page</a> and <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/com0com/">SourceForge Web CVS</a>. </p> <br> <center> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=129551&type=5" alt="SourceForge.net Logo" border="0" height="62" width="210"></a></center> </body> </html> |
From: Vyacheslav F. <vf...@us...> - 2005-05-31 08:08:56
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12346 Modified Files: ReadMe.txt Log Message: Added link to http://com0com.sourceforge.net/ Index: ReadMe.txt =================================================================== RCS file: /cvsroot/com0com/com0com/ReadMe.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReadMe.txt 17 May 2005 14:23:42 -0000 1.4 --- ReadMe.txt 31 May 2005 08:08:33 -0000 1.5 *************** *** 18,22 **** For example, to send/receive faxes over IP you can connect Windows Fax application to CNCA0 port and t38modem (part of the OpenH323 project) ! to CNCB0 port. BUILDING --- 18,24 ---- For example, to send/receive faxes over IP you can connect Windows Fax application to CNCA0 port and t38modem (part of the OpenH323 project) ! to CNCB0 port. In this case the t38modem is a fax modem emulation program. ! ! The homepage for com0com project is http://com0com.sourceforge.net/. BUILDING |
From: Vyacheslav F. <vf...@us...> - 2005-05-30 12:17:44
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14624 Modified Files: com2tcp.cpp Log Message: Fixed resolving problem Index: com2tcp.cpp =================================================================== RCS file: /cvsroot/com0com/com2tcp/com2tcp.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** com2tcp.cpp 30 May 2005 10:02:33 -0000 1.1 --- com2tcp.cpp 30 May 2005 12:17:32 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/05/30 12:17:32 vfrolov + * Fixed resolving problem + * * Revision 1.1 2005/05/30 10:02:33 vfrolov * Initial revision *************** *** 443,457 **** sn.sin_port = htons((u_short)atoi(pPort)); ! unsigned long addr = inet_addr(pAddr); ! const struct hostent *pHostEnt = (addr == INADDR_NONE) ? ! gethostbyname(pAddr) : ! gethostbyaddr((const char *)&addr, 4, AF_INET); ! if (!pHostEnt) { ! TraceLastError("Connect(): gethostbyname(\"%s\")", pAddr); ! return INVALID_SOCKET; ! } ! memcpy(&sn.sin_addr, pHostEnt->h_addr, pHostEnt->h_length); const struct protoent *pProtoEnt; --- 446,461 ---- sn.sin_port = htons((u_short)atoi(pPort)); ! sn.sin_addr.S_un.S_addr = inet_addr(pAddr); ! if (sn.sin_addr.S_un.S_addr == INADDR_NONE) { ! const struct hostent *pHostEnt = gethostbyname(pAddr); ! if (!pHostEnt) { ! TraceLastError("Connect(): gethostbyname(\"%s\")", pAddr); ! return INVALID_SOCKET; ! } ! ! memcpy(&sn.sin_addr, pHostEnt->h_addr, pHostEnt->h_length); ! } const struct protoent *pProtoEnt; |
From: Vyacheslav F. <vf...@us...> - 2005-05-30 10:03:01
|
Update of /cvsroot/com0com/com2tcp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8152 Added Files: com2tcp.cpp com2tcp.dsp com2tcp.dsw Log Message: Initial revision --- NEW FILE: com2tcp.dsp --- # Microsoft Developer Studio Project File - Name="com2tcp" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=com2tcp - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "com2tcp.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "com2tcp.mak" CFG="com2tcp - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "com2tcp - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "com2tcp - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "com2tcp - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT CPP /YX /Yc /Yu # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "com2tcp - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "com2tcp - Win32 Release" # Name "com2tcp - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\com2tcp.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\ReadMe.txt # End Source File # End Target # End Project --- NEW FILE: com2tcp.cpp --- /* * $Id: com2tcp.cpp,v 1.1 2005/05/30 10:02:33 vfrolov Exp $ * * Copyright (c) 2005 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: com2tcp.cpp,v $ * Revision 1.1 2005/05/30 10:02:33 vfrolov * Initial revision * * */ #include <winsock2.h> #include <windows.h> #include <stdio.h> /////////////////////////////////////////////////////////////// static void TraceLastError(const char *pFmt, ...) { DWORD err = GetLastError(); va_list va; va_start(va, pFmt); vfprintf(stderr, pFmt, va); va_end(va); fprintf(stderr, " ERROR %s (%lu)\n", strerror(err), (unsigned long)err); } /////////////////////////////////////////////////////////////// static BOOL myGetCommState(HANDLE hC0C, DCB *dcb) { dcb->DCBlength = sizeof(*dcb); if (!GetCommState(hC0C, dcb)) { TraceLastError("GetCommState()"); return FALSE; } return TRUE; } static BOOL mySetCommState(HANDLE hC0C, DCB *dcb) { if (!SetCommState(hC0C, dcb)) { TraceLastError("SetCommState()"); return FALSE; } return TRUE; } /////////////////////////////////////////////////////////////// static void CloseEvents(int num, HANDLE *hEvents) { for (int i = 0 ; i < num ; i++) { if (hEvents[i]) { if (!::CloseHandle(hEvents[i])) { TraceLastError("CloseEvents(): CloseHandle()"); } hEvents[i] = NULL; } } } static BOOL PrepareEvents(int num, HANDLE *hEvents, OVERLAPPED *overlaps) { memset(hEvents, 0, num * sizeof(HANDLE)); memset(overlaps, 0, num * sizeof(OVERLAPPED)); for (int i = 0 ; i < num ; i++) { overlaps[i].hEvent = hEvents[i] = ::CreateEvent(NULL, TRUE, FALSE, NULL); if (!hEvents[i]) { TraceLastError("PrepareEvents(): CreateEvent()"); CloseEvents(i, hEvents); return FALSE; } } return TRUE; } /////////////////////////////////////////////////////////////// static void InOut(HANDLE hC0C, SOCKET hSock) { printf("InOut() START\n"); BOOL stop = FALSE; enum { EVENT_READ, EVENT_SENT, EVENT_RECEIVED, EVENT_WRITTEN, EVENT_STAT, EVENT_NUM }; HANDLE hEvents[EVENT_NUM]; OVERLAPPED overlaps[EVENT_NUM]; if (!PrepareEvents(EVENT_NUM, hEvents, overlaps)) stop = TRUE; if (!SetCommMask(hC0C, EV_DSR)) { TraceLastError("InOut(): SetCommMask()"); stop = TRUE; } char cbufRead[1024]; DWORD cbufReadDone = 0; BOOL waitingRead = FALSE; DWORD cbufSendDone = 0; BOOL waitingSend = FALSE; DWORD sent; char cbufRecv[1]; DWORD cbufRecvDone = 0; BOOL waitingRecv = FALSE; DWORD cbufWriteDone = 0; BOOL waitingWrite = FALSE; DWORD written; BOOL waitingStat = FALSE; while (!stop) { if (!waitingRead && !waitingSend) { if (cbufSendDone < cbufReadDone) { if (!WriteFile((HANDLE)hSock, cbufRead + cbufSendDone, cbufReadDone - cbufSendDone, &sent, &overlaps[EVENT_SENT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WriteFile(hSock)"); break; } } waitingSend = TRUE; } else { if (!ReadFile(hC0C, cbufRead, sizeof(cbufRead), &cbufReadDone, &overlaps[EVENT_READ])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): ReadFile(hC0C)"); break; } } waitingRead = TRUE; } } if (!waitingRecv && !waitingWrite) { if (cbufWriteDone < cbufRecvDone) { if (!WriteFile(hC0C, cbufRecv + cbufWriteDone, cbufRecvDone - cbufWriteDone, &written, &overlaps[EVENT_WRITTEN])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WriteFile(hC0C)"); break; } } waitingWrite = TRUE; } else { if (!ReadFile((HANDLE)hSock, cbufRecv, sizeof(cbufRecv), &cbufRecvDone, &overlaps[EVENT_RECEIVED])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): ReadFile(hSock)"); break; } } waitingRecv = TRUE; } } if (!waitingStat) { DWORD maskStat; if (!WaitCommEvent(hC0C, &maskStat, &overlaps[EVENT_STAT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("InOut(): WaitCommEvent()"); break; } } waitingStat = TRUE; DWORD stat; if (!GetCommModemStatus(hC0C, &stat)) { TraceLastError("InOut(): GetCommModemStatus()"); break; } if (!(stat & MS_DSR_ON)) { printf("DSR is OFF\n"); break; } } if ((waitingRead || waitingSend) && (waitingRecv || waitingWrite) && waitingStat) { DWORD undef; switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_READ: if (!GetOverlappedResult(hC0C, &overlaps[EVENT_READ], &cbufReadDone, FALSE)) { TraceLastError("InOut(): GetOverlappedResult(EVENT_READ)"); stop = TRUE; break; } ResetEvent(hEvents[EVENT_READ]); waitingRead = FALSE; break; case WAIT_OBJECT_0 + EVENT_SENT: if (!GetOverlappedResult((HANDLE)hSock, &overlaps[EVENT_SENT], &sent, FALSE)) { TraceLastError("InOut(): GetOverlappedResult(EVENT_SENT)"); stop = TRUE; break; } ResetEvent(hEvents[EVENT_SENT]); cbufSendDone += sent; if (cbufSendDone >= cbufReadDone) cbufSendDone = cbufReadDone = 0; waitingSend = FALSE; break; case WAIT_OBJECT_0 + EVENT_RECEIVED: if (!GetOverlappedResult((HANDLE)hSock, &overlaps[EVENT_RECEIVED], &cbufRecvDone, FALSE)) { TraceLastError("InOut(): GetOverlappedResult(EVENT_RECEIVED)"); stop = TRUE; break; } ResetEvent(hEvents[EVENT_RECEIVED]); if (!cbufRecvDone) { printf("Received EOF\n"); break; } waitingRecv = FALSE; break; case WAIT_OBJECT_0 + EVENT_WRITTEN: if (!GetOverlappedResult(hC0C, &overlaps[EVENT_WRITTEN], &written, FALSE)) { TraceLastError("InOut(): GetOverlappedResult(EVENT_WRITTEN)"); stop = TRUE; break; } ResetEvent(hEvents[EVENT_WRITTEN]); cbufWriteDone += written; if (cbufWriteDone >= cbufRecvDone) cbufWriteDone = cbufRecvDone = 0; waitingWrite = FALSE; break; case WAIT_OBJECT_0 + EVENT_STAT: if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], &undef, FALSE)) { TraceLastError("InOut(): GetOverlappedResult(EVENT_STAT)"); stop = TRUE; break; } waitingStat = FALSE; break; case WAIT_TIMEOUT: break; default: TraceLastError("InOut(): WaitForMultipleObjects()"); stop = TRUE; } } } CancelIo(hC0C); CancelIo((HANDLE)hSock); CloseEvents(EVENT_NUM, hEvents); printf("InOut() - STOP\n"); } /////////////////////////////////////////////////////////////// static BOOL WaitComReady(HANDLE hC0C) { enum { EVENT_STAT, EVENT_NUM }; HANDLE hEvents[EVENT_NUM]; OVERLAPPED overlaps[EVENT_NUM]; if (!PrepareEvents(EVENT_NUM, hEvents, overlaps)) return FALSE; BOOL fault = FALSE; if (!SetCommMask(hC0C, EV_DSR)) { TraceLastError("WaitComReady(): SetCommMask()"); fault = TRUE; } BOOL waitingStat = FALSE; while (!fault) { if (!waitingStat) { DWORD maskStat; if (!WaitCommEvent(hC0C, &maskStat, &overlaps[EVENT_STAT])) { if (::GetLastError() != ERROR_IO_PENDING) { TraceLastError("WaitComReady(): WaitCommEvent()"); fault = TRUE; break; } } waitingStat = TRUE; DWORD stat; if (!GetCommModemStatus(hC0C, &stat)) { TraceLastError("WaitComReady(): GetCommModemStatus()"); fault = TRUE; break; } if (stat & MS_DSR_ON) { printf("DSR is ON\n"); Sleep(1000); if (!GetCommModemStatus(hC0C, &stat)) { TraceLastError("WaitComReady(): GetCommModemStatus()"); fault = TRUE; break; } if (stat & MS_DSR_ON) break; // OK if DSR is still ON printf("DSR is OFF\n"); } } if (waitingStat) { DWORD undef; switch (WaitForMultipleObjects(EVENT_NUM, hEvents, FALSE, 5000)) { case WAIT_OBJECT_0 + EVENT_STAT: if (!GetOverlappedResult(hC0C, &overlaps[EVENT_STAT], &undef, FALSE)) { TraceLastError("WaitComReady(): GetOverlappedResult(EVENT_STAT)"); fault = TRUE; } waitingStat = FALSE; break; case WAIT_TIMEOUT: break; default: TraceLastError("WaitComReady(): WaitForMultipleObjects()"); fault = TRUE; } } } CancelIo(hC0C); CloseEvents(EVENT_NUM, hEvents); printf("WaitComReady() - %s\n", fault ? "FAIL" : "OK"); return !fault; } /////////////////////////////////////////////////////////////// static HANDLE OpenC0C(const char *pPath) { HANDLE hC0C = CreateFile(pPath, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (hC0C == INVALID_HANDLE_VALUE) { TraceLastError("OpenC0C(): CreateFile(\"%s\")", pPath); return INVALID_HANDLE_VALUE; } DCB dcb; if (!myGetCommState(hC0C, &dcb)) { CloseHandle(hC0C); return INVALID_HANDLE_VALUE; } dcb.BaudRate = CBR_19200; dcb.ByteSize = 8; dcb.Parity = NOPARITY; dcb.StopBits = ONESTOPBIT; dcb.fOutxCtsFlow = TRUE; dcb.fOutxDsrFlow = FALSE; dcb.fDsrSensitivity = TRUE; dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; dcb.fDtrControl = DTR_CONTROL_ENABLE; dcb.fOutX = FALSE; dcb.fInX = TRUE; dcb.XonChar = 0x11; dcb.XoffChar = 0x13; dcb.XonLim = 100; dcb.XoffLim = 100; dcb.fParity = FALSE; dcb.fNull = FALSE; if (!mySetCommState(hC0C, &dcb)) { CloseHandle(hC0C); return INVALID_HANDLE_VALUE; } COMMTIMEOUTS timeouts; if (!GetCommTimeouts(hC0C, &timeouts)) { TraceLastError("OpenC0C(): GetCommTimeouts()"); CloseHandle(hC0C); return INVALID_HANDLE_VALUE; } timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.ReadTotalTimeoutMultiplier = MAXDWORD; timeouts.ReadTotalTimeoutConstant = MAXDWORD - 1; timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.WriteTotalTimeoutMultiplier = 0; timeouts.WriteTotalTimeoutConstant = 0; if (!SetCommTimeouts(hC0C, &timeouts)) { TraceLastError("OpenC0C(): SetCommTimeouts()"); CloseHandle(hC0C); return INVALID_HANDLE_VALUE; } printf("OpenC0C(\"%s\") - OK\n", pPath); return hC0C; } /////////////////////////////////////////////////////////////// static SOCKET Connect(const char *pAddr, const char *pPort) { struct sockaddr_in sn; memset(&sn, 0, sizeof(sn)); sn.sin_family = AF_INET; sn.sin_port = htons((u_short)atoi(pPort)); unsigned long addr = inet_addr(pAddr); const struct hostent *pHostEnt = (addr == INADDR_NONE) ? gethostbyname(pAddr) : gethostbyaddr((const char *)&addr, 4, AF_INET); if (!pHostEnt) { TraceLastError("Connect(): gethostbyname(\"%s\")", pAddr); return INVALID_SOCKET; } memcpy(&sn.sin_addr, pHostEnt->h_addr, pHostEnt->h_length); const struct protoent *pProtoEnt; pProtoEnt = getprotobyname("tcp"); if (!pProtoEnt) { TraceLastError("Connect(): getprotobyname(\"tcp\")"); return INVALID_SOCKET; } SOCKET hSock = socket(AF_INET, SOCK_STREAM, pProtoEnt->p_proto); if (hSock == INVALID_SOCKET) { TraceLastError("Connect(): socket()"); return INVALID_SOCKET; } if (connect(hSock, (struct sockaddr *)&sn, sizeof(sn)) == SOCKET_ERROR) { TraceLastError("Connect(): connect()"); closesocket(hSock); return INVALID_SOCKET; } printf("Connect(\"%s\", \"%s\") - OK\n", pAddr, pPort); return hSock; } static void Disconnect(SOCKET hSock) { if (shutdown(hSock, SD_BOTH) != 0) TraceLastError("Disconnect(): shutdown()"); if (closesocket(hSock) != 0) TraceLastError("Disconnect(): closesocket()"); printf("Disconnect() - OK\n"); } /////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { if (argc != 4) { printf("Usage:\n"); printf(" %s \\\\.\\<com port> <host addr> <host port>\n", argv[0]); return 1; } HANDLE hC0C = OpenC0C(argv[1]); if (hC0C == INVALID_HANDLE_VALUE) { return 2; } WSADATA wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); while (WaitComReady(hC0C)) { SOCKET hSock = Connect(argv[2], argv[3]); if (hSock == INVALID_SOCKET) break; InOut(hC0C, hSock); Disconnect(hSock); } CloseHandle(hC0C); WSACleanup(); return 0; } /////////////////////////////////////////////////////////////// --- NEW FILE: com2tcp.dsw --- Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "com2tcp"=.\com2tcp.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### |
From: Vyacheslav F. <vf...@us...> - 2005-05-20 12:06:15
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15791 Modified Files: adddev.c com0com.h Log Message: Improved port numbering Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/adddev.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** adddev.c 12 May 2005 07:41:27 -0000 1.2 --- adddev.c 20 May 2005 12:06:05 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2005/05/20 12:06:05 vfrolov + * Improved port numbering + * * Revision 1.2 2005/05/12 07:41:27 vfrolov * Added ability to change the port names *************** *** 363,370 **** } ! NTSTATUS AddFdoBus(IN PDRIVER_OBJECT pDrvObj, IN PDEVICE_OBJECT pPhDevObj) { ! static LONG numNext = 0; NTSTATUS status = STATUS_SUCCESS; UNICODE_STRING portName; --- 366,413 ---- } ! ULONG AllocPortNum(IN PDRIVER_OBJECT pDrvObj) { ! static ULONG numNext = 0; ! ! PDEVICE_OBJECT pDevObj; ! ULONG num; ! PCHAR pBusyMask; ! SIZE_T busyMaskLen; ! ! if (!numNext) ! return numNext++; ! ! busyMaskLen = numNext; ! pBusyMask = ExAllocatePool(PagedPool, busyMaskLen); ! ! if (!pBusyMask) ! return numNext++; ! ! RtlZeroMemory(pBusyMask, busyMaskLen); ! ! for (pDevObj = pDrvObj->DeviceObject ; pDevObj ; pDevObj = pDevObj->NextDevice) { ! if (((PC0C_COMMON_EXTENSION)pDevObj->DeviceExtension)->doType == C0C_DOTYPE_FB) { ! ULONG num = ((PC0C_FDOBUS_EXTENSION)pDevObj->DeviceExtension)->portNum; ! ! ASSERT(num < busyMaskLen); ! pBusyMask[num] = 1; ! } ! } + for (num = 0 ; num < busyMaskLen ; num++) { + if (!pBusyMask[num]) + break; + } + + ExFreePool(pBusyMask); + + if (num >= busyMaskLen) + return numNext++; + + return num; + } + + NTSTATUS AddFdoBus(IN PDRIVER_OBJECT pDrvObj, IN PDEVICE_OBJECT pPhDevObj) + { NTSTATUS status = STATUS_SUCCESS; UNICODE_STRING portName; *************** *** 375,379 **** int i; ! num = InterlockedIncrement(&numNext) - 1; RtlInitUnicodeString(&portName, NULL); --- 418,422 ---- int i; ! num = AllocPortNum(pDrvObj); RtlInitUnicodeString(&portName, NULL); *************** *** 413,416 **** --- 456,460 ---- } + pDevExt->portNum = num; pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/com0com.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** com0com.h 19 May 2005 08:23:40 -0000 1.7 --- com0com.h 20 May 2005 12:06:05 -0000 1.8 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.8 2005/05/20 12:06:05 vfrolov + * Improved port numbering + * * Revision 1.7 2005/05/19 08:23:40 vfrolov * Fixed data types *************** *** 64,68 **** #define C0C_DOTYPE_FP 3 ! #define C0C_PORT_NAME_LEN 10 #define COMMON_EXTENSION \ --- 67,71 ---- #define C0C_DOTYPE_FP 3 ! #define C0C_PORT_NAME_LEN 12 #define COMMON_EXTENSION \ *************** *** 189,192 **** --- 192,196 ---- KSPIN_LOCK ioLock; C0C_CHILD childs[2]; + ULONG portNum; } C0C_FDOBUS_EXTENSION, *PC0C_FDOBUS_EXTENSION; |
From: Vyacheslav F. <vf...@us...> - 2005-05-19 08:24:10
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24515 Modified Files: com0com.h io.c ioctl.c trace.c Log Message: Fixed data types Index: trace.c =================================================================== RCS file: /cvsroot/com0com/com0com/trace.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** trace.c 13 May 2005 16:58:03 -0000 1.4 --- trace.c 19 May 2005 08:23:41 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2005/05/19 08:23:41 vfrolov + * Fixed data types + * * Revision 1.4 2005/05/13 16:58:03 vfrolov * Implemented IOCTL_SERIAL_LSRMST_INSERT *************** *** 521,531 **** PSIZE_T pSize, IN PVOID pData, ! IN ULONG length) { #define DUMP_MAX 16 CHAR bufA[DUMP_MAX + 1]; ! ULONG i; ! pDestStr = AnsiStrFormat(pDestStr, pSize, "%lu:", length); for (i = 0 ; i < length && i < DUMP_MAX ; i++) { --- 524,534 ---- PSIZE_T pSize, IN PVOID pData, ! IN SIZE_T length) { #define DUMP_MAX 16 CHAR bufA[DUMP_MAX + 1]; ! SIZE_T i; ! pDestStr = AnsiStrFormat(pDestStr, pSize, "%lu:", (ULONG)length); for (i = 0 ; i < length && i < DUMP_MAX ; i++) { *************** *** 750,754 **** } ! InterlockedExchange(&strOldFreeInd, sizeof(strOld) - size); KeReleaseSpinLock(&strOldLock, oldIrql); --- 753,757 ---- } ! InterlockedExchange(&strOldFreeInd, (LONG)(sizeof(strOld) - size)); KeReleaseSpinLock(&strOldLock, oldIrql); *************** *** 802,806 **** RtlCopyMemory(pDestStr, &strOld[strOldBusyInd], lenBuf); pDestStr[lenBuf] = 0; ! strOldBusyInd += lenBuf; ASSERT(strOldBusyInd <= strOldFreeInd); if (strOldBusyInd == strOldFreeInd) --- 805,809 ---- RtlCopyMemory(pDestStr, &strOld[strOldBusyInd], lenBuf); pDestStr[lenBuf] = 0; ! strOldBusyInd += (LONG)lenBuf; ASSERT(strOldBusyInd <= strOldFreeInd); if (strOldBusyInd == strOldFreeInd) *************** *** 1005,1009 **** PC0C_COMMON_EXTENSION pDevExt; PVOID pSysBuf; ! ULONG inform, major; if (!TRACE_FILE_OK) --- 1008,1013 ---- PC0C_COMMON_EXTENSION pDevExt; PVOID pSysBuf; ! ULONG_PTR inform; ! ULONG major; if (!TRACE_FILE_OK) Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/com0com.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** com0com.h 14 May 2005 17:07:02 -0000 1.6 --- com0com.h 19 May 2005 08:23:40 -0000 1.7 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.7 2005/05/19 08:23:40 vfrolov + * Fixed data types + * * Revision 1.6 2005/05/14 17:07:02 vfrolov * Implemented SERIAL_LSRMST_MST insertion *************** *** 95,99 **** PUCHAR pFree; PUCHAR pEnd; ! ULONG busy; BOOLEAN escape; C0C_RAW_DATA insertData; --- 98,102 ---- PUCHAR pFree; PUCHAR pEnd; ! SIZE_T busy; BOOLEAN escape; C0C_RAW_DATA insertData; Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/ioctl.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ioctl.c 14 May 2005 17:07:02 -0000 1.4 --- ioctl.c 19 May 2005 08:23:41 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2005/05/19 08:23:41 vfrolov + * Fixed data types + * * Revision 1.4 2005/05/14 17:07:02 vfrolov * Implemented SERIAL_LSRMST_MST insertion *************** *** 169,173 **** KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); RtlZeroMemory(pSysBuf, sizeof(*pSysBuf)); ! pSysBuf->AmountInInQueue = pDevExt->pIoPortLocal->readBuf.busy; KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); pIrp->IoStatus.Information = sizeof(SERIAL_STATUS); --- 172,176 ---- KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); RtlZeroMemory(pSysBuf, sizeof(*pSysBuf)); ! pSysBuf->AmountInInQueue = (ULONG)pDevExt->pIoPortLocal->readBuf.busy; KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); pIrp->IoStatus.Information = sizeof(SERIAL_STATUS); *************** *** 426,430 **** pSysBuf->CurrentTxQueue = 0; pSysBuf->CurrentRxQueue = ! pDevExt->pIoPortLocal->readBuf.pEnd - pDevExt->pIoPortLocal->readBuf.pBase; pIrp->IoStatus.Information = sizeof(SERIAL_COMMPROP); --- 429,433 ---- pSysBuf->CurrentTxQueue = 0; pSysBuf->CurrentRxQueue = ! (ULONG)(pDevExt->pIoPortLocal->readBuf.pEnd - pDevExt->pIoPortLocal->readBuf.pBase); pIrp->IoStatus.Information = sizeof(SERIAL_COMMPROP); *************** *** 475,479 **** if (pReadBuf->pBase) { while (pReadBuf->busy) { ! ULONG length; length = pReadBuf->pFree <= pReadBuf->pBusy ? --- 478,482 ---- if (pReadBuf->pBase) { while (pReadBuf->busy) { ! SIZE_T length; length = pReadBuf->pFree <= pReadBuf->pBusy ? Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/io.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** io.c 14 May 2005 17:07:02 -0000 1.5 --- io.c 19 May 2005 08:23:41 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2005/05/19 08:23:41 vfrolov + * Fixed data types + * * Revision 1.5 2005/05/14 17:07:02 vfrolov * Implemented SERIAL_LSRMST_MST insertion *************** *** 44,48 **** (((PUCHAR)(pIrp)->AssociatedIrp.SystemBuffer) + (pIrp)->IoStatus.Information) ! VOID CompactRawData(PC0C_RAW_DATA pRawData, ULONG writeDone) { if (writeDone) { --- 47,51 ---- (((PUCHAR)(pIrp)->AssociatedIrp.SystemBuffer) + (pIrp)->IoStatus.Information) ! VOID CompactRawData(PC0C_RAW_DATA pRawData, SIZE_T writeDone) { if (writeDone) { *************** *** 67,71 **** if (free > 0) { ! ULONG length; if (free > pSrcRawData->size) --- 70,74 ---- if (free > 0) { ! SIZE_T length; if (free > pSrcRawData->size) *************** *** 92,96 **** for (;;) { ! ULONG length, writeLength, readLength; PUCHAR pWriteBuf, pReadBuf; --- 95,99 ---- for (;;) { ! SIZE_T length, writeLength, readLength; PUCHAR pWriteBuf, pReadBuf; *************** *** 166,176 **** VOID CopyCharsWithEscape( PC0C_BUFFER pBuf, UCHAR escapeChar, ! PUCHAR pReadBuf, ULONG readLength, ! PUCHAR pWriteBuf, ULONG writeLength, ! PULONG pReadDone, ! PULONG pWriteDone) { ! ULONG readDone; ! ULONG writeDone; readDone = 0; --- 169,179 ---- VOID CopyCharsWithEscape( PC0C_BUFFER pBuf, UCHAR escapeChar, ! PUCHAR pReadBuf, SIZE_T readLength, ! PUCHAR pWriteBuf, SIZE_T writeLength, ! PSIZE_T pReadDone, ! PSIZE_T pWriteDone) { ! SIZE_T readDone; ! SIZE_T writeDone; readDone = 0; *************** *** 184,188 **** if (pBuf->insertData.size && readLength) { ! ULONG length = pBuf->insertData.size; if (length > readLength) --- 187,191 ---- if (pBuf->insertData.size && readLength) { ! SIZE_T length = pBuf->insertData.size; if (length > readLength) *************** *** 245,251 **** for (;;) { ! ULONG writeLength, readLength; PVOID pWriteBuf, pReadBuf; - ULONG readDone, writeDone; writeLength = pIrpStack->Parameters.Write.Length - pIrp->IoStatus.Information; --- 248,254 ---- for (;;) { ! SIZE_T readDone, writeDone; ! SIZE_T writeLength, readLength; PVOID pWriteBuf, pReadBuf; writeLength = pIrpStack->Parameters.Write.Length - pIrp->IoStatus.Information; *************** *** 258,262 **** pWriteBuf = GET_REST_BUFFER(pIrp); ! if ((ULONG)(pBuf->pEnd - pBuf->pBase) <= pBuf->busy) break; --- 261,265 ---- pWriteBuf = GET_REST_BUFFER(pIrp); ! if ((SIZE_T)(pBuf->pEnd - pBuf->pBase) <= pBuf->busy) break; *************** *** 296,302 **** for (;;) { ! ULONG writeLength, readLength; PVOID pWriteBuf, pReadBuf; - ULONG readDone, writeDone; writeLength = pRawData->size; --- 299,305 ---- for (;;) { ! SIZE_T readDone, writeDone; ! SIZE_T writeLength, readLength; PVOID pWriteBuf, pReadBuf; writeLength = pRawData->size; *************** *** 309,313 **** pWriteBuf = pRawData->data; ! if ((ULONG)(pBuf->pEnd - pBuf->pBase) <= pBuf->busy) break; --- 312,316 ---- pWriteBuf = pRawData->data; ! if ((SIZE_T)(pBuf->pEnd - pBuf->pBase) <= pBuf->busy) break; *************** *** 346,353 **** { PC0C_IO_PORT pReadIoPort; ! ULONG readDone, writeDone; PIRP pIrpRead, pIrpWrite; PNTSTATUS pStatusRead, pStatusWrite; ! ULONG writeLength, readLength; PVOID pWriteBuf, pReadBuf; --- 349,356 ---- { PC0C_IO_PORT pReadIoPort; ! SIZE_T readDone, writeDone; PIRP pIrpRead, pIrpWrite; PNTSTATUS pStatusRead, pStatusWrite; ! SIZE_T writeLength, readLength; PVOID pWriteBuf, pReadBuf; *************** *** 398,403 **** PC0C_BUFFER pBuf) { ! ULONG readDone, writeDone; ! ULONG writeLength, readLength; PVOID pWriteBuf, pReadBuf; --- 401,406 ---- PC0C_BUFFER pBuf) { ! SIZE_T readDone, writeDone; ! SIZE_T writeLength, readLength; PVOID pWriteBuf, pReadBuf; |
From: Vyacheslav F. <vf...@us...> - 2005-05-17 15:08:19
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3798 Modified Files: strutils.h Log Message: Fixed parameter type typo Index: strutils.h =================================================================== RCS file: /cvsroot/com0com/com0com/strutils.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** strutils.h 26 Jan 2005 12:18:54 -0000 1.1 --- strutils.h 17 May 2005 15:07:36 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/05/17 15:07:36 vfrolov + * Fixed parameter type typo + * * Revision 1.1 2005/01/26 12:18:54 vfrolov * Initial revision *************** *** 29,33 **** #define _C0C_STRUTILS_H_ ! NTSTATUS CopyStrW(OUT PWCHAR pDestStr, IN ULONG size, IN PWCHAR pStr); NTSTATUS DupStrW(OUT PWCHAR *ppDestStr, IN PWCHAR pStr, IN BOOLEAN multiStr); --- 32,36 ---- #define _C0C_STRUTILS_H_ ! NTSTATUS CopyStrW(OUT PWCHAR pDestStr, IN SIZE_T size, IN PWCHAR pStr); NTSTATUS DupStrW(OUT PWCHAR *ppDestStr, IN PWCHAR pStr, IN BOOLEAN multiStr); |
From: Vyacheslav F. <vf...@us...> - 2005-05-17 15:06:28
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3541 Modified Files: pnp.c Log Message: Fixed type cast Index: pnp.c =================================================================== RCS file: /cvsroot/com0com/com0com/pnp.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pnp.c 26 Jan 2005 12:18:54 -0000 1.1 --- pnp.c 17 May 2005 15:06:18 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/05/17 15:06:18 vfrolov + * Fixed type cast + * * Revision 1.1 2005/01/26 12:18:54 vfrolov * Initial revision *************** *** 133,137 **** } ! pIrp->IoStatus.Information = (ULONG)pIDs; return status; --- 136,140 ---- } ! pIrp->IoStatus.Information = (ULONG_PTR)pIDs; return status; *************** *** 173,177 **** if (NT_SUCCESS(status)) ! pIrp->IoStatus.Information = (UINT_PTR)portText.Buffer; } break; --- 176,180 ---- if (NT_SUCCESS(status)) ! pIrp->IoStatus.Information = (ULONG_PTR)portText.Buffer; } break; *************** *** 184,188 **** if (NT_SUCCESS(status)) ! pIrp->IoStatus.Information = (UINT_PTR)portText.Buffer; } break; --- 187,191 ---- if (NT_SUCCESS(status)) ! pIrp->IoStatus.Information = (ULONG_PTR)portText.Buffer; } break; |
From: Vyacheslav F. <vf...@us...> - 2005-05-17 14:23:57
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27204 Modified Files: ReadMe.txt com0com.rc Log Message: Changed version Index: com0com.rc =================================================================== RCS file: /cvsroot/com0com/com0com/com0com.rc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** com0com.rc 1 Feb 2005 09:09:28 -0000 1.2 --- com0com.rc 17 May 2005 14:23:42 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2005/05/17 14:23:42 vfrolov + * Changed version + * * Revision 1.2 2005/02/01 09:09:28 vfrolov * Added version info *************** *** 30,35 **** #include "c0clog.rc" ! #define VER_VERSION 1,0,0,0 ! #define VER_VERSION_STR "1.0.0.0" #define VER_PODUCT_NAME_STR "Null-modem emulator" --- 33,38 ---- #include "c0clog.rc" ! #define VER_VERSION 1,1,0,0 ! #define VER_VERSION_STR "1.1.0.0" #define VER_PODUCT_NAME_STR "Null-modem emulator" Index: ReadMe.txt =================================================================== RCS file: /cvsroot/com0com/com0com/ReadMe.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReadMe.txt 12 May 2005 07:41:27 -0000 1.3 --- ReadMe.txt 17 May 2005 14:23:42 -0000 1.4 *************** *** 5,9 **** INTRODUCTION ! The null-modem emulator is a kernel-mode serial driver for Windows. You can create an unlimited number of virtual COM port pairs and use any pair to connect one application to another. --- 5,9 ---- INTRODUCTION ! The null-modem emulator is a kernel-mode virtual serial port driver for Windows. You can create an unlimited number of virtual COM port pairs and use any pair to connect one application to another. |
From: Vyacheslav F. <vf...@us...> - 2005-05-14 17:07:11
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2477 Modified Files: com0com.h io.c ioctl.c openclos.c Log Message: Implemented SERIAL_LSRMST_MST insertion Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/io.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** io.c 13 May 2005 16:58:03 -0000 1.4 --- io.c 14 May 2005 17:07:02 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2005/05/14 17:07:02 vfrolov + * Implemented SERIAL_LSRMST_MST insertion + * * Revision 1.4 2005/05/13 16:58:03 vfrolov * Implemented IOCTL_SERIAL_LSRMST_INSERT *************** *** 41,44 **** --- 44,86 ---- (((PUCHAR)(pIrp)->AssociatedIrp.SystemBuffer) + (pIrp)->IoStatus.Information) + VOID CompactRawData(PC0C_RAW_DATA pRawData, ULONG writeDone) + { + if (writeDone) { + pRawData->size = (UCHAR)(pRawData->size - writeDone); + + if (pRawData->size) { + ASSERT((pRawData->size + writeDone) <= sizeof(pRawData->data)); + + RtlMoveMemory(pRawData->data, pRawData->data + writeDone, pRawData->size); + } + } + } + + NTSTATUS MoveRawData(PC0C_RAW_DATA pDstRawData, PC0C_RAW_DATA pSrcRawData) + { + int free; + + if (!pSrcRawData->size) + return STATUS_SUCCESS; + + free = sizeof(pDstRawData->data) - pDstRawData->size; + + if (free > 0) { + ULONG length; + + if (free > pSrcRawData->size) + length = pSrcRawData->size; + else + length = free; + + ASSERT((pDstRawData->size + length) <= sizeof(pDstRawData->data)); + + RtlCopyMemory(pDstRawData->data + pDstRawData->size, pSrcRawData->data, length); + pDstRawData->size = (UCHAR)(pDstRawData->size + length); + CompactRawData(pSrcRawData, length); + } + return pSrcRawData->size ? STATUS_PENDING : STATUS_SUCCESS; + } + NTSTATUS ReadBuffer(PIRP pIrp, PC0C_BUFFER pBuf) { *************** *** 68,73 **** pIrp->IoStatus.Information++; readLength--; ! if (!readLength) status = STATUS_SUCCESS; } break; --- 110,133 ---- pIrp->IoStatus.Information++; readLength--; ! if (!readLength) { status = STATUS_SUCCESS; + break; + } + } + if (pBuf->insertData.size) { + length = pBuf->insertData.size; + + if (length > readLength) + length = readLength; + + RtlCopyMemory(pReadBuf, pBuf->insertData.data, length); + pReadBuf += length; + pIrp->IoStatus.Information += length; + readLength -= length; + CompactRawData(&pBuf->insertData, length); + if (!readLength) { + status = STATUS_SUCCESS; + break; + } } break; *************** *** 105,109 **** VOID CopyCharsWithEscape( ! PC0C_IO_PORT pReadIoPort, PUCHAR pReadBuf, ULONG readLength, PUCHAR pWriteBuf, ULONG writeLength, --- 165,169 ---- VOID CopyCharsWithEscape( ! PC0C_BUFFER pBuf, UCHAR escapeChar, PUCHAR pReadBuf, ULONG readLength, PUCHAR pWriteBuf, ULONG writeLength, *************** *** 113,122 **** ULONG readDone; ULONG writeDone; - UCHAR escapeChar; readDone = 0; ! if (pReadIoPort->readBuf.escape && readLength) { ! pReadIoPort->readBuf.escape = FALSE; *pReadBuf++ = SERIAL_LSRMST_ESCAPE; readDone++; --- 173,181 ---- ULONG readDone; ULONG writeDone; readDone = 0; ! if (pBuf->escape && readLength) { ! pBuf->escape = FALSE; *pReadBuf++ = SERIAL_LSRMST_ESCAPE; readDone++; *************** *** 124,128 **** } ! escapeChar = pReadIoPort->escapeChar; if (!escapeChar) { --- 183,198 ---- } ! if (pBuf->insertData.size && readLength) { ! ULONG length = pBuf->insertData.size; ! ! if (length > readLength) ! length = readLength; ! ! RtlCopyMemory(pReadBuf, pBuf->insertData.data, length); ! pReadBuf += length; ! readDone += length; ! readLength -= length; ! CompactRawData(&pBuf->insertData, length); ! } if (!escapeChar) { *************** *** 149,153 **** if (curChar == escapeChar) { if (!readLength--) { ! pReadIoPort->readBuf.escape = TRUE; break; } --- 219,223 ---- if (curChar == escapeChar) { if (!readLength--) { ! pBuf->escape = TRUE; break; } *************** *** 186,189 **** --- 256,261 ---- } + pWriteBuf = GET_REST_BUFFER(pIrp); + if ((ULONG)(pBuf->pEnd - pBuf->pBase) <= pBuf->busy) break; *************** *** 192,200 **** pBuf->pEnd - pBuf->pFree : pBuf->pBusy - pBuf->pFree; - pWriteBuf = GET_REST_BUFFER(pIrp); pReadBuf = pBuf->pFree; CopyCharsWithEscape( ! pReadIoPort, pReadBuf, readLength, pWriteBuf, writeLength, --- 264,271 ---- pBuf->pEnd - pBuf->pFree : pBuf->pBusy - pBuf->pFree; pReadBuf = pBuf->pFree; CopyCharsWithEscape( ! pBuf, pReadIoPort->escapeChar, pReadBuf, readLength, pWriteBuf, writeLength, *************** *** 215,218 **** --- 286,340 ---- } + NTSTATUS InsertBuffer(PC0C_RAW_DATA pRawData, PC0C_BUFFER pBuf) + { + NTSTATUS status; + + if (!pBuf->pBase) + return STATUS_PENDING; + + status = STATUS_PENDING; + + for (;;) { + ULONG writeLength, readLength; + PVOID pWriteBuf, pReadBuf; + ULONG readDone, writeDone; + + writeLength = pRawData->size; + + if (!writeLength) { + status = STATUS_SUCCESS; + break; + } + + pWriteBuf = pRawData->data; + + if ((ULONG)(pBuf->pEnd - pBuf->pBase) <= pBuf->busy) + break; + + readLength = pBuf->pBusy <= pBuf->pFree ? + pBuf->pEnd - pBuf->pFree : pBuf->pBusy - pBuf->pFree; + + pReadBuf = pBuf->pFree; + + CopyCharsWithEscape( + pBuf, 0, + pReadBuf, readLength, + pWriteBuf, writeLength, + &readDone, &writeDone); + + pBuf->busy += readDone; + pBuf->pFree += readDone; + if (pBuf->pFree == pBuf->pEnd) + pBuf->pFree = pBuf->pBase; + + CompactRawData(pRawData, writeDone); + } + + if (status == STATUS_PENDING) + status = MoveRawData(&pBuf->insertData, pRawData); + + return status; + } + VOID ReadWriteDirect( PIRP pIrpLocal, *************** *** 246,250 **** pReadBuf = GET_REST_BUFFER(pIrpRead); readLength = IoGetCurrentIrpStackLocation(pIrpRead)->Parameters.Read.Length ! - pIrpRemote->IoStatus.Information; pWriteBuf = GET_REST_BUFFER(pIrpWrite); writeLength = IoGetCurrentIrpStackLocation(pIrpWrite)->Parameters.Write.Length --- 368,372 ---- pReadBuf = GET_REST_BUFFER(pIrpRead); readLength = IoGetCurrentIrpStackLocation(pIrpRead)->Parameters.Read.Length ! - pIrpRead->IoStatus.Information; pWriteBuf = GET_REST_BUFFER(pIrpWrite); writeLength = IoGetCurrentIrpStackLocation(pIrpWrite)->Parameters.Write.Length *************** *** 252,256 **** CopyCharsWithEscape( ! pReadIoPort, pReadBuf, readLength, pWriteBuf, writeLength, --- 374,378 ---- CopyCharsWithEscape( ! &pReadIoPort->readBuf, pReadIoPort->escapeChar, pReadBuf, readLength, pWriteBuf, writeLength, *************** *** 269,272 **** --- 391,426 ---- } + VOID InsertDirect( + PC0C_RAW_DATA pRawData, + PIRP pIrpRead, + PNTSTATUS pStatusWrite, + PNTSTATUS pStatusRead, + PC0C_BUFFER pBuf) + { + ULONG readDone, writeDone; + ULONG writeLength, readLength; + PVOID pWriteBuf, pReadBuf; + + pReadBuf = GET_REST_BUFFER(pIrpRead); + readLength = IoGetCurrentIrpStackLocation(pIrpRead)->Parameters.Read.Length + - pIrpRead->IoStatus.Information; + pWriteBuf = pRawData->data; + writeLength = pRawData->size; + + CopyCharsWithEscape( + pBuf, 0, + pReadBuf, readLength, + pWriteBuf, writeLength, + &readDone, &writeDone); + + pIrpRead->IoStatus.Information += readDone; + CompactRawData(pRawData, writeDone); + + if (readDone == readLength) + *pStatusRead = STATUS_SUCCESS; + if (writeDone == writeLength) + *pStatusWrite = STATUS_SUCCESS; + } + NTSTATUS FdoPortIo( int ioType, *************** *** 322,325 **** --- 476,483 ---- statusCurrent = STATUS_SUCCESS; break; + case C0C_IO_TYPE_INSERT: + ASSERT(pParam); + InsertDirect((PC0C_RAW_DATA)pParam, pIrpCurrent, &status, &statusCurrent, &pIoPort->readBuf); + break; } *************** *** 369,377 **** } ! if (ioType == C0C_IO_TYPE_WRITE && status == STATUS_PENDING) { ! ASSERT(pParam); ! status = WriteBuffer((PIRP)pParam, pIoPort, pQueueToComplete); } - return status; } --- 527,542 ---- } ! if (status == STATUS_PENDING) { ! switch (ioType) { ! case C0C_IO_TYPE_WRITE: ! ASSERT(pParam); ! status = WriteBuffer((PIRP)pParam, pIoPort, pQueueToComplete); ! break; ! case C0C_IO_TYPE_INSERT: ! ASSERT(pParam); ! status = InsertBuffer((PC0C_RAW_DATA)pParam, &pIoPort->readBuf); ! break; ! } } return status; } *************** *** 380,384 **** IN PC0C_IO_PORT pIoPort, IN ULONG bits, ! IN BOOLEAN set) { ULONG modemStatusOld; --- 545,550 ---- IN PC0C_IO_PORT pIoPort, IN ULONG bits, ! IN BOOLEAN set, ! PLIST_ENTRY pQueueToComplete) { ULONG modemStatusOld; *************** *** 403,417 **** modemStatusChanged = modemStatusOld ^ pIoPort->modemStatus; ! if (modemStatusChanged & C0C_MSB_CTS) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_CTS; ! if (modemStatusChanged & C0C_MSB_DSR) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_DSR; ! if (modemStatusChanged & C0C_MSB_RING) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_RING; ! if (modemStatusChanged & C0C_MSB_RLSD) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_RLSD; } --- 569,607 ---- modemStatusChanged = modemStatusOld ^ pIoPort->modemStatus; ! if (modemStatusChanged) { ! if (pIoPort->escapeChar) { ! C0C_RAW_DATA insertData; ! insertData.size = 3; ! insertData.data[0] = pIoPort->escapeChar; ! insertData.data[1] = SERIAL_LSRMST_MST; ! insertData.data[2] = (UCHAR)(pIoPort->modemStatus | (modemStatusChanged >> 4)); ! FdoPortIo( ! C0C_IO_TYPE_INSERT, ! &insertData, ! pIoPort, ! &pIoPort->irpQueues[C0C_QUEUE_READ], ! pQueueToComplete); ! #if DBG ! if (insertData.size) ! Trace0((PC0C_COMMON_EXTENSION)pIoPort->pDevExt, L"WARNING: Lost SERIAL_LSRMST_MST"); ! #endif /* DBG */ ! } ! if (modemStatusChanged & C0C_MSB_CTS) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_CTS; ! ! if (modemStatusChanged & C0C_MSB_DSR) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_DSR; ! ! if (modemStatusChanged & C0C_MSB_RING) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_RING; ! ! if (modemStatusChanged & C0C_MSB_RLSD) ! pIoPort->eventMask |= pIoPort->waitMask & SERIAL_EV_RLSD; ! ! WaitComplete(pIoPort, pQueueToComplete); ! } } *************** *** 436,441 **** if (bits) ! SetModemStatus(pDevExt->pIoPortRemote, bits, TRUE); ! ! WaitComplete(pDevExt->pIoPortRemote, pQueueToComplete); } --- 626,629 ---- if (bits) ! SetModemStatus(pDevExt->pIoPortRemote, bits, TRUE, pQueueToComplete); } Index: openclos.c =================================================================== RCS file: /cvsroot/com0com/com0com/openclos.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** openclos.c 13 May 2005 16:58:03 -0000 1.4 --- openclos.c 14 May 2005 17:07:02 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2005/05/14 17:07:02 vfrolov + * Implemented SERIAL_LSRMST_MST insertion + * * Revision 1.4 2005/05/13 16:58:03 vfrolov * Implemented IOCTL_SERIAL_LSRMST_INSERT *************** *** 103,109 **** KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); ! SetModemStatus(pDevExt->pIoPortRemote, C0C_MSB_CTS | C0C_MSB_DSR, FALSE); ! ! WaitComplete(pDevExt->pIoPortRemote, &queueToComplete); readBuf = pDevExt->pIoPortLocal->readBuf; --- 106,110 ---- KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); ! SetModemStatus(pDevExt->pIoPortRemote, C0C_MSB_CTS | C0C_MSB_DSR, FALSE, &queueToComplete); readBuf = pDevExt->pIoPortLocal->readBuf; Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/ioctl.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ioctl.c 13 May 2005 16:58:03 -0000 1.3 --- ioctl.c 14 May 2005 17:07:02 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2005/05/14 17:07:02 vfrolov + * Implemented SERIAL_LSRMST_MST insertion + * * Revision 1.3 2005/05/13 16:58:03 vfrolov * Implemented IOCTL_SERIAL_LSRMST_INSERT *************** *** 65,71 **** pDevExt->pIoPortRemote, C0C_MSB_CTS, ! (BOOLEAN)(code == IOCTL_SERIAL_SET_RTS)); ! ! WaitComplete(pDevExt->pIoPortRemote, &queueToComplete); KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); --- 68,73 ---- pDevExt->pIoPortRemote, C0C_MSB_CTS, ! (BOOLEAN)(code == IOCTL_SERIAL_SET_RTS), ! &queueToComplete); KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); *************** *** 90,96 **** pDevExt->pIoPortRemote, C0C_MSB_DSR, ! (BOOLEAN)(code == IOCTL_SERIAL_SET_DTR)); ! ! WaitComplete(pDevExt->pIoPortRemote, &queueToComplete); KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); --- 92,97 ---- pDevExt->pIoPortRemote, C0C_MSB_DSR, ! (BOOLEAN)(code == IOCTL_SERIAL_SET_DTR), ! &queueToComplete); KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/com0com.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** com0com.h 13 May 2005 16:58:03 -0000 1.5 --- com0com.h 14 May 2005 17:07:02 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2005/05/14 17:07:02 vfrolov + * Implemented SERIAL_LSRMST_MST insertion + * * Revision 1.5 2005/05/13 16:58:03 vfrolov * Implemented IOCTL_SERIAL_LSRMST_INSERT *************** *** 82,85 **** --- 85,93 ---- } C0C_IRP_QUEUE, *PC0C_IRP_QUEUE; + typedef struct _C0C_RAW_DATA { + UCHAR size; + UCHAR data[7]; + } C0C_RAW_DATA, *PC0C_RAW_DATA; + typedef struct _C0C_BUFFER { PUCHAR pBase; *************** *** 89,92 **** --- 97,101 ---- ULONG busy; BOOLEAN escape; + C0C_RAW_DATA insertData; } C0C_BUFFER, *PC0C_BUFFER; *************** *** 94,98 **** (buf).pFree = (buf).pBusy = (buf).pBase; \ (buf).busy = 0; \ ! (buf).escape = FALSE struct _C0C_FDOPORT_EXTENSION; --- 103,108 ---- (buf).pFree = (buf).pBusy = (buf).pBase; \ (buf).busy = 0; \ ! (buf).escape = FALSE; \ ! (buf).insertData.size = 0 struct _C0C_FDOPORT_EXTENSION; *************** *** 258,261 **** --- 268,272 ---- #define C0C_IO_TYPE_WRITE 2 #define C0C_IO_TYPE_WAIT_COMPLETE 3 + #define C0C_IO_TYPE_INSERT 4 NTSTATUS FdoPortIo( *************** *** 269,273 **** IN PC0C_IO_PORT pIoPort, IN ULONG bits, ! IN BOOLEAN set); VOID UpdateHandFlow( --- 280,285 ---- IN PC0C_IO_PORT pIoPort, IN ULONG bits, ! IN BOOLEAN set, ! PLIST_ENTRY pQueueToComplete); VOID UpdateHandFlow( |
From: Vyacheslav F. <vf...@us...> - 2005-05-13 16:58:13
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21179 Modified Files: trace.c openclos.c ioctl.c io.c com0com.h Log Message: Implemented IOCTL_SERIAL_LSRMST_INSERT Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/io.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** io.c 13 May 2005 06:32:16 -0000 1.3 --- io.c 13 May 2005 16:58:03 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2005/05/13 16:58:03 vfrolov + * Implemented IOCTL_SERIAL_LSRMST_INSERT + * * Revision 1.3 2005/05/13 06:32:16 vfrolov * Implemented SERIAL_EV_RXCHAR *************** *** 43,49 **** PIO_STACK_LOCATION pIrpStack; - if (!pBuf->pBase) - return STATUS_PENDING; - status = STATUS_PENDING; pIrpStack = IoGetCurrentIrpStackLocation(pIrp); --- 46,49 ---- *************** *** 51,55 **** for (;;) { ULONG length, writeLength, readLength; ! PVOID pWriteBuf, pReadBuf; readLength = pIrpStack->Parameters.Read.Length - pIrp->IoStatus.Information; --- 51,55 ---- for (;;) { ULONG length, writeLength, readLength; ! PUCHAR pWriteBuf, pReadBuf; readLength = pIrpStack->Parameters.Read.Length - pIrp->IoStatus.Information; *************** *** 60,70 **** } ! if (!pBuf->busy) break; writeLength = pBuf->pFree <= pBuf->pBusy ? pBuf->pEnd - pBuf->pBusy : pBuf->busy; - pReadBuf = GET_REST_BUFFER(pIrp); pWriteBuf = pBuf->pBusy; --- 60,82 ---- } ! pReadBuf = GET_REST_BUFFER(pIrp); ! ! if (!pBuf->busy) { ! if (pBuf->escape) { ! pBuf->escape = FALSE; ! *pReadBuf++ = SERIAL_LSRMST_ESCAPE; ! pIrp->IoStatus.Information++; ! readLength--; ! if (!readLength) ! status = STATUS_SUCCESS; ! } break; + } + + ASSERT(pBuf->pBase); writeLength = pBuf->pFree <= pBuf->pBusy ? pBuf->pEnd - pBuf->pBusy : pBuf->busy; pWriteBuf = pBuf->pBusy; *************** *** 92,95 **** --- 104,165 ---- } + VOID CopyCharsWithEscape( + PC0C_IO_PORT pReadIoPort, + PUCHAR pReadBuf, ULONG readLength, + PUCHAR pWriteBuf, ULONG writeLength, + PULONG pReadDone, + PULONG pWriteDone) + { + ULONG readDone; + ULONG writeDone; + UCHAR escapeChar; + + readDone = 0; + + if (pReadIoPort->readBuf.escape && readLength) { + pReadIoPort->readBuf.escape = FALSE; + *pReadBuf++ = SERIAL_LSRMST_ESCAPE; + readDone++; + readLength--; + } + + escapeChar = pReadIoPort->escapeChar; + + if (!escapeChar) { + writeDone = writeLength < readLength ? writeLength : readLength; + + if (writeDone) + RtlCopyMemory(pReadBuf, pWriteBuf, writeDone); + + readDone += writeDone; + } else { + writeDone = 0; + + while (writeLength--) { + UCHAR curChar; + + if (!readLength--) + break; + + curChar = *pWriteBuf++; + writeDone++; + *pReadBuf++ = curChar; + readDone++; + + if (curChar == escapeChar) { + if (!readLength--) { + pReadIoPort->readBuf.escape = TRUE; + break; + } + *pReadBuf++ = SERIAL_LSRMST_ESCAPE; + readDone++; + } + } + } + + *pReadDone = readDone; + *pWriteDone = writeDone; + } + NTSTATUS WriteBuffer(PIRP pIrp, PC0C_IO_PORT pReadIoPort, PLIST_ENTRY pQueueToComplete) { *************** *** 105,110 **** for (;;) { ! ULONG length, writeLength, readLength; PVOID pWriteBuf, pReadBuf; writeLength = pIrpStack->Parameters.Write.Length - pIrp->IoStatus.Information; --- 175,181 ---- for (;;) { ! ULONG writeLength, readLength; PVOID pWriteBuf, pReadBuf; + ULONG readDone, writeDone; writeLength = pIrpStack->Parameters.Write.Length - pIrp->IoStatus.Information; *************** *** 124,139 **** pReadBuf = pBuf->pFree; ! length = writeLength < readLength ? writeLength : readLength; ! ! RtlCopyMemory(pReadBuf, pWriteBuf, length); ! pBuf->busy += length; ! pBuf->pFree += length; if (pBuf->pFree == pBuf->pEnd) pBuf->pFree = pBuf->pBase; ! pIrp->IoStatus.Information += length; ! WaitCompleteRxChar(pReadIoPort, pQueueToComplete); } --- 195,213 ---- pReadBuf = pBuf->pFree; ! CopyCharsWithEscape( ! pReadIoPort, ! pReadBuf, readLength, ! pWriteBuf, writeLength, ! &readDone, &writeDone); ! pBuf->busy += readDone; ! pBuf->pFree += readDone; if (pBuf->pFree == pBuf->pEnd) pBuf->pFree = pBuf->pBase; ! pIrp->IoStatus.Information += writeDone; ! if (writeDone) ! WaitCompleteRxChar(pReadIoPort, pQueueToComplete); } *************** *** 146,193 **** PNTSTATUS pStatusLocal, PNTSTATUS pStatusRemote, ! PC0C_IO_PORT pIoPortLocal, PLIST_ENTRY pQueueToComplete) { - PIO_STACK_LOCATION pIrpStackLocal; - PIO_STACK_LOCATION pIrpStackRemote; - ULONG length, writeLength, readLength; - PVOID pWriteBuf, pReadBuf; PC0C_IO_PORT pReadIoPort; ! pIrpStackLocal = IoGetCurrentIrpStackLocation(pIrpLocal); ! pIrpStackRemote = IoGetCurrentIrpStackLocation(pIrpRemote); ! if (pIrpStackLocal->MajorFunction == IRP_MJ_WRITE) { ! pWriteBuf = GET_REST_BUFFER(pIrpLocal); ! writeLength = pIrpStackLocal->Parameters.Write.Length - pIrpLocal->IoStatus.Information; ! pReadBuf = GET_REST_BUFFER(pIrpRemote); ! readLength = pIrpStackRemote->Parameters.Read.Length - pIrpRemote->IoStatus.Information; ! pReadIoPort = pIoPortLocal->pDevExt->pIoPortRemote; ! if (writeLength <= readLength) ! *pStatusLocal = STATUS_SUCCESS; ! if (writeLength >= readLength) ! *pStatusRemote = STATUS_SUCCESS; ! } else { ! pReadBuf = GET_REST_BUFFER(pIrpLocal); ! readLength = pIrpStackLocal->Parameters.Read.Length - pIrpLocal->IoStatus.Information; ! pWriteBuf = GET_REST_BUFFER(pIrpRemote); ! writeLength = pIrpStackRemote->Parameters.Write.Length - pIrpRemote->IoStatus.Information; ! pReadIoPort = pIoPortLocal; ! if (readLength <= writeLength) ! *pStatusLocal = STATUS_SUCCESS; ! if (readLength >= writeLength) ! *pStatusRemote = STATUS_SUCCESS; ! } ! length = writeLength < readLength ? writeLength : readLength; ! if (length) { ! RtlCopyMemory(pReadBuf, pWriteBuf, length); ! pIrpRemote->IoStatus.Information += length; ! pIrpLocal->IoStatus.Information += length; WaitCompleteRxChar(pReadIoPort, pQueueToComplete); - } } --- 220,270 ---- PNTSTATUS pStatusLocal, PNTSTATUS pStatusRemote, ! PC0C_IO_PORT pIoPortRemote, PLIST_ENTRY pQueueToComplete) { PC0C_IO_PORT pReadIoPort; + ULONG readDone, writeDone; + PIRP pIrpRead, pIrpWrite; + PNTSTATUS pStatusRead, pStatusWrite; + ULONG writeLength, readLength; + PVOID pWriteBuf, pReadBuf; ! if (IoGetCurrentIrpStackLocation(pIrpLocal)->MajorFunction == IRP_MJ_WRITE) { ! pIrpRead = pIrpRemote; ! pIrpWrite = pIrpLocal; ! pStatusRead = pStatusRemote; ! pStatusWrite = pStatusLocal; ! pReadIoPort = pIoPortRemote; ! } else { ! pIrpRead = pIrpLocal; ! pIrpWrite = pIrpRemote; ! pStatusRead = pStatusLocal; ! pStatusWrite = pStatusRemote; ! pReadIoPort = pIoPortRemote->pDevExt->pIoPortRemote; ! } ! pReadBuf = GET_REST_BUFFER(pIrpRead); ! readLength = IoGetCurrentIrpStackLocation(pIrpRead)->Parameters.Read.Length ! - pIrpRemote->IoStatus.Information; ! pWriteBuf = GET_REST_BUFFER(pIrpWrite); ! writeLength = IoGetCurrentIrpStackLocation(pIrpWrite)->Parameters.Write.Length ! - pIrpWrite->IoStatus.Information; ! CopyCharsWithEscape( ! pReadIoPort, ! pReadBuf, readLength, ! pWriteBuf, writeLength, ! &readDone, &writeDone); ! pIrpRead->IoStatus.Information += readDone; ! pIrpWrite->IoStatus.Information += writeDone; ! if (readDone == readLength) ! *pStatusRead = STATUS_SUCCESS; ! if (writeDone == writeLength) ! *pStatusWrite = STATUS_SUCCESS; ! if (writeDone) WaitCompleteRxChar(pReadIoPort, pQueueToComplete); } Index: openclos.c =================================================================== RCS file: /cvsroot/com0com/com0com/openclos.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** openclos.c 1 Feb 2005 16:51:51 -0000 1.3 --- openclos.c 13 May 2005 16:58:03 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2005/05/13 16:58:03 vfrolov + * Implemented IOCTL_SERIAL_LSRMST_INSERT + * * Revision 1.3 2005/02/01 16:51:51 vfrolov * Used C0C_BUFFER_PURGE() *************** *** 79,82 **** --- 82,86 ---- pDevExt->pIoPortLocal->waitMask = 0; pDevExt->pIoPortLocal->eventMask = 0; + pDevExt->pIoPortLocal->escapeChar = 0; UpdateHandFlow(pDevExt, &queueToComplete); Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/ioctl.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ioctl.c 1 Feb 2005 16:47:57 -0000 1.2 --- ioctl.c 13 May 2005 16:58:03 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2005/05/13 16:58:03 vfrolov + * Implemented IOCTL_SERIAL_LSRMST_INSERT + * * Revision 1.2 2005/02/01 16:47:57 vfrolov * Implemented SERIAL_PURGE_RXCLEAR and IOCTL_SERIAL_GET_COMMSTATUS *************** *** 196,201 **** KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); ! pDevExt->handFlow = *pSysBuf; ! UpdateHandFlow(pDevExt, &queueToComplete); KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); --- 199,211 ---- KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); ! if (pDevExt->pIoPortLocal->escapeChar && ! (pSysBuf->FlowReplace & SERIAL_ERROR_CHAR)) { ! status = STATUS_INVALID_PARAMETER; ! } ! ! if (status == STATUS_SUCCESS) { ! pDevExt->handFlow = *pSysBuf; ! UpdateHandFlow(pDevExt, &queueToComplete); ! } KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); *************** *** 223,227 **** TraceIrp("FdoPortIoCtl", pIrp, &status, TRACE_FLAG_RESULTS); break; ! case IOCTL_SERIAL_SET_CHARS: if (pIrpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(SERIAL_CHARS)) { status = STATUS_BUFFER_TOO_SMALL; --- 233,239 ---- TraceIrp("FdoPortIoCtl", pIrp, &status, TRACE_FLAG_RESULTS); break; ! case IOCTL_SERIAL_SET_CHARS: { ! PSERIAL_CHARS pSysBuf; ! if (pIrpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(SERIAL_CHARS)) { status = STATUS_BUFFER_TOO_SMALL; *************** *** 229,236 **** } ! KeAcquireSpinLock(&pDevExt->controlLock, &oldIrql); ! pDevExt->specialChars = *(PSERIAL_CHARS)pIrp->AssociatedIrp.SystemBuffer; ! KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); break; case IOCTL_SERIAL_GET_CHARS: if (pIrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(SERIAL_CHARS)) { --- 241,261 ---- } ! pSysBuf = (PSERIAL_CHARS)pIrp->AssociatedIrp.SystemBuffer; ! ! KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); ! ! if (pDevExt->pIoPortLocal->escapeChar && ! ((pDevExt->pIoPortLocal->escapeChar == pSysBuf->XoffChar) || ! (pDevExt->pIoPortLocal->escapeChar == pSysBuf->XonChar))) ! { ! status = STATUS_INVALID_PARAMETER; ! } ! ! if (status == STATUS_SUCCESS) ! pDevExt->specialChars = *pSysBuf; ! ! KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); break; + } case IOCTL_SERIAL_GET_CHARS: if (pIrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(SERIAL_CHARS)) { *************** *** 239,245 **** } ! KeAcquireSpinLock(&pDevExt->controlLock, &oldIrql); *(PSERIAL_CHARS)pIrp->AssociatedIrp.SystemBuffer = pDevExt->specialChars; ! KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); pIrp->IoStatus.Information = sizeof(SERIAL_CHARS); --- 264,270 ---- } ! KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); *(PSERIAL_CHARS)pIrp->AssociatedIrp.SystemBuffer = pDevExt->specialChars; ! KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); pIrp->IoStatus.Information = sizeof(SERIAL_CHARS); *************** *** 247,250 **** --- 272,302 ---- TraceIrp("FdoPortIoCtl", pIrp, &status, TRACE_FLAG_RESULTS); break; + case IOCTL_SERIAL_LSRMST_INSERT: { + UCHAR escapeChar; + + if (pIrpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(UCHAR)) { + status = STATUS_BUFFER_TOO_SMALL; + break; + } + + escapeChar = *(PUCHAR)pIrp->AssociatedIrp.SystemBuffer; + + KeAcquireSpinLock(pDevExt->pIoLock, &oldIrql); + + if (escapeChar && ((escapeChar == pDevExt->specialChars.XoffChar) || + (escapeChar == pDevExt->specialChars.XonChar) || + (pDevExt->handFlow.FlowReplace & SERIAL_ERROR_CHAR))) + { + status = STATUS_INVALID_PARAMETER; + } + + if (status == STATUS_SUCCESS) { + pDevExt->pIoPortLocal->escapeChar = escapeChar; + pIrp->IoStatus.Information = sizeof(UCHAR); + } + + KeReleaseSpinLock(pDevExt->pIoLock, oldIrql); + break; + } case IOCTL_SERIAL_SET_LINE_CONTROL: if (pIrpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(SERIAL_LINE_CONTROL)) { Index: trace.c =================================================================== RCS file: /cvsroot/com0com/com0com/trace.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** trace.c 28 Feb 2005 12:10:08 -0000 1.3 --- trace.c 13 May 2005 16:58:03 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2005/05/13 16:58:03 vfrolov + * Implemented IOCTL_SERIAL_LSRMST_INSERT + * * Revision 1.3 2005/02/28 12:10:08 vfrolov * Log skipped lines to trace file (was to syslog) *************** *** 1173,1176 **** --- 1176,1183 ---- pDestStr = AnsiStrCopyCommStatus(pDestStr, &size, (PSERIAL_STATUS)pSysBuf); break; + case IOCTL_SERIAL_LSRMST_INSERT: + if ((flags & TRACE_FLAG_PARAMS) && inLength >= sizeof(UCHAR)) + pDestStr = AnsiStrFormat(pDestStr, &size, " escapeChar=0x%02X", (int)(*(PUCHAR)pSysBuf & 0xFF)); + break; } break; Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/com0com.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** com0com.h 12 May 2005 07:41:27 -0000 1.4 --- com0com.h 13 May 2005 16:58:03 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.5 2005/05/13 16:58:03 vfrolov + * Implemented IOCTL_SERIAL_LSRMST_INSERT + * * Revision 1.4 2005/05/12 07:41:27 vfrolov * Added ability to change the port names *************** *** 85,93 **** PUCHAR pEnd; ULONG busy; } C0C_BUFFER, *PC0C_BUFFER; #define C0C_BUFFER_PURGE(buf) \ (buf).pFree = (buf).pBusy = (buf).pBase; \ ! (buf).busy = 0 struct _C0C_FDOPORT_EXTENSION; --- 88,98 ---- PUCHAR pEnd; ULONG busy; + BOOLEAN escape; } C0C_BUFFER, *PC0C_BUFFER; #define C0C_BUFFER_PURGE(buf) \ (buf).pFree = (buf).pBusy = (buf).pBase; \ ! (buf).busy = 0; \ ! (buf).escape = FALSE struct _C0C_FDOPORT_EXTENSION; *************** *** 117,120 **** --- 122,126 ---- ULONG waitMask; ULONG eventMask; + UCHAR escapeChar; #define C0C_MSB_CTS 0x10 |
From: Vyacheslav F. <vf...@us...> - 2005-05-13 06:32:25
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31164 Modified Files: io.c Log Message: Implemented SERIAL_EV_RXCHAR Index: io.c =================================================================== RCS file: /cvsroot/com0com/com0com/io.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** io.c 1 Feb 2005 08:36:27 -0000 1.2 --- io.c 13 May 2005 06:32:16 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2005/05/13 06:32:16 vfrolov + * Implemented SERIAL_EV_RXCHAR + * * Revision 1.2 2005/02/01 08:36:27 vfrolov * Changed SetModemStatus() to set multiple bits and set CD to DSR *************** *** 81,88 **** } ! NTSTATUS WriteBuffer(PIRP pIrp, PC0C_BUFFER pBuf) { NTSTATUS status; PIO_STACK_LOCATION pIrpStack; if (!pBuf->pBase) --- 84,100 ---- } ! VOID WaitCompleteRxChar(PC0C_IO_PORT pReadIoPort, PLIST_ENTRY pQueueToComplete) ! { ! if (pReadIoPort->waitMask & SERIAL_EV_RXCHAR) { ! pReadIoPort->eventMask |= SERIAL_EV_RXCHAR; ! WaitComplete(pReadIoPort, pQueueToComplete); ! } ! } ! ! NTSTATUS WriteBuffer(PIRP pIrp, PC0C_IO_PORT pReadIoPort, PLIST_ENTRY pQueueToComplete) { NTSTATUS status; PIO_STACK_LOCATION pIrpStack; + PC0C_BUFFER pBuf = &pReadIoPort->readBuf; if (!pBuf->pBase) *************** *** 122,125 **** --- 134,139 ---- pIrp->IoStatus.Information += length; + + WaitCompleteRxChar(pReadIoPort, pQueueToComplete); } *************** *** 131,135 **** PIRP pIrpRemote, PNTSTATUS pStatusLocal, ! PNTSTATUS pStatusRemote) { PIO_STACK_LOCATION pIrpStackLocal; --- 145,151 ---- PIRP pIrpRemote, PNTSTATUS pStatusLocal, ! PNTSTATUS pStatusRemote, ! PC0C_IO_PORT pIoPortLocal, ! PLIST_ENTRY pQueueToComplete) { PIO_STACK_LOCATION pIrpStackLocal; *************** *** 137,140 **** --- 153,157 ---- ULONG length, writeLength, readLength; PVOID pWriteBuf, pReadBuf; + PC0C_IO_PORT pReadIoPort; pIrpStackLocal = IoGetCurrentIrpStackLocation(pIrpLocal); *************** *** 146,149 **** --- 163,167 ---- pReadBuf = GET_REST_BUFFER(pIrpRemote); readLength = pIrpStackRemote->Parameters.Read.Length - pIrpRemote->IoStatus.Information; + pReadIoPort = pIoPortLocal->pDevExt->pIoPortRemote; if (writeLength <= readLength) *************** *** 156,159 **** --- 174,178 ---- pWriteBuf = GET_REST_BUFFER(pIrpRemote); writeLength = pIrpStackRemote->Parameters.Write.Length - pIrpRemote->IoStatus.Information; + pReadIoPort = pIoPortLocal; if (readLength <= writeLength) *************** *** 165,173 **** length = writeLength < readLength ? writeLength : readLength; ! if (length) RtlCopyMemory(pReadBuf, pWriteBuf, length); ! ! pIrpRemote->IoStatus.Information += length; ! pIrpLocal->IoStatus.Information += length; } --- 184,193 ---- length = writeLength < readLength ? writeLength : readLength; ! if (length) { RtlCopyMemory(pReadBuf, pWriteBuf, length); ! pIrpRemote->IoStatus.Information += length; ! pIrpLocal->IoStatus.Information += length; ! WaitCompleteRxChar(pReadIoPort, pQueueToComplete); ! } } *************** *** 216,220 **** ASSERT(pParam); if (status == STATUS_PENDING) ! ReadWriteDirect((PIRP)pParam, pIrpCurrent, &status, &statusCurrent); break; case C0C_IO_TYPE_WAIT_COMPLETE: --- 236,240 ---- ASSERT(pParam); if (status == STATUS_PENDING) ! ReadWriteDirect((PIRP)pParam, pIrpCurrent, &status, &statusCurrent, pIoPort, pQueueToComplete); break; case C0C_IO_TYPE_WAIT_COMPLETE: *************** *** 229,233 **** if (IoGetCurrentIrpStackLocation(pIrpCurrent)->MajorFunction == IRP_MJ_WRITE && statusCurrent == STATUS_PENDING) ! statusCurrent = WriteBuffer(pIrpCurrent, &pIoPort->pDevExt->pIoPortRemote->readBuf); if (statusCurrent == STATUS_PENDING) { --- 249,253 ---- if (IoGetCurrentIrpStackLocation(pIrpCurrent)->MajorFunction == IRP_MJ_WRITE && statusCurrent == STATUS_PENDING) ! statusCurrent = WriteBuffer(pIrpCurrent, pIoPort->pDevExt->pIoPortRemote, pQueueToComplete); if (statusCurrent == STATUS_PENDING) { *************** *** 274,278 **** if (ioType == C0C_IO_TYPE_WRITE && status == STATUS_PENDING) { ASSERT(pParam); ! status = WriteBuffer((PIRP)pParam, &pIoPort->readBuf); } --- 294,298 ---- if (ioType == C0C_IO_TYPE_WRITE && status == STATUS_PENDING) { ASSERT(pParam); ! status = WriteBuffer((PIRP)pParam, pIoPort, pQueueToComplete); } |
From: Vyacheslav F. <vf...@us...> - 2005-05-12 07:41:36
|
Update of /cvsroot/com0com/com0com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21395 Modified Files: ReadMe.txt adddev.c com0com.h initunlo.c Log Message: Added ability to change the port names Index: initunlo.c =================================================================== RCS file: /cvsroot/com0com/com0com/initunlo.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** initunlo.c 26 Jan 2005 12:18:54 -0000 1.1 --- initunlo.c 12 May 2005 07:41:27 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/05/12 07:41:27 vfrolov + * Added ability to change the port names + * * Revision 1.1 2005/01/26 12:18:54 vfrolov * Initial revision *************** *** 27,37 **** #include "precomp.h" NTSTATUS DriverEntry(IN PDRIVER_OBJECT pDrvObj, IN PUNICODE_STRING pRegistryPath) { ! UNREFERENCED_PARAMETER(pRegistryPath); TraceOpen(pDrvObj, pRegistryPath); pDrvObj->DriverUnload = c0cUnload; pDrvObj->DriverExtension->AddDevice = c0cAddDevice; --- 30,53 ---- #include "precomp.h" + #include "strutils.h" + + UNICODE_STRING c0cRegistryPath; NTSTATUS DriverEntry(IN PDRIVER_OBJECT pDrvObj, IN PUNICODE_STRING pRegistryPath) { ! NTSTATUS status; TraceOpen(pDrvObj, pRegistryPath); + status = STATUS_SUCCESS; + + RtlInitUnicodeString(&c0cRegistryPath, NULL); + StrAppendStr(&status, &c0cRegistryPath, pRegistryPath->Buffer, pRegistryPath->Length); + + if (!NT_SUCCESS(status)) { + SysLog(pDrvObj, status, L"DriverEntry FAIL"); + return status; + } + pDrvObj->DriverUnload = c0cUnload; pDrvObj->DriverExtension->AddDevice = c0cAddDevice; *************** *** 58,65 **** UNREFERENCED_PARAMETER(pDrvObj); TraceClose(); } - NTSTATUS c0cFlush(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp) { --- 74,82 ---- UNREFERENCED_PARAMETER(pDrvObj); + StrFree(&c0cRegistryPath); + TraceClose(); } NTSTATUS c0cFlush(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp) { Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/adddev.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** adddev.c 26 Jan 2005 12:18:54 -0000 1.1 --- adddev.c 12 May 2005 07:41:27 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2005/05/12 07:41:27 vfrolov + * Added ability to change the port names + * * Revision 1.1 2005/01/26 12:18:54 vfrolov * Initial revision *************** *** 75,79 **** NTSTATUS AddFdoPort(IN PDRIVER_OBJECT pDrvObj, IN PDEVICE_OBJECT pPhDevObj) { ! NTSTATUS status = STATUS_SUCCESS; UNICODE_STRING portName; PDEVICE_OBJECT pNewDevObj; --- 78,82 ---- NTSTATUS AddFdoPort(IN PDRIVER_OBJECT pDrvObj, IN PDEVICE_OBJECT pPhDevObj) { ! NTSTATUS status; UNICODE_STRING portName; PDEVICE_OBJECT pNewDevObj; *************** *** 108,113 **** } ! RtlInitUnicodeString(&portName, NULL); ! StrAppendStr0(&status, &portName, pPortName); if (!NT_SUCCESS(status)) { --- 111,159 ---- } ! { ! WCHAR portNameBuf[C0C_PORT_NAME_LEN]; ! UNICODE_STRING portNameTmp; ! UNICODE_STRING portRegistryPath; ! RTL_QUERY_REGISTRY_TABLE queryTable[2]; ! ! RtlInitUnicodeString(&portRegistryPath, NULL); ! StrAppendStr(&status, &portRegistryPath, c0cRegistryPath.Buffer, c0cRegistryPath.Length); ! StrAppendStr0(&status, &portRegistryPath, L"\\Parameters\\"); ! StrAppendStr0(&status, &portRegistryPath, pPortName); ! ! if (!NT_SUCCESS(status)) { ! SysLog(pPhDevObj, status, L"AddFdoPort FAIL"); ! goto clean; ! } ! ! RtlZeroMemory(queryTable, sizeof(queryTable)); ! ! portNameTmp.Length = 0; ! portNameTmp.MaximumLength = sizeof(portNameBuf); ! portNameTmp.Buffer = portNameBuf; ! ! queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; ! queryTable[0].Name = L"PortName"; ! queryTable[0].EntryContext = &portNameTmp; ! ! status = RtlQueryRegistryValues( ! RTL_REGISTRY_ABSOLUTE, ! portRegistryPath.Buffer, ! queryTable, ! NULL, ! NULL); ! ! StrFree(&portRegistryPath); ! ! RtlInitUnicodeString(&portName, NULL); ! ! if (!NT_SUCCESS(status) || !portNameTmp.Length) { ! status = STATUS_SUCCESS; ! StrAppendStr0(&status, &portName, pPortName); ! } else { ! StrAppendStr(&status, &portName, portNameTmp.Buffer, portNameTmp.Length); ! Trace00(NULL, L"PortName set to ", portName.Buffer); ! } ! } if (!NT_SUCCESS(status)) { *************** *** 139,143 **** RtlInitUnicodeString(&pDevExt->win32DeviceName, NULL); StrAppendStr0(&status, &pDevExt->win32DeviceName, C0C_PREF_WIN32_DEVICE_NAME); ! StrAppendStr0(&status, &pDevExt->win32DeviceName, pPortName); if (!NT_SUCCESS(status)) { --- 185,189 ---- RtlInitUnicodeString(&pDevExt->win32DeviceName, NULL); StrAppendStr0(&status, &pDevExt->win32DeviceName, C0C_PREF_WIN32_DEVICE_NAME); ! StrAppendStr0(&status, &pDevExt->win32DeviceName, portName.Buffer); if (!NT_SUCCESS(status)) { Index: ReadMe.txt =================================================================== RCS file: /cvsroot/com0com/com0com/ReadMe.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReadMe.txt 4 Feb 2005 10:58:37 -0000 1.2 --- ReadMe.txt 12 May 2005 07:41:27 -0000 1.3 *************** *** 55,56 **** --- 55,65 ---- vice versa. + FAQ + + Q. Is it possible to change the names CNCA0 and CNCB0 to COM2 and COM3? + A. Yes, it's possible. Add the following to the registry: + + [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\com0com\Parameters\CNCA0] + "PortName"="COM2" + [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\com0com\Parameters\CNCB0] + "PortName"="COM3" Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/com0com.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** com0com.h 1 Feb 2005 16:47:57 -0000 1.3 --- com0com.h 12 May 2005 07:41:27 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2005/05/12 07:41:27 vfrolov + * Added ability to change the port names + * * Revision 1.3 2005/02/01 16:47:57 vfrolov * Implemented SERIAL_PURGE_RXCLEAR and IOCTL_SERIAL_GET_COMMSTATUS *************** *** 52,59 **** #define C0C_DOTYPE_FP 3 #define COMMON_EXTENSION \ int doType; \ PDEVICE_OBJECT pDevObj; \ ! WCHAR portName[10]; \ #define FDO_EXTENSION \ --- 55,64 ---- #define C0C_DOTYPE_FP 3 + #define C0C_PORT_NAME_LEN 10 + #define COMMON_EXTENSION \ int doType; \ PDEVICE_OBJECT pDevObj; \ ! WCHAR portName[C0C_PORT_NAME_LEN]; \ #define FDO_EXTENSION \ *************** *** 167,170 **** --- 172,177 ---- } C0C_FDOBUS_EXTENSION, *PC0C_FDOBUS_EXTENSION; + extern UNICODE_STRING c0cRegistryPath; + VOID c0cUnload(IN PDRIVER_OBJECT pDrvObj); |