[chirp_devel] [PATCH] [UV-5R] Add Support for UV-6 with Longer 12 byte Ident
Jim Unroe
Fri Aug 12 12:00:00 PDT 2016
# HG changeset patch
# User Jim Unroe <rock.unroe at gmail.com>
# Date 1471021507 14400
# Node ID 6bb69e375abee8778da5c6b7f77df1dddb8efe64
# Parent d32e651e117af20f04a946aeaa00b99fb828bae3
[UV-5R] Add Support for UV-6 with Longer 12 byte Ident
The currently shipping Baofeng UV-6 responds to the clone request by
returning a 12 byte "ident". The original model replies with an 8 byte "ident"
(the same as all other radios currently supported by the uv5r.py driver).
The current CHIRP driver appends the radio's memory image after the "ident"
so the settings structures are all offset by 8 bytes to accomodate these extra
bytes at the beginning of the image. So there must alway be exactly 8 bytes
prepended to the actual memory map data.
Original UV-6 ident:
AA 36 74 04 00 05 20 DD
New UV-6 ident:
AA 01 01 36 01 74 01 04 00 05 20 DD
This patch works around the issue by doing the following...
1. The "ident" is now read one byte at a time until the last byte ("\xdd")
is received. This make it compatible with an 8 byte and 12 byte "ident".
2. The 4 bytes of the ident containing "\x01" are discarded to shorten the
ident to the standard 8 byte length and to put the "ident" in the same
format as the "ident" of the other radio models.
Related to Bug #3063
diff -r d32e651e117a -r 6bb69e375abe chirp/drivers/uv5r.py
--- a/chirp/drivers/uv5r.py Mon Aug 01 10:35:10 2016 -0400
+++ b/chirp/drivers/uv5r.py Fri Aug 12 13:05:07 2016 -0400
@@ -284,7 +284,7 @@
BASETYPE_F11 = ["USA"]
BASETYPE_UV82 = ["US2S", "B82S", "BF82", "N82-2", "N822"]
BASETYPE_BJ55 = ["BJ55"] # needed for for the Baojie UV-55 in bjuv55.py
-BASETYPE_UV6 = ["BF1"]
+BASETYPE_UV6 = ["BF1", "UV6"]
BASETYPE_KT980HP = ["BFP3V3 B"]
BASETYPE_F8HP = ["BFP3V3 F", "N5R-3", "N5R3", "F5R3", "BFT"]
BASETYPE_UV82HP = ["N82-3", "N823"]
@@ -411,9 +411,40 @@
raise errors.RadioError("Radio did not respond")
serial.write("\x02")
- ident = serial.read(8)
- LOG.info("Ident: %s" % util.hexprint(ident))
+ # Until recently, the "ident" returned by the radios supported by this
+ # driver have always been 8 bytes long. The image sturcture is the 8 byte
+ # "ident" followed by the downloaded memory data. So all of the settings
+ # structures are offset by 8 bytes. The ident returned from a UV-6 radio
+ # can be 8 bytes (original model) or now 12 bytes.
+ #
+ # To accomodate this, the "ident" is now read one byte at a time until the
+ # last byte ("\xdd") is encountered. The bytes containing the value "\x01"
+ # are discarded to shrink the "ident" length down to 8 bytes to keep the
+ # image data aligned with the existing settings structures.
+
+ # Ok, get the response
+ ident = ""
+ for i in range(1, 13):
+ response = serial.read(1)
+ # discard any bytes containing "\x01" and keep the rest
+ if response != "\x01":
+ ident += response
+ # stop reading once the last byte ("\xdd") is encountered
+ if response == "\xdd":
+ break
+
+ # check if response is OK
+ if len(ident) != 8 or not ident.startswith("\xaa"):
+ # bad response
+ msg = "Unexpected response, got this:"
+ msg += util.hexprint(ident)
+ LOG.debug(msg)
+ raise errors.RadioError("Unexpected response from radio.")
+
+ # DEBUG
+ LOG.info("Valid response, got this:")
+ LOG.debug(util.hexprint(ident))
serial.write("\x06")
ack = serial.read(1)
More information about the chirp_devel
mailing list