Hi,
I’m doing long term power consumption tests for an IoT device we have developed but am having problems with the downsample_logging.py program which keeps missing packets. The message is: “WARNING pkt_index skip: expected 296, received 305” as an example. (I set the frequency option to --downsample 120 as I only need a reading once/minute.)
However, if I use the UI and set the File/Preferences/Device/Setting/Reduction_Frequency to 1Hz (i.e. the slowest setting) and then hit the Tools/Record Statistics option it works just fine sending data to the CSV file. The problem with this solution is that the data file is very large as I get one row per second rather than one row per minute with the python program.
Based on a previous discussion I thought the issue might be related to USB power but I have checked the USB port power settings in Windows and set the “USB Selective Suspend Setting” to disabled. I have also tested it on a few different computers and get the same problem with dropped packets.
Do you have any suggestions for what I could try? Alternatively, would it be possible to change the UI to include slower statistics rates than 1Hz?
Are you using the original Joulescope JS110 or the new Joulescope JS220? Based upon the warning, I think you are using a JS110.
The JS220 always computes statistics on instrument, so any sample loss over USB does not matter. With the JS110, you can use statistics computed on instrument as long as you do not need standard deviation. When starting “downsample_logging.py”, provide the --source sensor arguments. With this argument, sample loss over USB does not matter.
Once again thanks for the quick reply.
Correct, I have the JS110. I tried using the source argument as suggested,
(i.e --downsample 120 --source sensor) and it starts fine with no dropped packet warnings. However, when I exit using CTRL-C I get the error message below.
= RESTART: C:\Users\lukem\Downloads\pyjoulescope_examples-main\pyjoulescope_examples-main\bin\downsample_logging.py
Starting logging - press CTRL-C to stop
Found one Joulescope
2023-02-10T07:56:20 ERROR while capturing data
Traceback (most recent call last):
File “C:\Users\lukem\Downloads\pyjoulescope_examples-main\pyjoulescope_examples-main\bin\downsample_logging.py”, line 382, in run
msg = device.stop()
File “C:\Users\lukem\Downloads\pyjoulescope_examples-main\pyjoulescope_examples-main\bin\downsample_logging.py”, line 483, in stop
charge, energy = self._last[4], self._last[5]
TypeError: ‘NoneType’ object is not subscriptable
Great to hear that using --source sensor fixed the original issue.
I think that the new error on close was because you pressed CTRL-C before the first statistics sample was received. With your command line arguments, that would happen if you exit before 60 seconds or so. I just updated downsample_logging.py to cleanly handle this case.
The program exits cleanly now but unfortunately I don’t get any data in the CSV file. Im using;
–downsample 10 --source sensor and waiting for a few minutes so there should be data posted by then.
That’s strange. It looks like the JS110 sensor-side statistics are not working with the new driver backend. I looked at the code, and the new backend always uses sensor-side statistics for the JS220 and host-side statistics for the JS110. I just added this as issue #3.
In the meantime, you can use the old backend. If you are using PowerShell:
Hi Matt,
Unfortunately, I can’t test this at the moment as I’m travelling now. Will try it out when I’m back late next week. In the meantime I’m using the statistics option on the device with 1Hz reporting which will be fine - just a very large file when I get back!