LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   I/O Programming usb printer port (http://www.linuxquestions.org/questions/programming-9/i-o-programming-usb-printer-port-654695/)

SPF 07-09-2008 04:55 PM

I/O Programming usb printer port
 
Hi,

I connected an usb printer port to my linux computer. After experimenting on an other computer with a 'normal' printer port, I wanted to try to extend the amount of I/O's using the usb solution.

The default address of the printer port is 0x378 (or 0x278 on some computers). Yes this is the old parallel port and it still works.
But my new computer doesn't have a parallel port. So I bought the usb printer/parallel port.

But now I have to find the address. Let's look at dmesg:
Code:

usb 1-3: new full speed USB device using ohci_hcd and address 3
usb 1-3: configuration #1 chosen from 1 choice
drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 3 if 0 alt 1 proto 2 vid 0x067B pid 0x2305
usbcore: registered new driver usblp
drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver

Hmm, 0x067B is the vid (Vendor ID) and 0x2305 is the pid (Product ID).

OK, let's look at lsusb -v:
Code:

Bus 001 Device 003: ID 067b:2305 Prolific Technology, Inc. PL2305 Parallel Port
Device Descriptor:
  bLength                18
  bDescriptorType        1
  bcdUSB              1.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass        0
  bDeviceProtocol        0
  bMaxPacketSize0        8
  idVendor          0x067b Prolific Technology, Inc.
  idProduct          0x2305 PL2305 Parallel Port
  bcdDevice            2.02
  iManufacturer          1 Prolific Technology Inc.
  iProduct                2 IEEE-1284 Controller
  iSerial                0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                9
    bDescriptorType        2
    wTotalLength          78
    bNumInterfaces          1
    bConfigurationValue    1
    iConfiguration          0
    bmAttributes        0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        0
      bAlternateSetting      0
      bNumEndpoints          1
      bInterfaceClass        7 Printer
      bInterfaceSubClass      1 Printer
      bInterfaceProtocol      1 Unidirectional
      iInterface              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        0
      bAlternateSetting      1
      bNumEndpoints          2
      bInterfaceClass        7 Printer
      bInterfaceSubClass      1 Printer
      bInterfaceProtocol      2 Bidirectional
      iInterface              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        0
      bAlternateSetting      2
      bNumEndpoints          3
      bInterfaceClass      255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol    255
      iInterface              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0004  1x 4 bytes
        bInterval              1
Device Status:    0x0000
  (Bus Powered)

Hmm, a lot of info, but still no address.

Maybe:

Code:

cat /proc/ioports
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-006f : keyboard
0070-0077 : rtc
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
01f0-01f7 : ide0
03c0-03df : vesafb
03f6-03f6 : ide0
0cf8-0cff : PCI conf1
1000-101f : 0000:00:0f.0
6000-6007 : 0000:00:0f.0
6100-61ff : 0000:00:0f.0
6200-623f : 0000:00:0f.0
9c00-9c3f : 0000:00:0f.0
  9c00-9c03 : ACPI PM1a_EVT_BLK
  9c0c-9c0d : ACPI PM2_CNT_BLK
  9c10-9c13 : ACPI PM_TMR
  9c18-9c1f : ACPI GPE0_BLK
  9c28-9c29 : ACPI PM1a_CNT_BLK
9d00-9d7f : 0000:00:0f.0
9e00-9e07 : 0000:00:01.0
ac1c-ac1f : 0000:00:01.0
fc00-fcff : 0000:00:0d.0
  fc00-fcff : 8139too
fe00-fe7f : 0000:00:0f.3
  fe00-fe7f : CS5535 Audio
ff00-ff0f : 0000:00:0f.2
  ff00-ff07 : ide0

But no luck at all. I can't seem to find the address.

Program I used on the classic port:
http://tldp.org/HOWTO/IO-Port-Programming-9.html

If it's not possible to directly address the parallel port, I would like to receive some tips or a workaround.

theNbomr 07-10-2008 03:18 PM

USB parallel (and other USB dongles) usually include driver software that adapts their proprietary interface to the OS. Using the bare hardware protocols that worked for older hardware is unlikely to work for USB interfaced adapters. There are some such dongles that are advertised as being compatible with various software protection anti-piracy dongles. Such USB-printer ports would probably give you the best hope of working in the way you want, but I wouldn't be making any critical plans based on it.
--- rod.

resetreset 07-19-2008 08:11 AM

Quote:

Originally Posted by SPF (Post 3209305)


If it's not possible to directly address the parallel port, I would like to receive some tips or a workaround.


It's defnitely not SUPPOSED to let you, you're supposed to only read from the /dev file. I'm STILL unclear as to what Linux DOES, because I remember X windows in the old days locking up my system when it probed my video card, when Linux was still, of course, a protected mode system.
If it lets you, well, bad things can obviously happen, since 2 programs can then read or write from it together. Imagine your hard disk :)

michaelk 07-19-2008 08:57 AM

I have this article somewhere..... I do not remember the details but it does cover the issues of connecting legacy hardware to your computer.

http://www.circellar.com/magazine/151toc.htm

As already posted a USB parallel port does not work like the hardware device built into the computer.

quandJe 02-08-2012 12:52 PM

Quote:

Originally Posted by michaelk (Post 3219927)
I have this article somewhere..... I do not remember the details but it does cover the issues of connecting legacy hardware to your computer.

http://www.circellar.com/magazine/151toc.htm

As already posted a USB parallel port does not work like the hardware device built into the computer.

I have tried to
sudo rmmod lp0
So as to make my USB/parallel port converter function just as a parallel port but I am having a serious problem getting my LED to come on.

v_mark 12-23-2012 03:05 PM

USB printer port bitbang
 
Hello,

I know well this is an old thread, BUT
I/O (well in this way only OUT) via USB nowadays could be interesting again, because of cheap and common embedded Linux systems which has one or more USB host.
Currently I have a WIFI router and NAS (both are OpenWRT) and these will the base of my home automation system.

Going back to USB parallel port usage as 8 bit output.
Theoretically it could go (I mean the printer port) inward as well but I have not tried.

I got an info in a DicoLitez page, where they use to switch on/off up to 8 lamps via USB parallel port.

It WORKS (8 LEDs lights up and down at my commands) and FAST.
Tomorrow I continue, but now I have to go.

Mark

v_mark 12-24-2012 08:28 AM

USB printer port bit-level programming SOLUTION
 
1 Attachment(s)
Hello,

I came back.
So I found a web page:
http://www-user.tu-chemnitz.de/~heha...zip/readme.txt
Where they use USB-LPT converter as 8 bit digital output.

The only trick is a latch IC which "remembers" the last bit configuration.
So my very simple (but working) layout is in the attachment.

I used
- 1 pc 74 HC/HCT 574 - IC,
- 1 pc R - resistor (currently I used 33 Ohm, but depends on LED voltage drop!)
- 8 pcs LED (again, I used 3-3,5 V drop white LED because this was available at home)

From software side you have very few to do:
Just send a character to the appropriate device, like
$> echo -ne "@" > /dev/lp0 # switch on bit 6 LED and switch off all others.
$> cat specially_crafted.txt > /dev/lp0 # you can send whole bunch of characters

Or from programming languages
- Open device filehandle
- write a charact
BR,
Mark


All times are GMT -5. The time now is 05:35 PM.