Jump to content
  • 0
Sign in to follow this  
stamasd

Sending messages to /dev/ttyUSB0

Question

This question is not Funtoo-specific, except for the fact that I am working to get this project done on a Funtoo box.

I have a headless box on which I installed Funtoo, which I plan on using as a home server. I don't want to have any monitor or keyboard attached to it, and yet I want it to display some status messages on a small attached display. For that I made a small gadget consisting of an Arduino Nano with a I2C OLED attached, which simply takes characters from the serial port and displays them onto the OLED. It shows up as /dev/ttyUSB0 and the serial port speed is 115200.

 

It works as expected when I use a terminal emulator such as picocom to connect to it:

picocom -b 115200 /dev/ttyUSB0

then it takes my keyboard input and displays it to the OLED.

 

However I want to use it non-interactively, and have messages sent to the display from a script run periodically from a cron job. But attempting to do that from the CLI with either echo or printf fails:

printf 1234 > /dev/ttyUSB0
or
echo "1234" > /dev/ttyUSB0

Neither of the above displays anything on the OLED. There is no error message; the serial port has been set to the correct speed with

stty -F /dev/ttyUSB0 115200

and checking with "stty -F /dev/ttyUSB0" shows that it's set to the correct speed. It's not a permission problem, my user has access to the port, and the same thing happens when I try the above as root.

At this point I'm not exactly sure why this fails.

 

(edit) FWIW it's not a function of the serial port speed. If I set the speed to 9600 both on the Arduino and in the terminal I get the exact same behavior: it works with picocom, but not with echo/printf.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...