Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: basic serial and USB access

by apotheon (Deacon)
on Feb 01, 2008 at 20:17 UTC ( #665639=note: print w/replies, xml ) Need Help??

in reply to Re: basic serial and USB access
in thread basic serial and USB access

You won't find anything generic for USB, it doesn't work that way. It's a 'bus' (Universal Serial Bus).

So . . . there's no way to get data directly from a USB device? That doesn't make sense to me.

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin

Replies are listed 'Best First'.
Re^3: basic serial and USB access
by GrandFather (Sage) on Feb 01, 2008 at 22:35 UTC

    From a specific type of USB device, yes. From USB devices generally, no. It's rather like saying: "How do I get data from a PCI bus device". There is no general answer because PCI is a bus and the way you interact with a graphics card is vastly different than the way you interact with a USB host controller. In that respectUSB is identical to PCI.

    Forget the "Serial" bit of "Universal Serial Bus" - it has no relationship with RS-232 serial which is the "serial port" protocol that you are talking about. Think of it as a Universal Bus and remember that the way you might communicate with a digital camera is rather different than the way you communicate with a keyboard or mouse.

    Actually, for most USB devices the USB part is irrelevant in terms of high level control of the device. You need to access the API presented by the device driver for the specific device you want to use.

    Perl is environmentally friendly - it saves trees

      Is there no way to access data from such a device, in Perl, without a device driver?

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

        I don't know how it works for other operating systems, but with Windows (at least in the past) the device gets matched by P&P using its PID and VID to a kernel mode driver that knows how to talk to the device. The main job of the driver is to handle P&P and other aspects of the USB bus that are incidental to the higher level conceptual operation of the device. You really really don't want to deal with a USB device at the level that drivers do. Most device manufacturers wouldn't make the information available to allow you to do that in any case.

        If what you will be dealing with is simply serial devices over a RS-232 to USB adapter, then your Perl code wouldn't know the difference in any case. If you are trying to develop some sort of generic test system, then you will need to write some sort of plug in code technology to handle different devices types over different interfaces.

        Perl is environmentally friendly - it saves trees

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://665639]
[marioroy]: s/hear/heard/
[karlgoethebier]: Discipulus: No. See https://en. wiki/Tribe_( Native_American)
[karlgoethebier]: They took Unix from some aliens
[marioroy]: Perl is so powerful that it can poll 40 metrics from 20 million devices in 40 minutes using 4 nodes only.
[karlgoethebier]: http://www. aliens.htm
[Lady_Aleena]: marioroy, I can't decide whether or not to move my RolePlaying:: Random:: modules to just Random::. I'm not as sophisticated as most here.
[marioroy]: Naming things can be difficult, sometimes more so that the actual code :)
[karlgoethebier]: Lady_Aleena: You need to jump to some conclusion
[Lady_Aleena]: And what would I rename RolePlaying/Random .pm to if I move all the RolePlaying/Random modules to just Random? Random/ Random/, maybe lowercase the file name to indicate it is a bit different? I don't know yet.
[marioroy]: What does Random do?

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-05-29 08:56 GMT
Find Nodes?
    Voting Booth?