Skip to content

Commit

Permalink
ga510.py: add 'reset' after clone error and upload
Browse files Browse the repository at this point in the history
The radio has to be power cycled after upload or clone errors. This
patch fixes issue by adding missing 'resets' to close communicatons.
  • Loading branch information
KC9HI authored and kk7ds committed Jul 18, 2023
1 parent 4f39ef1 commit 1e31e49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chirp/drivers/ga510.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def start_program(radio):
if not ack.endswith(b'\x06'):
LOG.debug('Ack was %r' % ack)
raise errors.RadioError('Radio did not respond to clone request')
reset(radio)

This comment has been minimized.

Copy link
@dforsi

dforsi Jul 30, 2023

Contributor

this and the other calls to reset(radio) after raising an exception won't be executed

This comment has been minimized.

Copy link
@kk7ds

kk7ds Jul 30, 2023

Owner

Sure enough, I clearly didn't review this very carefully.

Jim, the best way to do this is to either catch the exception from above or use a finally block which makes sure the last thing we ever do is reset the radio. Something like:

def sync_in(self):
    try:
        do_download(self)
    finally:
        reset(self)

The thing in the finally block always runs, even if exceptions are raised so we'll always do that before we leave here and raise back to the GUI (or even if we don't)

This comment has been minimized.

Copy link
@kk7ds

kk7ds Jul 30, 2023

Owner

(cc @KC9HI in case github didn't already notify you)


radio.pipe.write(b'F')

Expand Down Expand Up @@ -85,9 +86,11 @@ def do_download(radio):
if raddr != addr:
raise errors.RadioError('Radio send address %04x, expected %04x' %
(raddr, addr))
reset(radio)
if rlen != 0x40 or len(block) != 0x40:
raise errors.RadioError('Radio sent %02x (%02x) bytes, '
'expected %02x' % (rlen, len(block), 0x40))
reset(radio)

data += block

Expand Down Expand Up @@ -119,10 +122,13 @@ def do_upload(radio):
ack = radio.pipe.read(1)
if ack != b'\x06':
raise errors.RadioError('Radio refused block at addr %04x' % addr)
reset(radio)

s.cur = addr
radio.status_fn(s)

reset(radio)


BASE_FORMAT = """
struct {
Expand Down

0 comments on commit 1e31e49

Please sign in to comment.