I recall reading about programmers who like working in immediate windows, to try a few ideas out first. And there are programmers who do scripting (bash, perl, python, Tcl, and so forth…), and there are programmers who call plotting routines in low-level languages. Honestly, I wanted to try all of these out at some point, and now I have to do each of these together!
Looks like python’s serial library is popular in the arduino community, and this is the typical program that gets everyone going:
import serial ser = serial.Serial('/dev/ttyACM0', 57600) print(ser.name) while 1: textln = ser.readline()
This does print out the serial data coming out of the arduino (after perhaps one reset), and the data packet (from the MPU-6050) needs to be parsed, thrown into a file (buffer), and plotted next. For parsing, I thought it would be nice to just get to python’s command window equivalent:
>>> python >>> include serial >>> ser = serial.Serial('/dev/ttyACM0', 57600) >>> print(serial.readline())
Initially, I would keep entering in the print command, and the packet numbers would increment sequentially. That’s wrong, because I should have missed a lot of packets in between the enters! Then, they get messed up, as the ‘\n’ character seems to keep getting lost.
Now I am getting long long delays too.