[chirp_devel] Py3 bytes() compliance question
Rick DeWitt AA0RD
Wed Jan 8 10:44:26 PST 2020
OK, I finally realized that the future library is a Python add-on, not
CHIRP. Got that installed and the USB data > bytes processing is working.
Will the radio.pipe.write data eventually need to be passed as py3
bytes(), or will it still work with strings?
On 1/6/2020 11:19 AM, Dan Smith via chirp_devel wrote:
>> The new py3 MemoryMapBytes method has a problem.
>> Firstly, the py2.7 bytes() call is just an alias for string(), so it
>> does not generate a byte array.
>> I had to convert the data string to an integer list in order for
>> MemoryMapBytes to accept it. Otherwise it generates an error.
>>
>> in sync_in-- this works
>> bdata = []
>> for bx in data: # memory hog
>> bdata.append(ord(bx))
>> self._mmap = memmap.MemoryMapBytes(bdata) # For py3
>> self.process_mmap()
>>
>> This does not work; generates "integer required" error -
>> bdata = bytes(data)
>> self._mmap = memmap.MemoryMapBytes(bdata)
>>
>> Likewise if I convert the USB string data reads to bytes() in the
>> download function; still bombs -
>> bdata = bytes()
>> bdata.append = bytes(xxx)
>> ...
>> self._mmap = memmap.MemoryMapBytes(bdata)
> You should look at some of the drivers that have been converted, such as tk8180. You need to import the bytes handler from the future library, which handles the py2/py3 compatibility:
>
> from builtins import bytes
>
> --Dan
> _______________________________________________
> chirp_devel mailing list
> chirp_devel at intrepid.danplanet.com
> http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
> Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
--
Rick DeWitt
AA0RD
Sequim, Washington, USA 98382
(360) 681-3494
More information about the chirp_devel
mailing list