Say I have the following python script to read in serial data from my Arduino:
import serial ser = serial.Serial("dev/ttyACM1", 9600) ser.timeout = 2 ser.readlines()
On the other end I've flashed my Arduino with a program that sends 20 voltage readings every 0.5 seconds. The Arduino starts sending those readings from the moment it's hooked up, then after 20 seconds it stops and sends nothing.
Now what I've noticed is that I can read those 20 voltage values using the first script whenever I want. That is, I can hook up the Arduino, wait a couple of minutes then read in the values. This makes me think that the data is getting stored somewhere. I'm inclined to think that it's not being stored on the Arduino but on my laptop somewhere.
I've come up with a few questions that I hope the community could help me with:
- Where is PySerial getting the data from?
- For how long is the data stored in this place?
- Is there a way to clear this space before reading in values?
- How much storage space is there?
- When you set the baud rate in PySerial (second line in script), is this the rate that PySerial reads data from the storage area (not the Arduino)?
- I've noticed that if I set the baud rate in PySerial too high the first few lines of data are fragmented and sometimes completely wrong, why?
- Not exactly related but when you set serial.Serial.timeout are the units in seconds?
I appreciate your time.