I have a small LED matrix controlled by a display driver that accepts serial commands to update the display. I'm successfully controlling it via node with the node serial package, however I'd like to be able to update it with echo so that I can control it earlier in the boot up process with a shell script.

To start testing this new method, I set it up with:

chmod o+rw /dev/ttyUSB0
stty /dev/ttyUSB0 115200

And I'm able to send it commands using screen:

screen -F /dev/ttyUSB0 115200

However when I try to use:

echo -e 'title \r' > /dev/ttyUSB0

it doesn't work, and when I monitor the response in another window with

cat -v < /dev/ttyUSB0

I see that its receiving the message but it seems fragmented and also continuously responding with an error as if I'm sending lots of bad and/or blank commands.

How can I mimic the commands sent from screen using echo?

  • I don't know if was a typo but the command is stty -F /dev/ttyUSB0 115200 and why are you using a USB serial and to check the result are you using a serial port (not USB) /dev/ttyS1 – Dany Flores Aug 7 '15 at 1:23
  • Ah yes typo - I've updated the question, thanks. – MikeBman Aug 7 '15 at 11:38
  • screen -F ... -> Error: Unknown option -F – Pro Backup Nov 28 '18 at 12:12

I was able to configure the serial port so echo behaved like screen. Here are my settings:

stty -F /dev/ttyUSB0 115200 raw -echo -echoe -echok -echoctl -echoke

And to echo:

echo -e -n 'command_here\r'  > /dev/ttyUSB0 
|improve this answer|||||

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.