baryluk / fnirsi-usb-power-data-logger

Driver / Data logger for FNIRSI FNB48, FNIRSI C1 and FNIRSI FNB58 USB Power meter
MIT License
138 stars 14 forks source link

Data log every second? #11

Open Nedsk opened 1 year ago

Nedsk commented 1 year ago

Hey, Sorry to bother.

I have a very simple use I intend for your python app. I intend to use the app to capture the voltage/current etc every second for while the script is running. I don't need the every ms that it runs today.

is there a simple line I can change to only output one result every second (so my file isn't crazy huge)? I tried playing around with some lines but unfortunately, couldn't find a simple way to do it.

Thanks!

baryluk commented 1 year ago

Hi. No, there is no way to control it easily. Hardware can be configured to send less often, but this is not implemented. You need to write own script that postprocesses the file to skip lines. You can just write a Python program, or modify the existing one, and put it in a pipeline.

If you known awk this should be very easy to do quickly.

baryluk commented 9 months ago

@Nedsk In case you do not know how to use awk.

It is common tool on Linux / Unix.

Could use something like this for example:

$ ./fnirsi_logger.py | awk 'BEGIN {next_t=0.0;} { if ($1 >= next_t) { print $0; next_t = $1 + 1.0;} }'
timestamp sample_in_packet voltage_V current_A dp_V dn_V temp_C_ema energy_Ws capacity_As
1700005792.948 0 0.10052 0.00003 1.627 1.525 31.900 0.000000 0.000000
1700005793.948 0 0.10092 0.00003 1.628 1.526 31.900 0.000004 0.000044
1700005794.948 0 0.10095 0.00000 1.628 1.525 31.900 0.000005 0.000048
1700005795.948 0 0.10131 0.00003 1.628 1.526 31.900 0.000007 0.000067
...

Also, the logger now has argument parsers, (currently only have --crc and --verbose options), so if there are more people needing such function, we can easily implement it in the logger, to only print with specific frequency (sub-sampling).