I have a serial device (Omega RDXL4SD thermocouple reader, comms details p 22 here) connected to a USB port on my Raspberry Pi running Raspbian via an FTDI cable. It appears at /dev/ttyUSB0 and the output looks perfect if I display it by calling

pi@raspberrypi:~ $ screen /dev/ttyUSB0 9600

The output is a few numbers. Each time it spits out a line, the cursor returns to the beginning of the line and overwrites it, so that there is only ever one line of numbers on the screen at a time.

Now, I want to use cat, not screen to achieve the same effect, but when I do I get boxes with question marks in them:

pi@raspberrypi:~ $ cat /dev/ttyUSB0

I presume this is some kind of encoding problem. Can you explain what might be different about how these characters are being interpreted in screen versus cat, or suggest other troubleshooting steps?

In case it helps:

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l 

pi@raspberrypi:~ $ stty -F /dev/ttyUSB0
speed 9600 baud; line = 0;
min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo

Edit: @meuh suggested adding -vet to display special characters. Now that I know about those flags, my particular problem is effectively solved! I still wouldn't mind an explanation of exactly what's going on here though.

pi@raspberrypi:~ $ cat -vet /dev/ttyUSB0
  • 1
    Try cat -vet /dev/ttyUSB0 to see the special characters. Add the output to your post. – meuh Dec 14 '17 at 20:07
  • Are you sure the characters aren't part of the protocol the device is using? I find it unlikely that something else is inserting them. – Johan Myréen Dec 15 '17 at 17:42

Turns out the ^X characters, which are bytes of 0x18, are a sort of undocumented NaN in this protocol. There are multiple thermocouple ports, and if you only plug in one thermocouple you get one line with a temperature value and then a bunch of lines ending with ^X.

For some reason, cat in my terminal displays these characters as boxes but screen doesn't display them at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.