camgunz / cmp

An implementation of the MessagePack serialization format in C / msgpack.org[C]
http://msgpack.org
MIT License
340 stars 78 forks source link

python3 encoding string produces type 0xb0 #46

Closed glenn-edgar closed 6 years ago

glenn-edgar commented 6 years ago

See Example Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import msgpack print(msgpack.packb("/SPIFFS/WIFI.MPK")) b'\xb0/SPIFFS/WIFI.MPK'

Question 1: Donot know the format for the 0xb0 command.

Question 2: How can the type be incorporated into cmp.c

I am using your libraray on an ESP32 to communication to a linux server.
Thanks for your good work.

camgunz commented 6 years ago

Hi!

0xb0 is the fixstr type, which is a range type starting at 0xa0. In order to compute the length of the ensuing string, you just take the value (0xb0 in this case) and subtract 0xa0 -- which would give you 16. It's a little more complicated than "one value -> one type", but it's very efficient as most values are pretty small.

Let me know if I can explain it better. Is there a problem with CMP decoding data from Python's msgpack library?

glenn-edgar commented 6 years ago

python3 for certain utf-8 strings produces the 0xb0 encoding. cmp.c appears not to recognize this object type.

I was checking whether you were aware of this problem.

Thanks

Glenn Edgar

On Thu, Sep 13, 2018 at 7:08 AM Charlie Gunyon notifications@github.com wrote:

Hi!

0xb0 is the fixstr type, which is a range type starting at 0xa0. In order to compute the length of the ensuing string, you just take the value (0xb0 in this case) and subtract 0xa0 -- which would give you 16. It's a little more complicated than "one value -> one type", but it's very efficient as most values are pretty small.

Let me know if I can explain it better. Is there a problem with CMP decoding data from Python's msgpack library?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/camgunz/cmp/issues/46#issuecomment-421020030, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMefNtkbsCzCmqWqtTgNDPVS0Lv-b12ks5uambKgaJpZM4WmEfy .

glenn-edgar commented 6 years ago

Sorry about raising the issue. Your explanation helped me and I saw how the 0xb0 type was handled in your code.

Went back and ran test code and the 0xb0 string was properly handled. No issue with you code.

Thanks for your good work

On Thu, Sep 13, 2018 at 7:08 AM Charlie Gunyon notifications@github.com wrote:

Hi!

0xb0 is the fixstr type, which is a range type starting at 0xa0. In order to compute the length of the ensuing string, you just take the value (0xb0 in this case) and subtract 0xa0 -- which would give you 16. It's a little more complicated than "one value -> one type", but it's very efficient as most values are pretty small.

Let me know if I can explain it better. Is there a problem with CMP decoding data from Python's msgpack library?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/camgunz/cmp/issues/46#issuecomment-421020030, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMefNtkbsCzCmqWqtTgNDPVS0Lv-b12ks5uambKgaJpZM4WmEfy .

camgunz commented 6 years ago

No problem, it's pretty confusing. Thanks for being a proactive user though, let me know if you have other questions!