# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1487298529 28800 # Thu Feb 16 18:28:49 2017 -0800 # Node ID 0611c6c740ab74c0d939634765a52ebc2b5a8497 # Parent 4569107adfccc72db9d12d8ecfcb7b97cfe06c65 Avoid confusing BTECH UV-5X3 users with UV-5X driver
Reportedly people that are buying the (new) BTECH UV-5X3 radio are confused and choosing the Baofeng UV-5X model from the menus, which won't work. Many are just outright returning the radio as a result, assuming it's broken.
Since there are a million UV-5R variants and this is likely to get worse, this patch adds a blacklist of similar magic strings from radios that may be confused easily. If we fail to probe the radio that was selected, we can probe for the blacklist magics, and if any reply, raise a specific error to the user indicating that they chose the wrong model.
#4539
diff -r 4569107adfcc -r 0611c6c740ab chirp/drivers/uv5r.py --- a/chirp/drivers/uv5r.py Sat Feb 11 17:25:25 2017 -0500 +++ b/chirp/drivers/uv5r.py Thu Feb 16 18:28:49 2017 -0800 @@ -395,7 +395,7 @@ return version
-def _do_ident(radio, magic): +def _do_ident(radio, magic, secondack=True): serial = radio.pipe serial.timeout = 1
@@ -448,10 +448,11 @@ LOG.debug(msg) raise errors.RadioError("Unexpected response from radio.")
- serial.write("\x06") - ack = serial.read(1) - if ack != "\x06": - raise errors.RadioError("Radio refused clone") + if secondack: + serial.write("\x06") + ack = serial.read(1) + if ack != "\x06": + raise errors.RadioError("Radio refused clone")
return ident
@@ -501,6 +502,11 @@ return version
+IDENT_BLACKLIST = { + "\x50\x0D\x0C\x20\x16\x03\x28": "Radio identifies as BTECH UV-5X3", +} + + def _ident_radio(radio): for magic in radio._idents: error = None @@ -511,6 +517,22 @@ LOG.error(e) error = e time.sleep(2) + + for magic, reason in IDENT_BLACKLIST.items(): + try: + _do_ident(radio, magic, secondack=False) + except errors.RadioError as e: + # No match, try the next one + continue + + # If we got here, it means we identified the radio as + # something other than one of our valid idents. Warn + # the user so they can do the right thing. + LOG.warning(('Identified radio as a blacklisted model ' + '(details: %s)') % reason) + raise errors.RadioError(('%s. Please choose the proper vendor/' + 'model and try again.') % reason) + if error: raise error raise errors.RadioError("Radio did not respond")