uzlib error

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
kwiley
Posts: 102
Joined: Wed May 16, 2018 5:53 pm
Contact:

uzlib error

Post by kwiley » Fri Jun 15, 2018 4:26 pm

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?

User avatar
dhylands
Posts: 3464
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: uzlib error

Post by dhylands » Fri Jun 15, 2018 9:21 pm

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.

Damien
Site Admin
Posts: 635
Joined: Mon Dec 09, 2013 5:02 pm

Re: uzlib error

Post by Damien » Fri Jun 15, 2018 10:11 pm

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.

kwiley
Posts: 102
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: uzlib error

Post by kwiley » Mon Jun 18, 2018 3:52 pm

Well, I'm working on a Mac, using PySerial from Jupyter. I'll look into the possibility of character transformation some.

Post Reply