Fixed issue where metadata would come with garbage#50
Fixed issue where metadata would come with garbage#50Tjoms99 wants to merge 7 commits intoIRNAS:masterfrom
Conversation
…2 session were not terminated properly due to garbage data coming along with the metadata. We now expect them and try to get metadata one more time, but this time without garbage from previous session
…ld also just work after connecting to a PPK2 via USB
|
Thanks for the fix, it helped to figure out the way my test work! Good fix for me :) |
|
Also tested and it works for me! |
|
This is on 4.2.0 and 4.2.1 fw. |
|
works fine, thank you! |
|
Works also on my side. @wlgrd is it possible to merge it into master? |
|
+1 Can we merge this? Running into the same issue. Is this project still actively maintained? |
MrKevinWeiss
left a comment
There was a problem hiding this comment.
A few small things, but at least now we can move!
…r treating the symptom instead of the root cause
…not be immidiatly discovered
…) messes up with higher level application loggers. The application using the ppk2 lib should decide what to do with the exceptions and thereby log what they need.
|
Did another pass on this locally and verified it against a connected PPK2. A couple of extra things came up while testing/integrating this in other code using the API:
I also removed the library-side logger usage that was ending up affecting my main application logger outside of ppk2. Hard failures now just raise instead of log-and-continue. Verified by running: This still works on my side with a connected PPK2 ( |
|
Just got back from vacation, I will try to find some time either today or tomorrow for testing and reviewing! |
|
oh 3 weeks old... I guess that slipped through the cracks 🫤 |
MrKevinWeiss
left a comment
There was a problem hiding this comment.
I tested with python3.13 but needed a change...
manual testing results with "fresh" ppk
(.venv) weiss@lobaro-laptop-kw:~/repos/ppk2-api-python$ python examples/example_measure_mw.py
Press Enter to exit...
PPK2 devices found: [('/dev/ttyACM0', 'D06D19AF')]
[('/dev/ttyACM0', 'D06D19AF')]
Connecting to /dev/ttyACM0
Initialized Power Profiler
139.58 mW, Avg: 139.58 mW
27.09 mW, Avg: 83.34 mW
26.72 mW, Avg: 64.46 mW
26.66 mW, Avg: 55.01 mW
26.45 mW, Avg: 49.30 mW
26.29 mW, Avg: 45.47 mW
26.24 mW, Avg: 42.72 mW
26.17 mW, Avg: 40.65 mW
26.04 mW, Avg: 39.03 mW
26.02 mW, Avg: 37.73 mW
25.99 mW, Avg: 36.66 mW
25.95 mW, Avg: 35.77 mW
25.9 mW, Avg: 35.01 mW
25.83 mW, Avg: 34.35 mW
26.51 mW, Avg: 33.83 mW
26.94 mW, Avg: 33.40 mW
26.71 mW, Avg: 33.01 mW
27.01 mW, Avg: 32.67 mW
27.01 mW, Avg: 32.37 mW
26.99 mW, Avg: 32.11 mW
27.43 mW, Avg: 31.88 mW
27.78 mW, Avg: 31.70 mW
30.21 mW, Avg: 31.63 mW
28.85 mW, Avg: 31.52 mW
(.venv) weiss@lobaro-laptop-kw:~/repos/ppk2-api-python$ python examples/example_measure_mw.py
Press Enter to exit...
PPK2 devices found: [('/dev/ttyACM0', 'D06D19AF')]
[('/dev/ttyACM0', 'D06D19AF')]
Connecting to /dev/ttyACM0
Initialized Power Profiler
155.98 mW, Avg: 155.98 mW
26.94 mW, Avg: 91.46 mW
26.68 mW, Avg: 69.87 mW
26.61 mW, Avg: 59.05 mW
26.38 mW, Avg: 52.52 mW
26.22 mW, Avg: 48.13 mW
26.16 mW, Avg: 45.00 mW
26.09 mW, Avg: 42.63 mW
26.09 mW, Avg: 40.79 mW
25.98 mW, Avg: 39.31 mW
25.96 mW, Avg: 38.10 mW
25.92 mW, Avg: 37.08 mW
25.89 mW, Avg: 36.22 mW
25.84 mW, Avg: 35.48 mW
25.84 mW, Avg: 34.84 mW
25.82 mW, Avg: 34.27 mW
26.67 mW, Avg: 33.83 mW
26.96 mW, Avg: 33.45 mW
26.99 mW, Avg: 33.11 mW
27.0 mW, Avg: 32.80 mW
26.99 mW, Avg: 32.52 mW
27.01 mW, Avg: 32.27 mW
28.76 mW, Avg: 32.12 mW
27.48 mW, Avg: 31.93 mW
^C30.57 mW, Avg: 31.87 mW
Traceback (most recent call last):
File "/home/weiss/repos/ppk2-api-python/examples/example_measure_mw.py", line 107, in <module>
main()
~~~~^^
File "/home/weiss/repos/ppk2-api-python/examples/example_measure_mw.py", line 102, in main
input("Press Enter to exit...\n")
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
(.venv) weiss@lobaro-laptop-kw:~/repos/ppk2-api-python$ python examples/example_measure_mw.py
Press Enter to exit...
PPK2 devices found: [('/dev/ttyACM0', 'D06D19AF')]
[('/dev/ttyACM0', 'D06D19AF')]
Connecting to /dev/ttyACM0
Initialized Power Profiler
131.61 mW, Avg: 131.61 mW
27.03 mW, Avg: 79.32 mW
26.74 mW, Avg: 61.79 mW
26.67 mW, Avg: 53.01 mW
26.45 mW, Avg: 47.70 mW
26.33 mW, Avg: 44.14 mW
26.21 mW, Avg: 41.58 mW
26.11 mW, Avg: 39.64 mW
26.07 mW, Avg: 38.14 mW
26.05 mW, Avg: 36.93 mW
26.0 mW, Avg: 35.93 mW
25.95 mW, Avg: 35.10 mW
25.9 mW, Avg: 34.39 mW
25.84 mW, Avg: 33.78 mW
26.46 mW, Avg: 33.29 mW
26.74 mW, Avg: 32.88 mW
26.8 mW, Avg: 32.53 mW
27.01 mW, Avg: 32.22 mW
26.99 mW, Avg: 31.95 mW
27.01 mW, Avg: 31.70 mW
27.43 mW, Avg: 31.50 mW
27.94 mW, Avg: 31.33 mW
29.77 mW, Avg: 31.27 mW
28.88 mW, Avg: 31.17 mW
| import time | ||
| import threading | ||
|
|
||
| from src.ppk2_api.ppk2_api import PPK2_API |
There was a problem hiding this comment.
| from src.ppk2_api.ppk2_api import PPK2_API | |
| from ppk2_api.ppk2_api import PPK2_API |
There was a problem hiding this comment.
Works with python3.10 (which is the oldest still supported) and I am a big fan of the type hints.
|
If you add the small change and squash then I would be happy to merge. |
|
Hmmm testing on a firmware updated ppk I get the first few readings as 0... Details |
Investigated the PR/issue discussed here #49.
Turns out not properly exiting a program running the PPK2 influences the next PPK2 session. Setting up the metadata the first time will throw an exception due to the garbage data (from the previous session) that comes a long with it. Physically turning the PPK2 on and off using the switch resolves this issue, but that’s inconvenient to do every time; So I’ve added a software fix here :)
To reproduce the issue and showcase the fix
Connect the PPK2 via USB
Open a terminal and run the example
This is where the
UnicodeDecodeErrorwould previously be triggered