-
Notifications
You must be signed in to change notification settings - Fork 35
cn-cbor not portable for MCU that doesn't support alignment #29
Comments
I've made several tests with a cortex M0, and this lib seems not compatible with these kind of CPU. So for now, forget about my previous comment. There's other things to do to be compatible with Cortex MCU.. I'll see if I can do something about that. |
Yes, the ntohxxp functions assume that you can do unaligned reads. |
Hello, Thank you for this branch. I'll try your branch once I'd find time and let you know if it works. |
BTW, just for the historical record:
Contiki (where this code was used before) defines its own ntohl. |
Indeed, M3 supports address alignment, which is not the case of M0. |
Ok, I've found time to test, and it works like a charm. Do you plan to merge these change in master ? |
I would use cn-cbor on a ARM Cortex-M0, and I'm facing a problem with some dependencies.
Here https://github.com/cabo/cn-cbor/blob/master/src/cn-cbor.c#L16 and here https://github.com/cabo/cn-cbor/blob/master/src/cn-encoder.c#L11, arpa/inet.h is included to use ntohl. Problem is that I don't want to include arpa/inet.h, which would be a waste of flash space.
I want then propose a modification : https://gist.github.com/ks156/9b8d1a1d97ec1b38f91e
I can send a pull request if you want, but before, this code must be reviewed. I only started to work with cn-cbor few days ago and I don't have enough experience to know if these changes can have unexpected side effects. Basically, there's no change as long as CBOR_COMPAT is not defined. But if someone can confirm, it would be nice.
BR,
Paul
The text was updated successfully, but these errors were encountered: