[chirp_devel] MemoryMapBytes
Dan- 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)
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
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@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
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?
In python3 it requires bytes, yes.
--Dan
participants (2)
-
Dan Smith
-
Rick DeWitt AA0RD