LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   USB RS-232 Serial Port monitoring/sniffing (https://www.linuxquestions.org/questions/linux-software-2/usb-rs-232-serial-port-monitoring-sniffing-4175600952/)

wm1ke 03-02-2017 09:13 PM

USB RS-232 Serial Port monitoring/sniffing
 
I have a radio connected via a USB serial port to my Ubuntu box. Software on the Linux box manipulates the radio and the raio sends back lots of information like signal strength.

I need to capture the traffic going in anf out of the USB port. I can get lots of statistics using the "cat usbmon" approach but I have not discovered any way to capture the actual data.

Any Suggestions?
Thanks, Mike

Turbocapitalist 03-03-2017 01:53 PM

Welcome.

Does it show up as something like /dev/ttyUSB0 on your system? If so, then it can be treated like a regular serial port. Then you could whip up something easy with perl using Device::SerialPort, though I expect that there is probably something similar for Python if that is more familiar to you.

wm1ke 03-03-2017 06:30 PM

Thanks!
 
The Unix device is /dev/usbtty0
Perhaps I did not make the problem clear:
The port is connected to an RS-232 cable which is connected to the radio at the other end. I can not use a simple Perl script because the the port is already mounted by the radio's software running on the computer.

What I need is a peice of code that will report back to me what is going up and down that rs232 cable.
I think of it like a Tee where the data goes up and down the cable but I need to tap/sniff the data.
Mike

syg00 03-03-2017 07:39 PM

Nothing as simple as tee, but I was recently at a conference where a new (as in kernel 4.9+ only) kernel probing framework was demonstrated. The presenter has for example a tool that is used to snoop another tty. Everything displayed on the target was replicated on the snooper.
Used eBPF to inject a kprobe - needs pyhon/lua code to inject c code for the intercept and knowledge of the (kernel) function being probed and its parameters. Not simple, but probably a template for what you are planning.

The video of the presentation is here. He should have links at the end, but this is the home page of bcc, the userspace compiler collection that takes that python/lua and generates the probe for you.
Have fun - I have.

wm1ke 03-03-2017 10:00 PM

@syg00:
Thanks. Yes, that is what I am looking for but I guess I don't understand why such a tool does not already exist. Huh...
Mike

Turbocapitalist 03-03-2017 10:52 PM

There is apparently jpnevulator in the repositories of at least the Debian-based distros which might do the job, but I haven't tried that yet. There are also some tricks you can do with socat but I've gotten mixed results from that route.

wm1ke 03-04-2017 01:29 PM

@Turbocapitalist:
That's it! it took me a while to get it running, anf I have not totally certified the output, but it does appear that this is giving me access to the serial ports.
Thanks.
I do not know how to give you credit or points on thos forum but I am happy to.
Mike


All times are GMT -5. The time now is 09:04 AM.