OK, I did in fact make my driver work on both py3 and the (py2) main branch. I built my image into a bytearray, then converted to bytes, use MemoryMap: bytearraymmap = bytearray(radio._imagesize) readimageinto bytearray(bytearraymmap) self._mmap= memmap.MemoryMap(bytes(bytearraymmap))
This code works in both places. The py3 version will eventually need to be cleaned up to use the MemoryMapBytes, simply to avoid the array copy, but that's minor. We could add a stub version of MemoryMapBytes to py2 to simplify the transition.
On Sun, Feb 17, 2019 at 3:04 PM Dan Smith via chirp_devel < chirp_devel@intrepid.danplanet.com> wrote:
I'm trying to write a driver that works with both Python 2 and Python 3.
It works and passes all tests, but it cannot create a memory savable memory map when it downloads from the radio.
I can choose MemoryMapBytes, which works in Py3, or MemoryMap, which is
implemented in both but which results in a mmap that cannot be written to a file. I'm now officially lost, which is my usual state. Any suggestions?
I'm not sure what you mean, so showing code would be a lot more helpful. I've converted a bunch of radios in the py3 branch that work on py2 and py3 at the same time, so you can look for examples there. Most have a first commit that just makes them work with MemoryMap (i.e. compat mode) first, followed by one that makes them byte-clean using MemoryMapBytes. Note that you won't be able to make a driver that works on both on the main branch of course.
--Dan
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers