Build msgpack for micropython
Build msgpack for micropython
Hello.
I'm a newbie in python and especially micropython worlds, so I need some help Could somebody give me a clue how I could build msgpack (https://github.com/msgpack/msgpack-python). Maybe somebody had done it already. Or maybe there is an instruction (not about this library but general one)?
I know, there is a pure-python library, but I want to try binary one.
I'm a newbie in python and especially micropython worlds, so I need some help Could somebody give me a clue how I could build msgpack (https://github.com/msgpack/msgpack-python). Maybe somebody had done it already. Or maybe there is an instruction (not about this library but general one)?
I know, there is a pure-python library, but I want to try binary one.
Re: Build msgpack for micropython
Unfortunately this is not a simple process as the way CPython bindings work is very different to MicroPython bindings.bokolob wrote: ↑Wed Mar 10, 2021 4:59 pmI'm a newbie in python and especially micropython worlds, so I need some help Could somebody give me a clue how I could build msgpack (https://github.com/msgpack/msgpack-python). Maybe somebody had done it already. Or maybe there is an instruction (not about this library but general one)?
The starting point for extending MicroPython in C would be http://docs.micropython.org/en/latest/d ... dules.html
Re: Build msgpack for micropython
Thanks.
Is there some examples of iterating through an object content in C ? How to walk trough all the fields recursively ?
Is there some examples of iterating through an object content in C ? How to walk trough all the fields recursively ?
Re: Build msgpack for micropython
I wish I could just say "look at how the JSON serialiser works" -- https://github.com/micropython/micropyt ... modujson.c
Unfortunately, it's a bit complicated because the JSON serialiser is part of the core... you'll see the key line in modujson.c is:
Code: Select all
mp_obj_print_helper(&print, obj, PRINT_JSON);
However, in general the way to walk an object is via iterable:
Code: Select all
mp_obj_t iter = mp_getiter(iterable, NULL);
mp_obj_t item;
while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
// do something with item
}
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Build msgpack for micropython
I appreciate this doesn't answer your question, but this doc describes the four serialisation protocols which do work with MicroPython. Alas msgpack is not one of them.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Build msgpack for micropython
I need some serialiser that is efficient for the cpu (to consume less battery) and the result "size" (to consume less network). About that four serializers - json is fast, but its result is longer, other libraries are pure python, and I suppose that they are quite slow..
Re: Build msgpack for micropython
Isn't it a good ide to add other serialisers into core? At the same level as json is? They can be disabled with preprocessor directives.
Msgpack has C-library that could be used.
Msgpack has C-library that could be used.
Re: Build msgpack for micropython
See https://github.com/micropython/micropython/issues/4241
In short: the fallback implementation of msgpack is pure Python and almost works out of the box
There are just too many of them to choose. Also see e.g. https://github.com/micropython/micropython/issues/5597
In short: the fallback implementation of msgpack is pure Python and almost works out of the box
Code: Select all
Isn't it a good ide to add other serialisers into core?
Re: Build msgpack for micropython
I know about that library, but I suppose it would be too slow and inefficient for IO-heavy applications (on microcontroller). And in my case every uA of battery is crucial.