LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2010, 02:14 AM   #1
peonuser
Member
 
Registered: Mar 2008
Location: Where ever I am.
Distribution: Various
Posts: 177
Blog Entries: 172

Rep: Reputation: 21
usb parallel port


Looking for code or whatever to control the pins on a usb parallel adapter.
 
Old 08-04-2010, 10:28 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
AFAIK you can not control individual pins on a USB - parallel port adapter like the real hardware. You will need specialized USB I/O device.
 
Old 08-04-2010, 10:50 AM   #3
davidsrsb
Member
 
Registered: Oct 2003
Location: Kuala Lumpur, Malaysia
Distribution: Slackware 13.37 current
Posts: 770

Rep: Reputation: 33
"Real" parallel ports were never that standard. I used to use them as digital I/O for programming fpgas and flash memory. I found that the code was very fussy about the SuperIO chip type and even the bios.
The low cost USB equivalents do not give you the fine bidirectional control of individual pins
 
Old 08-04-2010, 01:20 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Moved to Programming
 
Old 08-04-2010, 06:45 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Apparently, there are some USB parallel printer ports that allow bit-level access. I know of someone who needed such a device to satisfy a copy protection dongle (Windows software), and he was able to do so. I don't know any more specific information than that.
--- rod.
 
Old 08-04-2010, 09:05 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theNbomr View Post
Apparently, there are some USB parallel printer ports that allow bit-level access. ...
If one can send a byte, he/she can send a byte with individually changed bits. So, the bit access probably applies only to status bits.
 
Old 08-04-2010, 10:20 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It isn't quite that simple. There are data bits, and there are control and status bits that manage the transfer of the data. In all but the most primitive parallel ports there is also the capability to use the data lines bidirectionally, in a couple of different formats. Most USB parallel ports are geared to printing only, and often using closed-source Windows-only drivers. The original IBM compatible printer ports were little more than a few latches and line drivers mapped into some real-mode IO space, and provided the capability to access bits and bytes individually, and without regard for Centronics compatibilty. These type of printer ports have all but disappeared from the landscape. There used to also be a plethora of online references to printer ports, and lots of hacker oriented projects that use them. I have used them in a couple of projects that are still running after several years. Don't know what I'll do when the hardware dies. I thought the parallel port would be ubiquitous for years...
--- rod.
 
Old 08-04-2010, 11:33 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theNbomr View Post
... the capability to access bits and bytes individually ...
I am reiterating my point: modern general purpose CPUs do not have bit-level addressing, just the byte-level one.
 
Old 08-04-2010, 11:46 PM   #9
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

theNbomr is right. Programming a parallel port in DOS (or, for that matter, via a linux kernel module) involves much more than simple "byte-wise bit twiddling". Here are two very good links (for Linux, not DOS, that is ):

http://parapin.sourceforge.net/doc/parapin.html

http://www.xml.com/ldd/chapter/book/ch08.html

Back to the original question: what about parallel port programming over a USB device?

We actually investigated this recently. We had a specialized device that happened to use a parallel port plug; it interfaced to DOS with some assembly language code. We needed to port to Windows (and to a motherboard that doesn't have a parallel port or any spare PCI slots). We considered substituting a "USB parallel port" device ... but ultimately wound up just using an Advantech I/O controller (also USB!) instead.

In any case, I believe in this latter scenario, michaelk's comments are correct:
Quote:
AFAIK you can not control individual pins on a USB - parallel port adapter like the real hardware. You will need specialized USB I/O device.
As such, Sergei Steshenko comments are also correct.

IMHO .. PSM

Last edited by paulsm4; 08-04-2010 at 11:49 PM.
 
Old 08-05-2010, 12:18 AM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Sergei Steshenko View Post
I am reiterating my point: modern general purpose CPUs do not have bit-level addressing, just the byte-level one.
I wasn't suggesting bit level addressing, in the sense of a microcontroller with bit addresses; merely that the original style of parallel port hardware made it easy to do bit-bash style hacking. In contrast, the USB parallel port usually (exceptions exist, as I mentioned earlier) provides a higher level of abstraction, such as the handshaked transfer of a byte or probably even larger chunks of data.
--- rod.
 
Old 08-05-2010, 02:56 AM   #11
peonuser
Member
 
Registered: Mar 2008
Location: Where ever I am.
Distribution: Various
Posts: 177

Original Poster
Blog Entries: 172

Rep: Reputation: 21
I know about the traditional parallel port I have hooked stepper motors, servos and switches to it. Linux does have a driver for usb parallel cable, but I am not a machine language programmer. While researching this yesterday, I found where someone had taken 74373 and 7400 chips (plus resistors) to a jet direct box and did some home automation. Since the chips are cheap, It might be neat to see if it works for the usb parallel cable also. Since there is no way for it to work, I have nothing to lose.

Last edited by peonuser; 08-05-2010 at 03:02 AM.
 
Old 08-05-2010, 03:01 AM   #12
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theNbomr View Post
... handshaked transfer of a byte ...
--- rod.
So, what is the problem compared to traditional parallel port ? The fact that the transfer is handshaked ?
 
Old 08-05-2010, 08:19 AM   #13
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
The problem is that the USB parallel ports don't provide a way to access the non-data registers directly (or even the data registers, for that matter). In applications such as peonuser describes, these other bits can be used as well as using the status bits as inputs. The USB-based interfaces only provide for Centronics-compatible operation. To transfer a byte to a printer requires a sequence of bit setting and polling that the USB interface performs internally. For applications that need to use the bits in other ways, there is no method to access the appropriate registers. The traditional Centronics compatible hardware also provided a bit that could be used to generate interrupts, allowing you to connect arbitrary TTL level signals to it, and trigger interrupts. In DOS and other real-mode applications, you could toggle bits in either the data register or control register under controlled timing, and this is one feature that software security dongles use.
So yes, if one wants to use the control register for purposes outside the Centronics standard, the USB-based interface will not allow this, as it alone will control the bits used for performing the handshake. To understand all of this, I suggest that you explore the nature of the parallel interface through one of the numerous online descriptions, perhaps starting with Tomi Engdahl's Parallel Port Interfacing Made Easy. The final couple of paragraphs are particularly germane to this thread.

--- rod.
 
Old 08-05-2010, 08:36 AM   #14
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theNbomr View Post
... I suggest that you explore the nature of the parallel interface ...
I don't need. In the mid-end eighties I designed ROM simulator connected to a parallel port of the host computer and support package for.

The simulator had a cable connected to a socket which had the same geometry and pinout as a ROM to be simulated; but internally it was a static RAM into which the code to be debugged could be downloaded.

The thing was used instead of PC BIOS ROM to help debug HW problems first, and then to debug BIOS modifications.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parallel Port to USB controller and outb() eteck Programming 8 06-05-2009 06:35 AM
usb-parallel port adapter al.basili Linux - Hardware 0 12-01-2005 01:56 PM
USB-Parallel Port Adapter FliesLikeABrick Linux - Hardware 6 09-29-2005 12:47 PM
parallel vs usb port raysr Mandriva 1 09-12-2004 12:14 AM
USB-parallel port printer Devenpillay Linux - Laptop and Netbook 1 09-07-2004 09:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration