Skip to content

Commit

Permalink
uv17: Refactor to handle ga510v2
Browse files Browse the repository at this point in the history
- Allows skipping ident if we are a detected model
- Assumes memsize is fixed if the magics are empty
- Logs missing blocks with more detail
  • Loading branch information
kk7ds committed Jun 25, 2024
1 parent a845e81 commit 5feefc8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions chirp/drivers/baofeng_uv17.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def _get_memory_size(radio):
def _get_memory_map(radio):
# Get memory map
memory_map = []
mem_size = _get_memory_size(radio)
if radio._magic_memsize:
mem_size = _get_memory_size(radio)
else:
mem_size = radio._radio_memsize
if mem_size != radio._radio_memsize:
raise errors.RadioError("Incorrect radio model or model not supported "
"(memory size doesn't match)")
Expand All @@ -58,9 +61,11 @@ def _get_memory_map(radio):
return memory_map


def _download(radio):
def _download(radio: chirp_common.CloneModeRadio):
"""Get the memory map"""
baofeng_uv17Pro._do_ident(radio)
if not radio._DETECTED_BY:
# The GA510v2 (at least) is detected, and thus has already done ident
baofeng_uv17Pro._do_ident(radio)
data = b""
memory_map = _get_memory_map(radio)

Expand All @@ -73,6 +78,8 @@ def _download(radio):
for block_number in radio.BLOCK_ORDER:
if block_number not in memory_map:
# Memory block not found.
LOG.error('Block %i (0x%x) not in memory map: %s',
block_number, block_number, memory_map)
raise errors.RadioError('Radio memory is corrupted. ' +
'Fix this by uploading a backup image ' +
'to the radio.')
Expand Down

0 comments on commit 5feefc8

Please sign in to comment.