Mattk470 has asked for the wisdom of the Perl Monks concerning the following question:

OK, most of this is perl related because thats what I'd use for downsteam data processing, but some might fall outside the box; pointing me in the right direction would be most helpful. here's an example of what I'm doing: Let's say I have a weather station steaming numerical data via USB and the software is reading it and storing it in a proprietary format. I can analyse the data later on using their software, however Id like to do analysis as it comes in. How would I go about intercepting the USB data port and process the numbers "on the fly"? I'd like to use the "on the fly" data to start other processes/machines. I don't think that this data is encrypted until it hits the software because the company focuses more on data analysis software.

Replies are listed 'Best First'.
Re: Reading real-time USB data
by Illuminatus (Curate) on Apr 11, 2011 at 23:23 UTC
    1. what OS?
    2. when you say 'intercept', do you really mean take it, or are you looking for something like pcap, which gives you a copy without interrupting the existing flow?
    3. have you looked at Device::USB::*?

    fnord

      A1. its windows vista A2. I'd want to copy as not to interupt the current software from doing its job A3. I haven't looked at Device::USB yet, thought I'd get some feedback first before jumping into it
        I don't think you're going to find a perl module that will do this. However, this page has some links to tools that should be able to capture the data ala wireshark/windump. I have not looked at any of these tools, but you should hopefully find one that can pipe the raw data to your perl app

        fnord

Re: Reading real-time USB data
by mje (Curate) on Apr 12, 2011 at 07:51 UTC

    I read "live" data from an Arduino attached to the USB port in Perl. You can see how I did it at http://www.martin-evans.me.uk/node/86. Basically I just use Win32::SerialPort. I'm sure you can do something similar in other operating systems.

      It sounds to me like the requirement here is to intercept the USB data, Wireshark-style, so that the data is being read by the Perl program while it is also being read by the proprietary software.

      I think that it is safe to say that some “OS-specific privileged-mode high magick” will be required in order to do that.   Or maybe just a piece of wire.   If the data is simply coming in as a serial data stream, and it is now being sent using USB just because those connectors require a lot fewer wires (i.e. no command-and-control data going the other way), then perhaps you could electrically split the wire using some kind of a pigtail without running into impedance or voltage-drop problems.