Comments (6)
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.
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.
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.
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.
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.
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)
- Coverage for float code
- Ready for release?
- travis
- coveralls
- Add diagnostic format serializer
- Wrong use of index variable after increment in cbor_test.c
- Failing to build tests when CMAKE_BUILD_TYPE MinSizeRel on Linux
- Parser does not respect tag 24 - It does not defer the decoding of data with this tag HOT 2
- Need a serializer option to get size of buffer needed HOT 2
- ssize_t is from POSIX and not from the C standard HOT 1
- const behavior makes life difficult HOT 3
- Make it build for windows HOT 2
- Strings not null-terminated after decode HOT 2
- cn_cbor_free is either overactive or needs to be even more overactive HOT 6
- Suggest renaming cn_cbor_index to cn_cbor_array_index HOT 2
- Define a field in struct cn_cbor.v that is of type uint8_t * HOT 1
- Consider indicating the size of floats in the API in the cb->length field
- Fuzz testing HOT 1
- is this project still maintained? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cn-cbor.