USB to Paralell I/O - Linux

This is a discussion on USB to Paralell I/O - Linux ; Hi there. I did a paralell port output turn on 8 and off 8 LEDs indicating what were printed as described here "http://www.epanorama.net/circuits/ parallel_output.html" like this image http://www.epanorama.net/circuits/lptleds.gif using gcc outb() function. Now i need to see those LEDs working ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: USB to Paralell I/O

  1. USB to Paralell I/O

    Hi there.

    I did a paralell port output turn on 8 and off 8 LEDs indicating what
    were printed as described here "http://www.epanorama.net/circuits/
    parallel_output.html" like this image http://www.epanorama.net/circuits/lptleds.gif
    using gcc outb() function.

    Now i need to see those LEDs working with an USB port. I bought a
    cable like this:
    http://cgi.ebay.com/NEW-USB-TO-DB25-...QQcmdZViewItem
    and tried the function outb() with the address of the USB driver that
    linux recognized uhci_hcd Host Controller.
    I downloaded the libusb-0.1.12(worked on my fedora 4 ok) and in a file
    called testlib.c and in other examples i see loops searching for
    devices and busses but i cant see something like outb() got what i
    need?
    I just would like to know how can i send data and receive data as i
    did in paralell.

    Any help will be very appreciated....

    Thanks.

  2. Re: USB to Paralell I/O

    Joealey wrote:
    >
    >I did a paralell port output turn on 8 and off 8 LEDs indicating what
    >were printed as described here "http://www.epanorama.net/circuits/
    >parallel_output.html" like this image http://www.epanorama.net/circuits/lptleds.gif
    >using gcc outb() function.
    >
    >Now i need to see those LEDs working with an USB port. I bought a
    >cable like this:
    >...
    >and tried the function outb() with the address of the USB driver that
    >linux recognized uhci_hcd Host Controller.


    Good golly, you have a lot to learn about USB!

    >I downloaded the libusb-0.1.12(worked on my fedora 4 ok) and in a file
    >called testlib.c and in other examples i see loops searching for
    >devices and busses but i cant see something like outb() got what i
    >need?
    >I just would like to know how can i send data and receive data as i
    >did in paralell.


    You can't. USB is much more than just a set of wires. USB is a
    protocol-based bus, like Ethernet. The host controller schedules the
    transfers to and from the various devices on the bus, and manages the
    timing of those transfers. To talk to a USB device, you have to submit
    requests to the host controller driver.

    The basic way of talking to a USB device is to scan the bus to find your
    device, then "claim" the interface that contains the endpoint you want to
    talk to, then submit requests to read from or write to that endpoint.

    The USB specification is surprisingly readable. You can download it from
    www.usb.org. Chapters 5 and 9 are of interest to device users.

    Did you get any documentation with your cable adapter? You can't tell what
    commands cause what actions without documentation.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

  3. Re: USB to Paralell I/O

    On Jun 13, 2:11 am, Tim Roberts wrote:

    > You can't. USB is much more than just a set of wires. USB is a
    > protocol-based bus, like Ethernet. The host controller schedules the
    > transfers to and from the various devices on the bus, and manages the
    > timing of those transfers. To talk to a USB device, you have to submit
    > requests to the host controller driver.
    > The basic way of talking to a USB device is to scan the bus to find your
    > device, then "claim" the interface that contains the endpoint you want to
    > talk to, then submit requests to read from or write to that endpoint.


    I read thousands of usb documents and this paragraphs said ALL i need
    to know in a few words. Thanks a lot for that!.

    > Did you get any documentation with your cable adapter? You can't tell what
    > commands cause what actions without documentation.


    No i did not get any documentation. I downloaded a USB port sniffer
    and saw some stuff. What i can tell you is that i saw on the sniffer
    while it was using my printer a (bulk transfer) and other control
    commands when i turned the printer off. Seems the driver was trying to
    restabilish the connection. The main thing is that when it was using
    my printer i saw only bulk transfers.

    Can you please show me a sample code that what should be a read or
    write funcition. I have an Usblib lib in linux that recognizes my
    adapter and the loop is exactly as you described before, search for
    the devices and bus and then print but it uses a device struct like
    this:
    struct usb_device *dev;
    print_device(dev,0); //where 0 is declared as "level" that i don't
    know what is... lol...

    To do something (read or write) i am guessing that i should fill the
    struct before the print_device and then get the result after the
    print_device, isn't?

    I have more for you if it helps on the whole thing....
    Linux gave me those answers when i use the specified commands on the
    libusb-0.1.12
    driver_name:
    bus/device idVendor/idProduct
    001/001 00000/00000 driver: hub

    descriptor_test
    - Unable to fetch manufacterer string
    - Unable to fetch product string
    ......... lots of address..... i think what should be interesting is up
    and on windows the product string is -> USB_PRINT


    Thanks a lot.

  4. Re: USB to Paralell I/O

    Joealey wrote:
    >
    >No i did not get any documentation. I downloaded a USB port sniffer
    >and saw some stuff. What i can tell you is that i saw on the sniffer
    >while it was using my printer a (bulk transfer) and other control
    >commands when i turned the printer off. Seems the driver was trying to
    >restabilish the connection. The main thing is that when it was using
    >my printer i saw only bulk transfers.
    >
    >Can you please show me a sample code that what should be a read or
    >write funcition. I have an Usblib lib in linux that recognizes my
    >adapter and the loop is exactly as you described before, search for
    >the devices and bus and then print but it uses a device struct like
    >this:
    > struct usb_device *dev;
    > print_device(dev,0); //where 0 is declared as "level" that i don't
    >know what is... lol...
    >
    > To do something (read or write) i am guessing that i should fill the
    >struct before the print_device and then get the result after the
    >print_device, isn't?


    The "usb_device" structure is the main device structure for libusb. The
    transfers will be done with usb_bulk_read and usb_bulk_write. Each call
    includes a buffer to be read or written.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

+ Reply to Thread