<div dir="ltr"><div dir="ltr"><div>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,</div><div>use MemoryMap:</div><div> bytearraymmap = bytearray(radio._imagesize)<br></div><div> readimageinto bytearray(bytearraymmap)</div><div> self._mmap= memmap.MemoryMap(bytes(bytearraymmap))</div><div><br></div><div>This code works in both places. The py3 version will eventually need to be cleaned up to use the <span class="gmail-im">MemoryMapBytes, simply to avoid the</span></div><div><span class="gmail-im">array copy, but that's minor. We could add a stub version of <span class="gmail-im">MemoryMapBytes to py2 to simplify the transition.<br></span></span></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 17, 2019 at 3:04 PM Dan Smith via chirp_devel <<a href="mailto:chirp_devel@intrepid.danplanet.com">chirp_devel@intrepid.danplanet.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> 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.<br>
> 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?<br>
<br>
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.<br>
<br>
--Dan<br>
<br>
_______________________________________________<br>
chirp_devel mailing list<br>
<a href="mailto:chirp_devel@intrepid.danplanet.com" target="_blank">chirp_devel@intrepid.danplanet.com</a><br>
<a href="http://intrepid.danplanet.com/mailman/listinfo/chirp_devel" rel="noreferrer" target="_blank">http://intrepid.danplanet.com/mailman/listinfo/chirp_devel</a><br>
Developer docs: <a href="http://chirp.danplanet.com/projects/chirp/wiki/Developers" rel="noreferrer" target="_blank">http://chirp.danplanet.com/projects/chirp/wiki/Developers</a><br>
</blockquote></div>