From 6904c732f40150b61362422fef18fdcc41c202c8 Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Wed, 5 Nov 2008 20:53:51 +0000
Subject: [PATCH] patch #6609: Using PCI parallel port cards on Windows *
 ppiwin.c (ppi_open): If the port parameter passed from the -p option is
 neither lpt1/2/3, try interpreting it directly as a base address. *
 avrdude.1: Document the change. * doc/avrdude.texi: (Ditto.)

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@786 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog        |  9 +++++++++
 avrdude.1        | 12 ++++++++++--
 doc/avrdude.texi |  5 ++++-
 ppiwin.c         | 19 +++++++++++++++++++
 4 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e4428b6e..6b65656f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-11-05  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	patch #6609: Using PCI parallel port cards on Windows
+	* ppiwin.c (ppi_open): If the port parameter passed from the
+	-p option is neither lpt1/2/3, try interpreting it directly as
+	a base address.
+	* avrdude.1: Document the change.
+	* doc/avrdude.texi: (Ditto.)
+
 2008-11-04  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	bug #22882: Erase Cycle Counter does not work for stk500v2
diff --git a/avrdude.1 b/avrdude.1
index 9575c084..26b32bb2 100644
--- a/avrdude.1
+++ b/avrdude.1
@@ -1,6 +1,6 @@
 .\"
 .\" avrdude - A Downloader/Uploader for AVR device programmers
-.\" Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007  Joerg Wunsch
+.\" Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008  Joerg Wunsch
 .\"
 .\" 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
@@ -19,7 +19,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd DATE July 27, 2008
+.Dd DATE November 5, 2008
 .Os
 .Dt AVRDUDE 1
 .Sh NAME
@@ -413,6 +413,14 @@ serial port, the
 port is the default.  If you need to use a different parallel or
 serial port, use this option to specify the alternate port name.
 .Pp
+On Win32 operating systems, the parallel ports are referred to as lpt1
+through lpt3, referring to the addresses 0x378, 0x278, and 0x3BC,
+respectively.  If the parallel port can be accessed through a different
+address, this address can be specified directly, using the common C
+language notation (i. e., hexadecimal values are prefixed by
+.Ql 0x
+).
+.Pp
 For the JTAG ICE mkII, if
 .Nm
 has been configured with libusb support,
diff --git a/doc/avrdude.texi b/doc/avrdude.texi
index a0c948e5..fae3cf03 100644
--- a/doc/avrdude.texi
+++ b/doc/avrdude.texi
@@ -1882,7 +1882,7 @@ Windows serial port device names such as: com1, com2, etc.
 @subsubsection Parallel Ports
 
 @noindent
-AVRDUDE will only accept 3 Windows parallel port names: lpt1, lpt2, or
+AVRDUDE will accept 3 Windows parallel port names: lpt1, lpt2, or
 lpt3.  Each of these names corresponds to a fixed parallel port base
 address:
 
@@ -1903,6 +1903,9 @@ using a laptop, you might have to use lpt3 instead of lpt1. Select the
 name of the port the corresponds to the base address of the parallel
 port that you want.
 
+If the parallel port can be accessed through a different
+address, this address can be specified directly, using the common C
+language notation (i. e., hexadecimal values are prefixed by @code{0x}).
 
 @c
 @c Node
diff --git a/ppiwin.c b/ppiwin.c
index 1c86e959..f32940ef 100644
--- a/ppiwin.c
+++ b/ppiwin.c
@@ -2,6 +2,7 @@
  * avrdude - A Downloader/Uploader for AVR device programmers
  * Copyright (C) 2003, 2004, 2006
  *    Eric B. Weddington <eweddington@cso.atmel.com>
+ * Copyright 2008, Joerg Wunsch
  *
  * 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
@@ -107,6 +108,24 @@ void ppi_open(char *port, union filedescriptor *fdp)
             break;
         }
     }
+    if(fd == -1)
+    {
+	/*
+	 * Supplied port name did not match any of the pre-defined
+	 * names.  Try interpreting it as a numeric
+	 * (hexadecimal/decimal/octal) address.
+	 */
+	char *cp;
+
+	fd = strtol(port, &cp, 0);
+	if(*port == '\0' || *cp != '\0')
+	{
+	    fprintf(stderr,
+		    "%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n",
+		    progname, port);
+	    fd = -1;
+	}
+    }
     if(fd < 0)
     {
         fprintf(stderr, "%s: can't open device \"%s\"\n\n", progname, port);