1

Is there a way to log events on Arduino when developing using C / AVR toolchain, and not the Arduino IDE? Working on Ubuntu.

RS2322016
3841 gold badge3 silver badges12 bronze badges
asked Sep 7, 2016 at 3:41
3
  • Do you want your host system to record stuff received from an Arduino? Or do you want an Arduino to record data? Either way, the answer is yes, it can be done. Commented Sep 7, 2016 at 5:46
  • First one, I would like to see on my host what Arduino is doing. Commented Sep 7, 2016 at 7:16
  • The IDE uses a plain serial console to communicate with the Arduino. You can use any serial console application you like. Commented Sep 7, 2016 at 7:55

2 Answers 2

3

On Ubuntu, I usually simply do

stty -F /dev/ttyACM0 raw 9600
cat /dev/ttyACM0 > the.log.file

Replace 9600 with your baud rate of choice.

answered Sep 7, 2016 at 10:11
8
  • Ha, neato. No character encoding mangling woes? Commented Sep 7, 2016 at 18:18
  • @user400344: The command is encoding agnostic: it moves the data from the serial port to the file as a byte stream, not a character stream. It could well be binary data for that matter. Commented Sep 7, 2016 at 19:26
  • Thanks, it will replace my terrible hack completely. Do you use something similarly simplistic to send data to your MCUs? Commented Sep 7, 2016 at 19:29
  • @user400344: No, I use text-based protocols, like in this command line interpreter, and type the stuff directly at the keyboard, usually through screen. You could cat the.data.to.send > /dev/ttyACM0 but, since the Arduino resets when you open the port, your sketch will miss the beginning of the file. You can avoid this auto-reset feature by putting a cap between RESET and 5V. Commented Sep 8, 2016 at 12:53
  • pretty neat. what value should I use for the cap? Commented Sep 8, 2016 at 16:45
1

Any of these are straightforward: python (serial library) or processing (same type of user interface, will happily build portable java programs for linux/win/mac). I use an awful perl script for logging stuff, can't recommend it. If you don't prefer the two first options, have a look at IPC::Open2 or IPC::Open3 - I use a bidirectional connection so I can send stuff, but I rely on 'tip' to do the serial connection stuff. If I wanted to log more than a few things, I would probably use python, which is much easier to read (later), and it will require a small fraction of the memory a fullblown java applet.

answered Sep 7, 2016 at 8:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.