summaryrefslogtreecommitdiffstats
path: root/serial.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2010-01-26 20:58:40 +0000
committerPatrick Georgi <pgeorgi@google.com>2010-01-26 20:58:40 +0000
commit06602c239c5de952bdc384a7f41d106ed6d24dc2 (patch)
tree53911c7e2296bdb0fa6c5057ca68dcc2f76ebbe9 /serial.c
parent0bf842d0ca93919a1cad185de19c4621b6f194e6 (diff)
downloadast2050-flashrom-06602c239c5de952bdc384a7f41d106ed6d24dc2.zip
ast2050-flashrom-06602c239c5de952bdc384a7f41d106ed6d24dc2.tar.gz
Windows wants UNC names for COM ports >9 (legacy COM ports only work with one digit)
As UNC also works for smaller names, just retarget all requests for dev=COMx on win32 to \\.\COMx. Tested with large and small COM port numbers on XP. Corresponding to flashrom svn r883. Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'serial.c')
-rw-r--r--serial.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/serial.c b/serial.c
index 0fbe029..4d49e08 100644
--- a/serial.c
+++ b/serial.c
@@ -105,7 +105,15 @@ fdtype sp_openserport(char *dev, unsigned int baud)
{
#ifdef _WIN32
HANDLE fd;
- fd = CreateFile(dev, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ char* dev2 = dev;
+ if ((strlen(dev) > 3) && (tolower(dev[0])=='c') && (tolower(dev[1])=='o') && (tolower(dev[2])=='m')) {
+ dev2 = malloc(strlen(dev)+5);
+ strcpy(dev2, "\\\\.\\");
+ strcpy(dev2+4, dev);
+ }
+ fd = CreateFile(dev2, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (dev2 != dev)
+ free(dev2);
if (fd == INVALID_HANDLE_VALUE) {
sp_die("Error: cannot open serial port");
}
OpenPOWER on IntegriCloud