Note that there are some explanatory texts on larger screens.

plurals
  1. POProtocol specification in XML
    primarykey
    data
    text
    <p>Is there a way to specify a packet-based protocol in XML, so (de)serialization can happen automatically?</p> <p>The context is as follows. I have a device that communicates through a serial port. It sends and receives a byte stream consisting of 'packets'. A packet is a collection of elementary data types and (sometimes) other packets. Some elements of packets are conditional; their inclusion depends on earlier elements.</p> <p>I have a C# application that communicates with this device. Naturally, I don't want to work on a byte-level throughout my application; I want to separate the protocol from my application code. Therefore I need to translate the byte stream to structures (classes).</p> <p>Currently I have implemented the protocol in C# by defining a class for each packet. These classes define the order and type of elements for each packet. Making class members conditional is difficult, so protocol information ends up in functions.</p> <p>I imagine XML that looks like this (note that my experience designing XML is limited):</p> <pre><code>&lt;packet&gt; &lt;field name="Author" type="int32" /&gt; &lt;field name="Nickname" type="bytes" size="4"&gt; &lt;condition type="range"&gt; &lt;field&gt;Author&lt;/field&gt; &lt;min&gt;3&lt;/min&gt; &lt;max&gt;6&lt;/min&gt; &lt;/condition&gt; &lt;/field&gt; &lt;/packet&gt; </code></pre> <p>.NET has something called a 'binary serializer', but I don't think that's what I'm looking for.</p> <p>Is there a way to separate protocol and code, even if packets 'include' other packets and have conditional elements?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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