rosenbrockc / live-serial Goto Github PK
View Code? Open in Web Editor NEWLive plotting and logging of serial port data.
License: MIT License
Live plotting and logging of serial port data.
License: MIT License
I don't know if there is an easy way to do this, but in my opinion, the filtering of the data to be logged should be an "opt-in" situation rather than an "opt-out". I frequently worry about loosing information due to filtering; I almost never worry about having data files that are too big. I think most people will think this way. Also, data is often pre-filtered by the sensor before it is sent to the serial port. There is usually no point in filtering twice.
The plot labels don't show up when a sensor key is not specified. This is true even when there is only one sensor (un-keyed) per COM port. E.g.
[sensor.foot]
dtype=int,float
port=COM5
label=Foot Scale
value_index=1
[sensor.seat]
dtype=int,float
port=COM6
label=Seat Scale
value_index=1
[port.COM5]
port_baud=115200
port_timeout=0.01
[port.COM6]
port_baud=115200
port_timeout=0.01
Using the same config file as #3 the CSV files that get generated have long integer file names. Since the sensor name is in the config file and there is no ambiguity as to which stream is which, they ought to be named after the sensor.
When I specify "port_encoding=ASCII" it appears to be ignored with the following output.
Using script args from config C:\Users\user\Documents\live-serial\prox.cfg. COM4: using {'port_parity': 'N', 'port_timeout': '0.025', 'port_stopbits': 1, 'encoding': 'UTF-8', 'virtual': False, 'delimiter': '\s', 'port_baud': '9600'} as config-set serial parameters.
It would be nice to be able to specify multiple columns in the value_index
option of a sensor; this would produce multiple lines on the single subplot. Also, if an "aggregate" sensor (e.g., sum or difference of real sensor values) could be plotted in a subplot, that would also be nice. E.g.,
[sensor.total]
port=aggregated
label=Total Weight
sensors=sensor.foot,sensor.seat
function=numpy.sum
When the ports are configured in a config file, there should be an auto
option so that the explicit ports don't need to be listed. In that case, any ports present in the config file would be monitored.
Tried to run but got the error "Value Error: Live feed has no sensor data keys. Can't set up plotting." I don't know what "sensor data keys" are.
` [sensor.prox]
dtype=float
port=COM4
label=Proximity
value_index=0
[port.COM4]
port_baud=115200
port_timeout=0.025 `
This may be a different issue...
When I specify "port_encoding=ASCII" it appears to be ignored with the following output.
Using script args from config C:\Users\user\Documents\live-serial\prox.cfg. COM4: using {'port_parity': 'N', 'port_timeout': '0.025', 'port_stopbits': 1, 'encoding': 'UTF-8', 'virtual': False, 'delimiter': '\\s', 'port_baud': '9600'} as config-set serial parameters.
The ideal behavior would be for a new directory to be created when the user specifies the data be logged to a directory that does not exist.
The following command
python liveserial\livemon.py COM4 COM5 COM6 -config capscalescale.cfg -refresh 10 -logdir C:\Users\TNiederhauser\Documents\logs\ThreeSensors -method last
Gives this error
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\TNiederhauser\\Documents\\logs\\ThreeSensors\\2246023103488.csv'
For the plots in windows, the initial figure size is tiny and the font size on the axes and tick labels can't be read, even when the window is dragged bigger.
It would be nice if the plot options could just be specified in the config file; any valid matplotlib
plot option should be accepted.
-h from the command line brings up "-timeout". The setting in the config file is "port_timeout". Is this an inconsistency or are they 2 different parameters?
The other script arguments (like -method
, -refresh
, -buffertime
, etc.) should be options in the configuration file as well. Then a project could just use a config file and livemon.py
would be called as:
python livemon.py auto -config project.cfg -log
The y-axis tick are not updating as the data scales
[sensor.prox]
dtype=int, float
port=COM4
label=Proximity
value_index=2
[port.COM4]
port_baud=115200
port_timeout=0.3
port_encoding=ASCII
# port_delimeter=\s
[global]
wait=10
buffertime=5
logdir=path
White-space separated is common, but not the only option. Let the user specify what delimiter to use.
ERROR: Port '/dev/ttyACM0' is not valid.
Sorry, actually it's not an issue, a question.
I use serial_read() and serial_write() to execute command on my target device from the host PC.
Also I want to save real-time log during executing my python script to control target device.
Is it possible to use logger and serial_write function concurrently?
The serial port is putting out 2 values separated by a space. The configuration file is shown below.
[sensor.prox]
dtype=int, float
port=COM4
label=Proximity
value_index=2
[port.COM4]
port_baud=115200
port_timeout=0.3
port_encoding=ASCII
# port_delimeter=\s
[global]
wait=10
buffertime=5
logdir=path
The beginning of the log file is as follows. It shows the computer system time stamp twice and omits the first value in the serial data, which happens to be an integer.
Time,Value 1,Value 2
1.71905112267,1.71905112267,5.08333333333
1.74497765965,1.74497765965,6.72222222222
1.90651988983,1.90651988983,432.0
2.00033950806,2.00033950806,526.0
2.09400129318,2.09400129318,620.0
"logdir" does not show up on the documentation page for configuration file even though it can be used in a configuration file.
It seems that everyone does not use UTF-8. My Arduino is returning encoding as UTF-16. The encoding ought to be a user-configurable option for each COM port.
Currently, the code waits for about 0.5 seconds before determining that there is no data available (and raising an exception). The user ought to be able to specify how long they are willing to wait for the hardware to initialize the stream.
Also, if the timeout is too low on the port configuration, then the data comes muddled (with new lines only showing up every few buffer flushes and the other data mixed up). If the timeout is made longer, then it works great. We either need to automate this, or add it to a wiki somewhere so the user can troubleshoot their session.
If the data is muddled then the code raises ValueError: Live feed has no sensor data keys. Can't setup plotting.
When logdir=path is commented out in the config file the follow error is raised and the code does not run.
ValueError: Live feed has no sensor data keys. Can't setup plotting. Try fiddling with the
-wait parameter.
The config file is shown below.
[sensor.prox]
dtype=int, float
port=COM3
label=Proximity
value_index=2
[port.COM3]
port_baud=115200
port_timeout=0.3
encoding=ASCII
# port_delimeter=\s
[global]
wait=10
buffertime=5
logdir=C:\Users\TNiederhauser\OneDrive - NewVista Property Holdings, LLC\ProxData\test\
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.