AnyTone 5888UVIII Python 3 updates, tested with radio, added to cpep8 manifest

This commit is contained in:
Brad Schuler 2023-01-10 00:15:57 -07:00 committed by Dan Smith
parent 12301814e2
commit 17dd37e175
4 changed files with 30 additions and 26 deletions

View File

@ -39,7 +39,8 @@ class ATBankModel(chirp_common.BankModel):
self._banks = []
self._memBounds = list(range(0, 750))
for i in range(0, 10):
self._banks.append(chirp_common.Bank(self, i, string.ascii_uppercase[i]))
self._banks.append(
chirp_common.Bank(self, i, string.ascii_uppercase[i]))
def get_num_mappings(self):
return len(self._banks)
@ -538,33 +539,33 @@ def _read(radio, length):
raise errors.RadioError("Short read from radio")
return data
valid_model = ['I588UVP']
valid_model = [b'I588UVP']
def _ident(radio):
radio.pipe.timeout = 1
_echo_write(radio, "PROGRAM")
_echo_write(radio, b"PROGRAM")
response = radio.pipe.read(3)
if response != "QX\x06":
if response != b"QX\x06":
LOG.debug("Response was:\n%s" % util.hexprint(response))
raise errors.RadioError("Unsupported model")
_echo_write(radio, "\x02")
_echo_write(radio, b"\x02")
response = radio.pipe.read(16)
LOG.debug(util.hexprint(response))
if response[15] != "\x06":
if response[-1:] != b"\x06":
LOG.debug("Response was:\n%s" % util.hexprint(response))
raise errors.RadioError("Missing ack")
if response[0:7] not in valid_model:
LOG.debug("Response was:\n%s" % util.hexprint(response))
raise errors.RadioError("Unsupported model")
# Manufacturer software does this also: _send(radio, 'R', 0x0080, 0x10)
# Manufacturer software does this also: _send(radio, b'R', 0x0080, 0x10)
def _finish(radio):
endframe = "\x45\x4E\x44"
endframe = b"\x45\x4E\x44"
_echo_write(radio, endframe)
result = radio.pipe.read(1)
if result != "\x06":
if result != b"\x06":
LOG.debug("Got:\n%s" % util.hexprint(result))
raise errors.RadioError("Radio did not finish cleanly")
@ -572,7 +573,7 @@ def _finish(radio):
def _checksum(data):
cs = 0
for byte in data:
cs += ord(byte)
cs += byte
return cs % 256
@ -580,14 +581,14 @@ def _send(radio, cmd, addr, length, data=None):
frame = struct.pack(">cHb", cmd, addr, length)
if data:
frame += data
frame += chr(_checksum(frame[1:]))
frame += "\x06"
frame += bytes([_checksum(frame[1:])])
frame += b"\x06"
_echo_write(radio, frame)
LOG.debug("Sent:\n%s" % util.hexprint(frame))
if data:
result = radio.pipe.read(1)
if result != "\x06":
LOG.debug("Ack was: %s" % repr(result))
if result != b"\x06":
LOG.debug("Ack was: %s" % util.hexprint(result))
raise errors.RadioError(
"Radio did not accept block at %04x" % addr)
return
@ -595,8 +596,8 @@ def _send(radio, cmd, addr, length, data=None):
LOG.debug("Got:\n%s" % util.hexprint(result))
header = result[0:4]
data = result[4:-2]
ack = result[-1]
if ack != "\x06":
ack = result[-1:]
if ack != b"\x06":
LOG.debug("Ack was: %s" % repr(ack))
raise errors.RadioError("Radio NAK'd block at %04x" % addr)
_cmd, _addr, _length = struct.unpack(">cHb", header)
@ -606,9 +607,9 @@ def _send(radio, cmd, addr, length, data=None):
LOG.debug(" Addr: %04x/%04x" % (addr, _addr))
raise errors.RadioError("Radio send unexpected block")
cs = _checksum(result[1:-2])
if cs != ord(result[-2]):
if cs != result[-2]:
LOG.debug("Calculated: %02x" % cs)
LOG.debug("Actual: %02x" % ord(result[-2]))
LOG.debug("Actual: %02x" % result[-2])
raise errors.RadioError("Block at 0x%04x failed checksum" % addr)
return data
@ -618,13 +619,13 @@ def _download(radio):
memobj = None
data = ""
data = b""
for start, end in radio._ranges:
for addr in range(start, end, 0x10):
if memobj is not None and not _should_send_addr(memobj, addr):
block = "\x00" * 0x10
block = b"\x00" * 0x10
else:
block = _send(radio, 'R', addr, 0x10)
block = _send(radio, b'R', addr, 0x10)
data += block
status = chirp_common.Status()
@ -638,7 +639,7 @@ def _download(radio):
_finish(radio)
return memmap.MemoryMap(data)
return memmap.MemoryMapBytes(data)
def _upload(radio):
@ -649,7 +650,7 @@ def _upload(radio):
if not _should_send_addr(radio._memobj, addr):
continue
block = radio._mmap[addr:addr + 0x10]
_send(radio, 'W', addr, len(block), block)
_send(radio, b'W', addr, len(block), block)
status = chirp_common.Status()
status.cur = addr
@ -798,6 +799,7 @@ class AnyTone5888UVIIIRadio(chirp_common.CloneModeRadio,
VENDOR = "AnyTone"
MODEL = "5888UVIII"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
_file_ident = b"588UVP"
_ranges = [

View File

@ -13,7 +13,7 @@
| <a name="Alinco_DR235T"></a> Alinco_DR235T | [@kk7ds](https://github.com/kk7ds) | 12-Dec-2022 | Yes | 0.02% |
| <a name="Alinco_DR435T"></a> Alinco_DR435T | [Implied by Alinco_DR235T](#user-content-Alinco_DR235T) | 12-Dec-2022 | Yes | 0.02% |
| <a name="AnyTone_5888UV"></a> AnyTone_5888UV | [@kk7ds](https://github.com/kk7ds) | 9-Dec-2022 | Yes | 0.14% |
| <a name="AnyTone_5888UVIII"></a> AnyTone_5888UVIII | | | | 0.04% |
| <a name="AnyTone_5888UVIII"></a> AnyTone_5888UVIII | [@bschuler42](https://github.com/bschuler42) | 9-Jan-2023 | Yes | 0.04% |
| <a name="AnyTone_778UV"></a> AnyTone_778UV | [Implied by Retevis_RT95](#user-content-Retevis_RT95) | 13-Nov-2022 | Yes | 0.17% |
| <a name="AnyTone_778UV_VOX"></a> AnyTone_778UV_VOX | [Implied by Retevis_RT95](#user-content-Retevis_RT95) | 13-Nov-2022 | Yes | 0.23% |
| <a name="AnyTone_OBLTR-8R"></a> AnyTone_OBLTR-8R | [@KC9HI](https://github.com/KC9HI) | 17-Dec-2022 | Yes | 0.02% |
@ -364,9 +364,9 @@
**Drivers:** 359
**Tested:** 79% (287/72) (92% of usage stats)
**Tested:** 80% (288/71) (92% of usage stats)
**Byte clean:** 86% (311/48)
**Byte clean:** 86% (312/47)
## Meaning of this testing

View File

@ -22,6 +22,7 @@ Anysecu_WP-9900,@KC9HI,11-Nov-2022
AnyTone_778UV,+Retevis_RT95,13-Nov-2022
AnyTone_778UV_VOX,+Retevis_RT95,13-Nov-2022
AnyTone_5888UV,@kk7ds,9-Dec-2022
AnyTone_5888UVIII,@bschuler42,9-Jan-2023
AnyTone_OBLTR-8R,@KC9HI,17-Dec-2022
AnyTone_TERMN-8R,@KC9HI,17-Dec-2022
BTECH_FRS-A1,@KC9HI,30-Nov-2022

View File

@ -14,6 +14,7 @@
./chirp/drivers/alinco.py
./chirp/drivers/anytone.py
./chirp/drivers/anytone_ht.py
./chirp/drivers/anytone_iii.py
./chirp/drivers/anytone778uv.py
./chirp/drivers/ap510.py
./chirp/drivers/baofeng_common.py