Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you won't find an easy-to-use serializer that will match the custom protocol you are looking at. But it look the set of primitives you have (int, bool + size ) are simple enough to be able to write your own decoder/encoder. Simply generating C/C++ code based on the message received. It should be fairly simple task to generate a compilable code taking such description. It should be an automated generation done at the compile time - similar to what protobuf/Corba are doing. </p> <p>Example: from the specification: </p> <pre><code>class Message{ int msg_num : 7 int dest_addr : 4 bool SRR : 1 bool IDE : 1 int source_addr : 6 //... and so on... } </code></pre> <p>the converter could write a function with body similar to (abstract notation and assuming MSB):</p> <p>Decoder:</p> <pre><code>m = new Message() { long long val = 0 for(int i=0; i&lt;7; i++) { val &lt;&lt;= 8 val += nextByte() } m.msg_num = val } { long long val = 0 for(int i=0; i&lt;4; i++) { val &lt;&lt;= 8 val += nextByte() } m.dest_addr = val } { int val = nextByte() m.SRR = val } { int val = nextByte() m.IDE = val } { long long val = 0 for(int i=0; i&lt;6; i++) { val &lt;&lt;= 8 val += nextByte() } m.source_addr = val } // and so on </code></pre> <p>Encoder:</p> <pre><code>{ long long val = m.msg_num for(int i=0;i&lt;7;i++) { writeByte(val &amp; 0xFF) val &gt;&gt;= 8 } } { long long val = m.dest_addr for(int i=0;i&lt;4;i++) { writeByte(val &amp; 0xFF) val &gt;&gt;= 8 } } .... </code></pre> <p>That should be pretty easy to generate and the simplest way to make sure the encoding is custom.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload