bug #22234: WINDOWS version: HOWTO: Specify Serial Ports Larger than COM9

* ser_win32.c (ser_open): prepend \\.\ to any COM port name, so it is
safe to be used for COM ports above 9.




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@825 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2009-07-02 10:23:57 +00:00
parent 38d792793c
commit 922d1e5465
2 changed files with 27 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2009-07-02 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #22234: WINDOWS version: HOWTO: Specify Serial Ports Larger than COM9
* ser_win32.c (ser_open): prepend \\.\ to any COM port name, so it is
safe to be used for COM ports above 9.
2009-07-02 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #26408: Crash in stk500v2_open()

View File

@ -110,6 +110,7 @@ static void ser_open(char * port, long baud, union filedescriptor *fdp)
{
LPVOID lpMsgBuf;
HANDLE hComPort=INVALID_HANDLE_VALUE;
char *newname = 0;
/*
* If the port is of the form "net:<host>:<port>", then
@ -125,10 +126,22 @@ static void ser_open(char * port, long baud, union filedescriptor *fdp)
exit(1);
}
/* if (hComPort!=INVALID_HANDLE_VALUE)
fprintf(stderr, "%s: ser_open(): \"%s\" is already open\n",
progname, port);
*/
if (strncasecmp(port, "com", strlen("com")) == 0) {
// prepend "\\\\.\\" to name, required for port # >= 10
newname = malloc(strlen("\\\\.\\") + strlen(port) + 1);
if (newname == 0) {
fprintf(stderr,
"%s: ser_open(): out of memory\n",
progname);
exit(1);
}
strcpy(newname, "\\\\.\\");
strcat(newname, port);
port = newname;
}
hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@ -174,6 +187,10 @@ static void ser_open(char * port, long baud, union filedescriptor *fdp)
progname, port);
exit(1);
}
if (newname != 0) {
free(newname);
}
}