Giter VIP home page Giter VIP logo

Comments (6)

ks156 avatar ks156 commented on July 17, 2024

I've made several tests with a cortex M0, and this lib seems not compatible with these kind of CPU.
I'm experiencing tons of problems, especially with this part : https://github.com/cabo/cn-cbor/blob/master/src/cn-cbor.c#L138-L140

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.

from cn-cbor.

cabo avatar cabo commented on July 17, 2024

Yes, the ntohxxp functions assume that you can do unaligned reads.
I have pushed a workaround in branch "unaligned".
(TODO: This clearly can be done better, and there needs to be a proper way to set CBOR_CAN_DO_UNALIGNED_READS.)

from cn-cbor.

ks156 avatar ks156 commented on July 17, 2024

Hello,

Thank you for this branch. I'll try your branch once I'd find time and let you know if it works.

from cn-cbor.

cabo avatar cabo commented on July 17, 2024

BTW, just for the historical record:
Just including <arpa/inet.h> is not expensive (at least not on my machine):

alma:tmp cabo$ cat ai1.c
#include <arpa/inet.h>

int f() {return 1;}
alma:tmp cabo$ size ai1.o
__TEXT  __DATA  __OBJC  others  dec hex
75  0   0   32  107 6b
alma:tmp cabo$ cat ai2.c
int f() {return 1;}
alma:tmp cabo$ size ai2.o
__TEXT  __DATA  __OBJC  others  dec hex
75  0   0   32  107 6b
alma:tmp cabo$ 

Contiki (where this code was used before) defines its own ntohl.
But we did use a Cortex-M3 for those tests, IIRC, so we didn't encounter the unaligned access problem.

from cn-cbor.

ks156 avatar ks156 commented on July 17, 2024

Indeed, M3 supports address alignment, which is not the case of M0.
If what you've done works as expected, I suggest to fix this code, which will increase the portability of this lib.

from cn-cbor.

ks156 avatar ks156 commented on July 17, 2024

Ok, I've found time to test, and it works like a charm.
There's also an include of arpa/inet.h in cn-encoder.c, line 11 (https://github.com/cabo/cn-cbor/blob/unaligned/src/cn-encoder.c#L11) that should also be surrounded by #ifdef CBOR_CAN_DO_UNALIGNED_READS

Do you plan to merge these change in master ?

from cn-cbor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.