[chirp_devel] [PATCH] [UV-5R] UV-82HP (An error has occurred, Unexpected response from radio)

Jim Unroe
Thu Sep 22 16:58:36 PDT 2016


did this patch ever get delivered to the chirp-devel mailing list?

Jim KC9HI

On Tue, Sep 20, 2016 at 7:51 PM, Jim Unroe <rock.unroe at gmail.com> wrote:
> # HG changeset patch
> # User Jim Unroe <rock.unroe at gmail.com>
> # Date 1474414440 14400
> # Node ID 094e758be36b3c8c34aff852a2f9770f5773d65a
> # Parent  a1b8b53606f6025fc1ad727331837cfc7759f178
> [UV-5R] UV-82HP (An error has occurred, Unexpected response from radio)
>
> The "ident" returned by the radios supported by the uv5r.py driver used to be
> static. The "ident" of the UV-82HP radio (and possibly other recent Baofeng
> radios) now changes based on the band limit settings. When setting a band limit
> to "1" or and value ending in "01" (101, 201, 301, etc.), the value ends up in
> the "ident" and is stripped by the code that was added to support the UV-6 with
> the longer 12 byte "ident".
>
> This patch uses a different strategy to support the UV-6 with longer "ident"
> restoring the use of any selectable band limit value.
>
> Bug #3987
>
> diff -r a1b8b53606f6 -r 094e758be36b chirp/drivers/uv5r.py
> --- a/chirp/drivers/uv5r.py     Sat Sep 10 11:34:01 2016 -0400
> +++ b/chirp/drivers/uv5r.py     Tue Sep 20 19:34:00 2016 -0400
> @@ -426,26 +426,28 @@
>      # Ok, get the response
>      ident = ""
>      for i in range(1, 13):
> -        response = serial.read(1)
> -        # discard any bytes containing "\x01" and keep the rest
> -        if response != "\x01":
> -            ident += response
> +        byte = serial.read(1)
> +        response += byte
>          # stop reading once the last byte ("\xdd") is encountered
> -        if response == "\xdd":
> +        if byte == "\xdd":
>              break
>
>      # check if response is OK
> -    if len(ident) != 8 or not ident.startswith("\xaa"):
> +    if len(response) in [8, 12]:
> +        # DEBUG
> +        LOG.info("Valid response, got this:")
> +        LOG.debug(util.hexprint(response))
> +        if len(response) == 12:
> +            ident = response[0] + response[3] + response[5] + response[7:]
> +        else:
> +            ident = response
> +    else:
>          # bad response
>          msg = "Unexpected response, got this:"
> -        msg += util.hexprint(ident)
> +        msg += util.hexprint(response)
>          LOG.debug(msg)
>          raise errors.RadioError("Unexpected response from radio.")
>
> -    # DEBUG
> -    LOG.info("Valid response, got this:")
> -    LOG.debug(util.hexprint(ident))
> -
>      serial.write("\x06")
>      ack = serial.read(1)
>      if ack != "\x06":



More information about the chirp_devel mailing list