views:

111

answers:

2

I have a USB to parallel port device that i want to interface with through c++ on a modern windows OS (xp and newer).

I've done a little research but the information is a bit patchy when it comes to programming to one of these USB to parallel port devices (most of the information is dated and assumes that you have a parallel port built right into the motherboard, something my brand new computer doesn't have). One reference even says that it is not possible to interface with a USB to parallel port from a C++ program without some sort of software changes.

All i want to do is to is be able to read or write 8 bits to the parallel port through a USB to parallel port device on a modern computer running a modern windows OS (with ports being dedicated to reading or writing only).

Is there any quick and easy way of doing this? Some sample code would be greatly appreciated.

Also, how many of these USB to parallel ports can I interface with my computer? Am i limited to 3 due to some sort of legacy addressing or can i have as many as my USB and CPU are able to support?

Working off VC++ 2008, running Windows 7 x64 with a Core i7 860.

Edit: a bit more information...

I've tried using inpout23 along with some prewritten test program. It compiled just fine and ran just fine claiming to have both read and written to a parallel port. I had my USB to parallel port connected to the computer and that port connected to a cable in which i had identified, stripped and soldered each of the 25 wires onto a sort of plug for quickly plugging into a breadboard for testing. None of the output pins had changed to what the program had said was written to them (instead they were all set to high and never changed).

A: 

I've worked with a USB-to-serial port adapter before and I guess USB-to-parallel should be the same. You should have got a driver along with the adapter - this does most of the work for you, hiding the USB interface and presenting it to the OS as a traditional parallel port. For example, when I plug my adapter into the USB port, it just shows up as COM4 in Device Manager. I'm guessing yours will show up as LPT1 or something. From there on, it's a matter of using the standard Windows API to access these ports. (see Communications Resources on MSDN)

casablanca
I played with those USB to serial ports as well, those seemed to work ok and my computer recognized them as COM ports. No drivers were necessary for this serial port (windows had it already) but it showed up as an "IEEE 1284 Controller" and was defined as a "printer port" under the devices properties. I wasn't able to find any code that opened up a parallel port as a "LPT1" port like i was able to with a "COM1" port. All the I/O I've seen in my research says it outputs to some sort of legacy 16-bit addressing system which doesn't seem to work for me.
Faken
+2  A: 

I've done this in the past and I have good news and bad news.

The good news is that it always worked (sometimes with tweaking), which is a tribute to the electronic manufacturers of designing extremely robust protocols. Apparently the USB to parallel converters all provided the hardware port emulation.

The bad news is that performance was awful on the 'bitbanging' interface models. If you do not mind slow updates this is not an issue at all. I used it for programming uControllers and soon the price of serial or USB programmers was overcome by my impatience.

Just use the windows API to read/write the LPT or COM ports and it works (slowly).

Peter Tillemans
What do you mean by tweaking? Also, my computer is NOT recognizing an LPT1 port, rather a "IEEE 1284 controller" instead would this be a problem?
Faken