[chirp_devel] MemoryMapBytes

Dan Smith
Mon Jan 6 11:19:28 PST 2020


> 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


More information about the chirp_devel mailing list