cdump / radiacode

Library for RadiaCode-101
MIT License
108 stars 20 forks source link

Stop work after update RC-101 #20

Closed slimpdev closed 10 months ago

slimpdev commented 10 months ago

Hello.

After update FW of Device when i start "sudo python3 -m radiacode-examples.basic" i see error:

### DataBuf:
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/radiacode-examples/basic.py", line 39, in <module>
    main()
  File "/usr/local/lib/python3.11/dist-packages/radiacode-examples/basic.py", line 33, in main
    for v in rc.data_buf():
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/radiacode/radiacode.py", line 133, in data_buf
    return decode_VS_DATA_BUF(r, self._base_time)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/radiacode/decoders/databuf.py", line 18, in decode_VS_DATA_BUF
    raise Exception(f'seq jump, expect:{next_seq}, got:{seq}')
Exception: seq jump, expect:230, got:46

Bluetooth connect not worked too. Try on other RPi with same error. FW number 04.08 Any ideas how to fix it?

ckuethe commented 10 months ago

Can't reproduce on Ubuntu 22.04 x86_64, kernel 6.5.6, RC-102 fw 4.0.8, and this module v0.2.2

slimpdev commented 10 months ago

My OS 6.1.0-rpi6-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27) aarch64 And log when i try use bluetooth connect:

python3 -m radiacode-examples.webserver --bluetooth-mac 52:43:06:50:00:6F
will use Bluetooth connection
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<process() done, defined at /home/SlimpDev/.local/lib/python3.11/site-packages/radiacode-examples/webserver.py:48> exception=Exception('seq jump, expect:58, got:46')>
Traceback (most recent call last):
  File "/home/SlimpDev/.local/lib/python3.11/site-packages/radiacode-examples/webserver.py", line 52, in process
    databuf = app.rc_conn.data_buf()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/SlimpDev/.local/lib/python3.11/site-packages/radiacode/radiacode.py", line 133, in data_buf
    return decode_VS_DATA_BUF(r, self._base_time)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/SlimpDev/.local/lib/python3.11/site-packages/radiacode/decoders/databuf.py", line 18, in decode_VS_DATA_BUF
    raise Exception(f'seq jump, expect:{next_seq}, got:{seq}')
Exception: seq jump, expect:58, got:46
======== Running on http://0.0.0.0:8080 ========

Server was started, but no data updates.

cdump commented 10 months ago

I can confirm the bug after upgrading to the new firmware - looks like authors break the compatibility and replace some message types, I will take a look to it and new version of radiacode library will be released, compatible with new firmware.

cdump commented 10 months ago

Try v0.3.0 - it's compatible only with new firmware (for older FW you can use v0.2.x) radiacode API is also slightly changed (see git diff in examples/) to reflect changes in API of the new firmware

ckuethe commented 10 months ago

I've got another detector on the way, so I can revert one of them to 4.07 and maybe find a way to keep support for older firmwares too.

At least over USB, v0.2.2 is able to poll the version from fw4.07 and fw4.08.

cdump commented 10 months ago

I don't think it's reasonable to support old firmware in the v0.3.x. Of course, it's possible, but it will add unnecessary complexity and make the code less clean. Anyone who can't upgrade to the new firmware can continue using 0.2.x versions.

That's the reason why I changed the API of this radiacode package and didn't try to split RealTimeData into existing CountRate & DoseRate types, just to avoid breaking compatibility at any cost.

slimpdev commented 10 months ago

I can confirm that data transfer is now working on the new firmware. Thank you. P.S. Now I will think how to update mqttpub.py so that it would also work with the new firmware.