Just spent hours tracking down the "DOCSIS TLV" config-file format and implementing it. This is one of those things where the project spec says "do what that spec says to do", pointing you at a deprecated version of the big spec, then the updated version of that spec says "do what this other spec says to do", but that spec is then defined in terms of 2 other specs... an enormous amount of reading to specify something that can be described in a tiny amount of code.
The key thing that gets left out AFAICS is that the spec is recursive; so for option 43.1, 43.2, or 43.3.4.5.2.3.4.5.6, for example, you do all of the encoding steps as though you were doing a top-level encoding for the various named (numbered) sub-options at each level, then you break the resulting (potentially very long) value into 255-byte chunks of top-level encodings. For instance, our last example there with a value of 'hello' looks like:
[43,21,3,19,4,17,5,15,2,13,3,11,4,9,5,7,6,5,104,101,108,108,111]
Once you actually get all that, it's one of those relatively simple specs that likely should just be wrapped up in a standard library... but that would be hundreds of times more work than putting together something that can do what you need for this tiny project.
There are likely stupid little corner cases, such as whether to do splitting of long option-values only at the top-level, or whether you are intended to also split them in the recursive elements if an individual sub-element is > 255 chars. There's also some checksums and the like, basically just some sha1 hashes.
The fact that you need lookup tables for all non-trivial interpretation makes the whole thing look way too messy to bother with beyond the needs of your clients of the day. In the example above, unless you know that 43.3 has internal structure you can't parse the result meaningfully. It might just as easily be a single long string. The T (type) in TLV is just a single-byte-integer reference into the current table space, not a direct data-type value. Those tables are vendor, and potentially even project, specific, so you then need to create a mechanism for users to define the tables... ick. Makes one appreciate context-free formats all the more.
Comments
2010-02-04 09:16
A somewhat heavy-handed approa ch (requires a Posix'y system) : Let the server processes be handled bySupervisor [...]
2010-02-04 08:50
I often have the same problem. I've resorted to subproces s, as well, with the tearDown( ) calling a platform-spe [...]
2010-02-03 22:42
I haven't had to write a test like this in quite a while, so this isn't how I do it, but ... If you run a chil [...]
2010-01-31 18:17
I feel your pain. I'm banging my head against the GSM 09.02 spec at the moment.
2010-01-27 16:17
What kind of spam is that ^^ I like socat for this stuff (also my netfilter-fu is weak) . socat TCP-LISTE [...]
2010-01-27 13:28
In case you weren't aware - St artCom (www.startssl.com) is a great place to get free, trus ted certificates.
2010-01-25 16:56
I based the rewriting on the t wisted.web rewriting-rule code : http://twistedmatrix.com/tra c/browser/tags/releases/ [...]
2010-01-25 16:32
Did you independently think up this way of doing things, or were you inspired by other cod e you found on the inter [...]
2010-01-24 18:27
It did help. Though I'm still tempted to use raw SQL. Thanks , serendipity!
2010-01-22 17:43
Hmm, hard to tell if this is a spam post or not (the use of the search terms for the name makes me suspect it is, [...]
2010-01-22 15:39
Wow, thank you for so informat ive post. I am just a beginner in programming and now tried to run a similar type of [...]
2010-01-22 12:21
PyOpenGL sprint would be tempt ing. I'll only be there for th e first day of sprinting. I've just been waiting for a [...]
2010-01-21 12:46
I love this post. LOVE. IT .
2010-01-16 22:10
Oh, I know about the start/end key support for pagination, bu t it's like saying that with o ffset and limit SQL has [...]
2010-01-16 17:41
CouchDB already has support fo r pagination using the start_k ey and count get data. What li brary are you using?