0x9900 / SA818

Programming software for the SA818 radio module.
BSD 2-Clause "Simplified" License
40 stars 22 forks source link

SA818: ERROR: Unable to decode the firmware version #21

Closed Allan-N closed 5 months ago

Allan-N commented 5 months ago

I have an SA818 and exec'ing sa818 version fails with the following :

SA818: ERROR: Unable to decode the firmeare version
Traceback (most recent call last):
  File "/usr/bin/sa818", line 425, in <module>
    main()
  File "/usr/bin/sa818", line 409, in main
    radio.version()
  File "/usr/bin/sa818", line 121, in version
    return version
           ^^^^^^^
UnboundLocalError: cannot access local variable 'version' where it is not associated with a value

With a bit of debugging I found the reply string include 2 "_" characters (+VERSION:SA818_V5.5_MM).

The following diff appears to resolve the issue (for me).

diff --git a/sa818.py b/sa818.py
index 71f1a7f..0bdb96d 100755
--- a/sa818.py
+++ b/sa818.py
@@ -113,7 +113,7 @@ class SA818:
     time.sleep(0.5)
     reply = self.readline()
     try:
-      _, version = reply.split('_')
+      _, version = reply.split('_', 1)
     except ValueError:
       logger.error('Unable to decode the firmeare version')
     else:

Bonus points if you can also correct two typos (firweare --> firmware, tome --> tone)

0x9900 commented 5 months ago

Thanks for the patch. I have integrated your changes. -fred-