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 a288abd commit c6cf1a7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 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 @@ -60,7 +63,9 @@ def _get_memory_map(radio):

def _download(radio):
"""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 c6cf1a7

Please sign in to comment.