[chirp_devel] The End of Days - #495

Dan Smith
Sun Feb 10 10:42:59 PST 2019


> I've fixed the drivers to work on both Python 2 and 3, with all tests
> passing. Attached is the patch.

Sweet, thanks

> diff -r 6147365892e1 -r 6f5c2af0b6f1 chirp/drivers/uvb5.py
> --- a/chirp/drivers/uvb5.py     Fri Feb 08 21:49:27 2019 -0800
> +++ b/chirp/drivers/uvb5.py     Fri Feb 08 22:42:54 2019 -0800

<snip>

> -    data = radio._mmap[0x0030:]
> +    data = radio._mmap.get_byte_compatible()[0x0030:]


Not that it matters, but this shouldn't be strictly necessary since you're using MemoryMapBytes right?

> diff -r 6f5c2af0b6f1 -r d1470be72a27 chirp/drivers/th350.py
> --- a/chirp/drivers/th350.py    Fri Feb 08 22:42:54 2019 -0800
> +++ b/chirp/drivers/th350.py    Sat Feb 09 17:49:11 2019 -0800

<snip>

>  def do_download(radio):
>      do_ident(radio)
> -    data = "TH350 Radio Program data v1.08\x00\x00"
> -    data += ("\x00" * 16)
> +    data = b"TRI350 Radio Program data v1.08\x00"
> +    data += (b"\x00" * 16)


Why did you change this and the match_model stuff? In the past, we definitely couldn't do something like this because it would make images created by newer chirp incompatible with older chirp for no real reason. Since your driver only existed after the metadata change, this doesn't really affect you, but I don't really want to get into the habit of doing this without good reason.

> To ensure that the behavior of get_raw(asbytes=True) is consistent
> across Python 2 and 3, I've pulled in python-future which provides a
> mostly-complete implementation of bytes for Python 2. This way we can
> guarantee that bytes or bytes-compatible objects are returned when
> new-style drivers ask for them.

This is cool, I spent some time making sure this is installable and functional in the win32 py2 environment and it appears to be, so this should help a lot.

> Another thing that I missed is importing __futures__.division for
> Python 2, again to ensure consistent behavior in 2/3.

I was going to take exception to this, but TIL that the __futures__ imports like that only affect the module in which they were imported, so this too is a good thing.

I pushed all but the th350 patch, just looking for information on the format change.

Thanks!

--Dan


More information about the chirp_devel mailing list