sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.01k stars 448 forks source link

Adding target which sets terminal settings using `stty` #528

Open doronbehar opened 7 years ago

doronbehar commented 7 years ago

Many websites explaining how to read Serial communications from the Arduino board on Linux and MacOSx with a terminal emulator, instruct readers to run a command similar to:

stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

Taken from the Arch Linux Wiki Article on Arduino.

Other examples with similar instructions:

  1. https://playground.arduino.cc/Interfacing/LinuxTTY
  2. http://forum.arduino.cc/index.php?topic=38838.msg286321#msg286321

Chrisheydrick's article, suggests using screen, as already suggested by the target monitor of this project.

I think we need to generalize the monitor target and automatically set the correct parameters with stty to Arduino's tty, as instructed in the examples above. In addition, it might be useful to automatically set (if not explicitly set by the user) $MONITOR_CMD according to the available commands in $PATH (last option should be less IMO).

I think using less it should suit most users much more than screen, because it's impossible to echo to Arduino's tty while screen is reading it's content.

Would a PR be welcomed?

edgar-bonet commented 6 years ago

That's a heck of a long stty command!

Personally, I just set the terminal to raw mode and disable echo. “Raw mode” is a setting that combines many individual settings into a single option. It's purpose is, as the Mac OS documentation puts it, to “change the modes of the terminal so that no input or output processing is performed”. Note that raw mode does not disable echo, so that has to be done explicitly. Thus:

stty -F $PORT raw -echo $BAUDRATE

The Armadeus wiki suggests adding -echoe -echok. I did an experiment that shows that these are redundant.