A controller module (power supply) for piece of scientific equipment in our lab uses a Windows program on a PC for a human interface via USB connection. I have a list of the "set" and "read" commands that are exchanged over USB.
I would like to monitor or sniff their communication with a RPi without interrupting it.
If it were RS-232 I'd just tap into the serial line, perhaps use a buffer amplifier then have pigpio read for several seconds at the appropriate baud rate with something like the script below.
Once read, I'd look through the chunk of data for the particular "set" and "read" commands that I'm interested in.
Alas the connection is USB which I think poses several challenges
- data clock rate could be very high
- there may be a lot of extra information exchanged constantly that I'd have to filter out
- since it's a different protocol, there's a chance that
pi.bb_serial_read_open(pin, baud)might not collect anything because it doesn't recognize the signal.
I don't think I can add a USB hub and use a USB to serial converter, because it would not pick up the traffic intended for a different USB device.
- Superuser SE: How does a RS-232 to USB converter work?
- Electronics SE: How do USB to serial adapters work?
Question: How can I use pigpio to "sniff" or monitor an existing USB connection between two devices?
update: These suggest to me that perhaps this is just too complicated and not worth trying, but maybe I'm overreacting? I just need to capture the stream passively, and search it for a few predetermined strings.
- Reverse Engineering SE: Where do I find a cheap hardware USB sniffer
- Building a USB protocol analyzer
- BeagleBoard/GSoC/2010 Projects/USBSniffer
- Teensy - DIY USB Protocol Analyzer, Packet modifier, USB wrapper, USB over LA
- Kickstarter: "OpenVizsla" Open Source USB Protocol Analyzer
In response to the question in comments, I got some help from someone familiar with Windows 7 in Chinese. Turning on the power supply at the far end of the USB adds
USB Serial Port COM4 to the display.
Partial example script outlining how
pigpio can be used to collect data on a serial line. There's no reason to think that this would work when monitoring communications on a USB connection.
from binascii import hexlify import pigpio, time # don't forget 'sudo pidof pigpiod' pin = 24 baud = 9600 t_collect = 3. # seconds pi = pigpio.pi() try: # in case it was left open pi.bb_serial_read_close(pin) except: pass pi.bb_serial_read_open(pin, baud) time.sleep(t_collect) self.pi.bb_serial_read_close(pin) # now read what's been collected size, data = pi.bb_serial_read(pin) data_hexlified = hexlify(data) n_hexlified = len(data_hexlified)