How can I view raw binary/hex data from a serial port in real-time?

0
49
Asked By TechWiz42 On

I've got some specialized hardware that outputs data through a serial port using RS232. I have the connection settings and know it emits 31 bytes every other time frame. I can connect to the console using `screen /dev/ttyS0`, but I'm unsure how to handle the binary format, as connecting might result in garbled text since the terminal interprets bytes as ASCII.

Is there a way to live view the incoming bytes using tools like `screen` or `watch`? Ideally, I'd want the output to be in a format showing the binary data clearly. Also, I've heard about `socat`, but I haven't used it before; would it work here, and what would the command look like? Ultimately, I want to ensure that I've set up the connection correctly and am receiving valid data. Looking ahead, I plan to use Telegraf to connect to the serial port and send data to InfluxDB, but let's start with displaying the binary data first. I'd like to skip deep dives into C programming since my skills are a bit rusty.

2 Answers

Answered By BinaryBard88 On

You might want to try using a simple Python script for this. It can easily read binary data from the serial port, and you could get some help from an LLM to write it. I found a GitHub repo that might have what you need: [Hexadecimal Data Monitor for Serial Ports](https://github.com/cyph3rryx/Hexadecimal-Data-Monitor-for-Serial-Ports).

DataGuru99 -

That looks like exactly what I need! Thanks!

CuriousCoder21 -

Am I missing something? That script doesn't seem to read data from a serial port at all.

Answered By PerlPioneer54 On

Using Perl could be a good solution too. There are plenty of modules available that can help you read raw socket data easily.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.