Page 1 of 1

uzlib error

Posted: Fri Jun 15, 2018 4:26 pm
by kwiley
I'm compressing data on a desktop with zlib before sending it over serial comms to a PyBoard via USB_VCP. The PyBoard then decompresses packets of data before processing them. I have confirmed that any overhead of compression or decompression is, in fact, compensated by the reduced transmission size, at least in the case of my particular application. In a few rare cases, I am finding that on a particular set of data, uzlib fails to decompress a zlib compressed set of data, throwing a ValueError (of -4 if that means anything). For completeness, I tested decompressing the same buffer on the desktop immediately after compressing it but before transmitting it, and of course, zlib on the desktop has no trouble decompressing its own compressed data. So it would appear that uzlib is not a perfect implementation of zlib.

Are there any known problems with uzlib? Is this result not necessarily surprising?

Re: uzlib error

Posted: Fri Jun 15, 2018 9:21 pm
by dhylands
How are you opening the serial port to the pyboard? Under linux, make sure that you put the serial port in raw mode or some of the characters will get transformed.

Re: uzlib error

Posted: Fri Jun 15, 2018 10:11 pm
by Damien
If you can find a particular bit of data that doesn't decompress on pyboard it would be worth saving it to a file on the desktop PC to run further tests on it. You could first try decompressing it with the Unix version of micropython, and then try copying it as a file to the pyboard and decompressing it from the file.

Re: uzlib error

Posted: Mon Jun 18, 2018 3:52 pm
by kwiley
Well, I'm working on a Mac, using PySerial from Jupyter. I'll look into the possibility of character transformation some.