Bug #9541

Cannot Download from TYT TH-7800: local variable 'ack' referenced before assignment

Added by Patrick Snyder 14 days ago.

Status:New Start date:11/12/2021
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:chirp-daily
Chirp Version:daily Platform:Linux
Model affected:(All models)

Description

I'm having an issue downloading the data from my TYT TH7800. I have seen other users report something similar in the past and a bug fix was generally pushed out for their specific radio/scenario.

ERROR: Failed to clone: Failed to communicate with the radio: local variable 'ack' referenced before assignment

Tried to dig into it myself and contribute but just don't have time at the moment. I was able to run chirp on another linux box running Raspbian (which looks to be executing chirpw using python2.7) and that version downloads and uploads to the radio just fine, however the kali linux box I want to run chirp on looks to execute it in python3.9 which seems to be causing the issue. I've isolated it to the th7800.py driver file, the _identify function, and can see when the 'ack' variable is attempting to be referenced (line 577 of ..chirp/drivers/th7800.py) I assume older versions of python were either less strict about variable references or, more likely, one of the earlier functions that gets the data to set that ack variable are failing in python3 and cascading down to this point.

def _identify(radio):
    """Do identify handshake with TYT""" 
    try:
        radio.pipe.write("\x02SPECPR")
        ack = radio.pipe.read(1)
        if ack != "A":
            util.hexprint(ack)
            raise errors.RadioError("Radio did not ACK first command: %x" 
                                    % ord(ack))
    except:
        LOG.debug(util.hexprint(ack))
        raise errors.RadioError("Unable to communicate with the radio")

    radio.pipe.write("G\x02")
    ident = radio.pipe.read(16)
    radio.pipe.write("A")
    r = radio.pipe.read(2)
    if r != "A":
        raise errors.RadioError("Ack failed")
    return ident

Then again I could be totally wrong about all this...its been a while since I've dug into some python code. Thanks for the help.

Radio info:
Trying to download from a TYT TH7800.

Version info:
CHIRP 0.3.0dev on Linux kalishack 5.14.0-kali2-amd64 #1 SMP Debian 5.14.9-2kali1 (2021-10-04) x86_64 (Python 3.9.7)

Also available in: Atom PDF