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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...