Fixes and testing: retevis_rt22.py & update Python3 Driver Testing matrix

This commit is contained in:
Jim Unroe 2022-12-08 21:39:10 -05:00 committed by Dan Smith
parent 1c56250a33
commit adb317bb0d
3 changed files with 35 additions and 30 deletions

View File

@ -75,7 +75,7 @@ struct {
} embedded_msg;
"""
CMD_ACK = "\x06"
CMD_ACK = b"\x06"
RT22_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=2.00),
chirp_common.PowerLevel("High", watts=5.00)]
@ -124,12 +124,12 @@ def _get_radio_model(radio):
def _rt22_enter_programming_mode(radio):
serial = radio.pipe
magic = "PROGRGS"
magic = b"PROGRGS"
exito = False
for i in range(0, 5):
for j in range(0, len(magic)):
time.sleep(0.005)
serial.write(magic[j])
serial.write(magic[j:j + 1])
ack = serial.read(1)
try:
@ -147,7 +147,7 @@ def _rt22_enter_programming_mode(radio):
raise errors.RadioError(msg)
try:
serial.write("\x02")
serial.write(b"\x02")
ident = serial.read(8)
except:
_rt22_exit_programming_mode(radio)
@ -178,13 +178,13 @@ def _rt22_enter_programming_mode(radio):
raise errors.RadioError("Radio refused to enter programming mode")
try:
serial.write("\x07")
serial.write(b"\x07")
ack = serial.read(1)
except:
_rt22_exit_programming_mode(radio)
raise errors.RadioError("Error communicating with radio")
if ack != "\x4E":
if ack != b"\x4E":
_rt22_exit_programming_mode(radio)
raise errors.RadioError("Radio refused to enter programming mode")
@ -194,7 +194,7 @@ def _rt22_enter_programming_mode(radio):
def _rt22_exit_programming_mode(radio):
serial = radio.pipe
try:
serial.write("E")
serial.write(b"E")
except:
raise errors.RadioError("Radio refused to exit programming mode")
@ -202,14 +202,14 @@ def _rt22_exit_programming_mode(radio):
def _rt22_read_block(radio, block_addr, block_size):
serial = radio.pipe
cmd = struct.pack(">cHb", 'R', block_addr, block_size)
expectedresponse = "W" + cmd[1:]
cmd = struct.pack(">cHb", b'R', block_addr, block_size)
expectedresponse = b"W" + cmd[1:]
LOG.debug("Reading block %04x..." % (block_addr))
try:
for j in range(0, len(cmd)):
time.sleep(0.005)
serial.write(cmd[j])
serial.write(cmd[j:j + 1])
response = serial.read(4 + block_size)
if response[:4] != expectedresponse:
@ -236,11 +236,10 @@ def _rt22_write_block(radio, block_addr, block_size, _requires_patch=False,
_radio_id=""):
serial = radio.pipe
cmd = struct.pack(">cHb", 'W', block_addr, block_size)
cmd = struct.pack(">cHb", b'W', block_addr, block_size)
if _requires_patch:
mmap = radio.get_mmap()
data = mmap[block_addr:block_addr + block_size]
# For some radios (RT-622 & RT22FRS) memory at 0x1b8 reads as 0, but
# radio ID should be written instead
if block_addr == 0x1b8:
@ -256,10 +255,10 @@ def _rt22_write_block(radio, block_addr, block_size, _requires_patch=False,
try:
for j in range(0, len(cmd)):
time.sleep(0.005)
serial.write(cmd[j])
serial.write(cmd[j:j + 1])
for j in range(0, len(data)):
time.sleep(0.005)
serial.write(data[j])
serial.write(data[j:j + 1])
if serial.read(1) != CMD_ACK:
raise Exception("No ACK")
except:
@ -273,7 +272,7 @@ def do_download(radio):
radio_ident = _rt22_enter_programming_mode(radio)
LOG.info("Radio Ident is %s" % repr(radio_ident))
data = ""
data = b""
status = chirp_common.Status()
status.msg = "Cloning from radio"
@ -291,11 +290,9 @@ def do_download(radio):
LOG.debug("Address: %04x" % addr)
LOG.debug(util.hexprint(block))
data += radio.MODEL.ljust(8)
_rt22_exit_programming_mode(radio)
return memmap.MemoryMap(data)
return memmap.MemoryMapBytes(data)
def do_upload(radio):
@ -309,7 +306,7 @@ def do_upload(radio):
LOG.info("Image Ident is %s" % repr(image_ident))
# Determine if upload requires patching
if image_ident == "\x00\x00\x00\x00\x00\x00\xFF\xFF":
if image_ident == b"\x00\x00\x00\x00\x00\x00\xFF\xFF":
patch_block = True
else:
patch_block = False
@ -343,6 +340,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
VENDOR = "Retevis"
MODEL = "RT22"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
_ranges = [
(0x0000, 0x0180, 0x10),
@ -352,8 +350,8 @@ class RT22Radio(chirp_common.CloneModeRadio):
]
_memsize = 0x0400
_block_size = 0x40
_fileid = ["P32073", "P3" + "\x00\x00\x00" + "3", "P3207!",
"\x00\x00\x00\x00\x00\x00\xF8\xFF"]
_fileid = [b"P32073", b"P3" + b"\x00\x00\x00" + b"3", b"P3207!",
b"\x00\x00\x00\x00\x00\x00\xF8\xFF"]
def get_features(self):
rf = chirp_common.RadioFeatures()

View File

@ -186,7 +186,7 @@
| <a name="Kenwood_TS-590S_CloneMode"></a> Kenwood_TS-590S_CloneMode | | | | 0.00% |
| <a name="Kenwood_TS-590S_SG_LiveMode"></a> Kenwood_TS-590S_SG_LiveMode | | | Yes | |
| <a name="Kenwood_TS-850"></a> Kenwood_TS-850 | | | Yes | 0.00% |
| <a name="LUITON_LT-316"></a> LUITON_LT-316 | | | | 0.04% |
| <a name="LUITON_LT-316"></a> LUITON_LT-316 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | 0.04% |
| <a name="LUITON_LT-580_UHF"></a> LUITON_LT-580_UHF | [@KC9HI](https://github.com/KC9HI) | 8-Dec-2022 | Yes | 0.01% |
| <a name="LUITON_LT-580_VHF"></a> LUITON_LT-580_VHF | [@KC9HI](https://github.com/KC9HI) | 8-Dec-2022 | Yes | 0.01% |
| <a name="LUITON_LT-588UV"></a> LUITON_LT-588UV | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.01% |
@ -247,8 +247,8 @@
| <a name="Retevis_RT16"></a> Retevis_RT16 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.02% |
| <a name="Retevis_RT19"></a> Retevis_RT19 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.00% |
| <a name="Retevis_RT21"></a> Retevis_RT21 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.20% |
| <a name="Retevis_RT22"></a> Retevis_RT22 | | | | 0.54% |
| <a name="Retevis_RT22FRS"></a> Retevis_RT22FRS | | | | 0.04% |
| <a name="Retevis_RT22"></a> Retevis_RT22 | [@KC9HI](https://github.com/KC9HI) | 9-Dec-2022 | Yes | 0.54% |
| <a name="Retevis_RT22FRS"></a> Retevis_RT22FRS | [@KC9HI](https://github.com/KC9HI) | 9-Dec-2022 | Yes | 0.04% |
| <a name="Retevis_RT22S"></a> Retevis_RT22S | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.04% |
| <a name="Retevis_RT23"></a> Retevis_RT23 | | | | 0.04% |
| <a name="Retevis_RT26"></a> Retevis_RT26 | | | | 0.03% |
@ -259,7 +259,7 @@
| <a name="Retevis_RT47V"></a> Retevis_RT47V | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.00% |
| <a name="Retevis_RT6"></a> Retevis_RT6 | [@KC9HI](https://github.com/KC9HI) | 3-Dec-2022 | Yes | 0.04% |
| <a name="Retevis_RT619"></a> Retevis_RT619 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.00% |
| <a name="Retevis_RT622"></a> Retevis_RT622 | | | | 0.09% |
| <a name="Retevis_RT622"></a> Retevis_RT622 | [@KC9HI](https://github.com/KC9HI) | 9-Dec-2022 | Yes | 0.09% |
| <a name="Retevis_RT647"></a> Retevis_RT647 | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.00% |
| <a name="Retevis_RT668"></a> Retevis_RT668 | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.03% |
| <a name="Retevis_RT68"></a> Retevis_RT68 | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.03% |
@ -278,7 +278,7 @@
| <a name="Sainsonic_AP510"></a> Sainsonic_AP510 | | | | 0.00% |
| <a name="TDXone_TD-Q8A"></a> TDXone_TD-Q8A | | | | 0.02% |
| <a name="TIDRADIO_TD-H6"></a> TIDRADIO_TD-H6 | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes | 0.43% |
| <a name="TID_TD-M8"></a> TID_TD-M8 | | | | 0.04% |
| <a name="TID_TD-M8"></a> TID_TD-M8 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | 0.04% |
| <a name="TYT_TH-350"></a> TYT_TH-350 | | | Yes | 0.07% |
| <a name="TYT_TH-7800"></a> TYT_TH-7800 | | | | 0.13% |
| <a name="TYT_TH-7800_File"></a> TYT_TH-7800_File | | | | |
@ -299,7 +299,7 @@
| <a name="Vertex_Standard_FTL-8011"></a> Vertex_Standard_FTL-8011 | | | | |
| <a name="Vertex_Standard_VXA-700"></a> Vertex_Standard_VXA-700 | | | | |
| <a name="WACCOM_MINI-8900"></a> WACCOM_MINI-8900 | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.10% |
| <a name="WLN_KD-C1"></a> WLN_KD-C1 | | | | **1.74%** |
| <a name="WLN_KD-C1"></a> WLN_KD-C1 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | **1.74%** |
| <a name="Wouxun_KG-816"></a> Wouxun_KG-816 | | | | 0.07% |
| <a name="Wouxun_KG-818"></a> Wouxun_KG-818 | | | | 0.04% |
| <a name="Wouxun_KG-935G"></a> Wouxun_KG-935G | | | | 0.05% |
@ -355,14 +355,14 @@
| <a name="Yaesu_VX-8GE"></a> Yaesu_VX-8GE | [Implied by Yaesu_VX-8DR](#user-content-Yaesu_VX-8DR) | 15-Feb-2019 | Yes | 0.01% |
| <a name="Yaesu_VX-8R"></a> Yaesu_VX-8R | [Implied by Yaesu_VX-8DR](#user-content-Yaesu_VX-8DR) | 15-Feb-2019 | Yes | 0.03% |
| <a name="Yedro_YC-M04VUS"></a> Yedro_YC-M04VUS | [Implied by Retevis_RT95](#user-content-Retevis_RT95) | 13-Nov-2022 | Yes | 0.02% |
| <a name="Zastone_ZT-X6"></a> Zastone_ZT-X6 | | | | 0.11% |
| <a name="Zastone_ZT-X6"></a> Zastone_ZT-X6 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | 0.11% |
## Stats
**Drivers:** 355
**Tested:** 51% (184/171) (75% of usage stats)
**Tested:** 53% (191/164) (77% of usage stats)
**Byte clean:** 68% (242/113)
**Byte clean:** 70% (249/106)
## Minimal test prodecure
For the purposes of the Python 3 effort, a "tested" radio means

View File

@ -102,6 +102,7 @@ Kenwood_TK-768,+Kenwood_TK-760,5-Dec-2022
Kenwood_TK-860,+Kenwood_TK-760,5-Dec-2022
Kenwood_TK-862,+Kenwood_TK-760,5-Dec-2022
Kenwood_TK-868,+Kenwood_TK-760,5-Dec-2022
LUITON_LT-316,+Retevis_RT22,9-Dec-2022
LUITON_LT-580_UHF,@KC9HI,8-Dec-2022
LUITON_LT-580_VHF,@KC9HI,8-Dec-2022
LUITON_LT-588UV,@KC9HI,11-Nov-2022
@ -145,6 +146,8 @@ Retevis_RB85,@KC9HI,28-Nov-2022
Retevis_RT16,@KC9HI,30-Nov-2022
Retevis_RT19,@KC9HI,30-Nov-2022
Retevis_RT21,@KC9HI,30-Nov-2022
Retevis_RT22,@KC9HI,9-Dec-2022
Retevis_RT22FRS,@KC9HI,9-Dec-2022
Retevis_RT22S,@KC9HI,28-Nov-2022
Retevis_RT29_UHF,@KC9HI,30-Nov-2022
Retevis_RT29_VHF,@KC9HI,30-Nov-2022
@ -153,6 +156,7 @@ Retevis_RT47,@KC9HI,28-Nov-2022
Retevis_RT47V,@KC9HI,28-Nov-2022
Retevis_RT6,@KC9HI,3-Dec-2022
Retevis_RT619,@KC9HI,30-Nov-2022
Retevis_RT622,@KC9HI,9-Dec-2022
Retevis_RT647,@KC9HI,28-Nov-2022
Retevis_RT668,@KC9HI,28-Nov-2022
Retevis_RT68,@KC9HI,28-Nov-2022
@ -165,11 +169,13 @@ Retevis_RT9000D_220-260,@KC9HI,8-Dec-2022
Retevis_RT9000D_400-490,@KC9HI,8-Dec-2022
Retevis_RT9000D_66-88,@KC9HI,8-Dec-2022
TIDRADIO_TD-H6,@kk7ds,21-Oct-2022
TID_TD-M8,+Retevis_RT22,9-Dec-2022
TYT_TH-UV88,@KC9HI,5-Dec-2022
TYT_TH9000_144,+Retevis_RT9000D_136-174,8-Dec-2022
TYT_TH9000_220,+Retevis_RT9000D_220-260,8-Dec-2022
TYT_TH9000_440,+Retevis_RT9000D_400-490,8-Dec-2022
WACCOM_MINI-8900,@KC9HI,11-Nov-2022
WLN_KD-C1,+Retevis_RT22,9-Dec-2022
Yaesu_FT-1500M,@f3sty,05-Dec-2022
Yaesu_FT-70D,@n8sqt,05-Dec-2022
Yaesu_FT-7800_7900,@kk7ds,24-Oct-2022
@ -188,3 +194,4 @@ Yaesu_VX-8R,+Yaesu_VX-8DR,15-Feb-2019
Yaesu_VX-8DR,@kk7ds,15-Feb-2019
Yaesu_VX-8GE,+Yaesu_VX-8DR,15-Feb-2019
Yedro_YC-M04VUS,+Retevis_RT95,13-Nov-2022
Zastone_ZT-X6,+Retevis_RT22,9-Dec-2022