4 ms·
In re #4: > 4. JSON is a non-starter long-term: it sucks for small devices. They need a binary format that is easy to parse. ASN.1? https://en.wikipedia.org/
by carapace 9y ago
In re #4:
> 4. JSON is a non-starter long-term: it sucks for small devices. They need a binary format that is easy to parse.
ASN.1?
https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One
> ASN.1 is similar in purpose and use to protocol buffers and Apache Thrift, which are also interface description languages for cross-platform data serialization. Like those languages, it has a schema (in ASN.1, called a "module"), and a set of encodings, typically type-length-value encodings. However, ASN.1, defined in 1984, predates them by many years. It also includes a wider variety of basic data types, some of which are obsolete, and has more options for extensibility. A single ASN.1 message can include data from multiple modules defined in multiple standards, even standards defined years apart.
- mkj 9y agocbor looks better for small devices?
- wiremine 9y agoThis would be the first place I'd look if I were the Mozilla guys.
- bugmen0t 9y agowhy not cap'n'proto?
- _pmf_ 9y agoCap'n Proto's Time Traveling RPC[0] would indeed be a perfect match for the IoT. [0] https://capnproto.org/news/2013-12-12-capnproto-0.4-time-travel.html https://capnproto.org/news/2013-12-12-capnproto-0.4-time-tra...
- elcritch 9y agoIn theory it’s nice, but the core cap’n’proto library is too large for many embedded devices. It seems to be full of dynamic features making it difficult to pair down.
- kentonv 9y agoHave you tried using link-time garbage collection? The library is designed in a layered way, such that the core serialization does not depend on the "dynamic" features, so if you don't ever call "dynamic" features then link-time GC should be able to drop a huge chunk of the lib. There's also "lite mode", which #ifdef's out all the dynamic stuff: ./configure --disable-reflection Although it isn't as aggressive as it could be. We should fix that. I filed an issue: https://github.com/capnproto/capnproto/issues/634 https://github.com/capnproto/capnproto/issues/634 There is also a C implementation of capnp which I believe is designed for small footprint, FWIW.
- elcritch 9y agoNo I didn’t but that’s good to know. I tried a few attempts but wasn’t sure about how integral the reflection portions were (or if exceptions were crucial). I’d likely just compiled the library on my dev machine and looked at the library size and tried a few flags to get a quick idea if it’d work. It’d be useful to be able to just use the serialization protocol. Currently I’m using MsgPack which works decently well to get data from embedded cores but I’d prefer typed structures. Thanks for the feedback!
- kentonv 9y ago> or if exceptions were crucial Although KJ style prefers exceptions, the library is carefully written (and tested) to work with -fno-exceptions. KJ_ASSERT/KJ_REQUIRE invocations (which normally throw exceptions) can define a fallback path to use in the case that exceptions are disabled, usually involving returning some sort of dummy value. You can also register a per-thread exception callback which will be called on all exceptions before the fallback starts (or before aborting, if there is no fallback).
- elcritch 9y agoThat’s excellent! That certainly makes it seem much more useful for many embedded environments.
- hsivonen 9y agoCBOR doesn't have well-defined error handling.
- jnwatson 9y agoAsn.1 is great, and I see a lot of folks relearning the hard-earned lessons of it. The only problem is that there are no good open source implementations.
- kevin_thibedeau 9y agoAll of the open source TLS libs have to support enough of ASN.1 to process certificates.
- ofek 9y agohttps://github.com/wbond/asn1crypto https://github.com/wbond/asn1crypto
- carapace 9y agoASN1SCC? from https://essr.esa.int/project/asn1scc-asn-1-space-certifiable-compiler https://essr.esa.int/project/asn1scc-asn-1-space-certifiable... : > ASN1SCC is an ASN.1 compiler that was developed for ESA to cover all data modelling needs of space applications. > The compiler is targeting safe systems and generate either Spark/Ada or C code. Runtime library is minimalistic and open-source. The tool handles custom binary encoding layouts, is fully customizable through a code templating engine, generates ICDs and automatic test cases. https://github.com/ttsiodras/asn1scc https://github.com/ttsiodras/asn1scc > This repository contains the complete source code and tests of the ASN1SCC compiler ; an ASN.1 compiler that targets C and Ada, while placing specific emphasis on embedded systems: no black-box run-time library, portable code able to run under any OS (embedded or otherwise), no dynamic memory used anywhere, etc. See also blog post about it: https://ttsiodras.github.io/asn1.html https://ttsiodras.github.io/asn1.html
- keeperofdakeys 9y agoASN.1 has one of the same problems of XML - the data format is far too strict. Many libraries work by generating new structs/classes from the specification, which is a real problem for an agile workflow. The "struct" type also allows keys of the same name, which means you can't properly represent it in a Json/hashmap/dictionary type. (Not to mention that ASN.1 is just the specification language, there are more then ten ways to actually encode it on the wire. And from personal experience it can also be a pain to work with.) There are plenty of more modern binary formats that would be a good alternative. CBOR, MessagePack, Protobufs, etc.