diff --git a/doc/tech_report.tex b/doc/tech_report.tex index 1615c464681112524ff8a5d443e96b39336a5c32..bb97773e075c356449a1bf874eaf8aa348246703 100644 --- a/doc/tech_report.tex +++ b/doc/tech_report.tex @@ -577,44 +577,50 @@ The built-in data types are encoded as follows: \subsection{Protocol grammar} \label{sec:ConcreteGrammar} \begin{lstlisting}[basicstyle=\footnotesize\ttfamily] -<packet> := <id> <length> ( <version> | - <type_decl> | - <sample_decl> | - <type_binding> | - <sample_data> ) -<version> := <string> -<sample_decl> := <sample_id> <string> <type> -<type_decl> := <type_id> <string> <type> -<type_binding> := <sample_id> <type_id> -<user_id> := 0x40..0xffffffff +<packet> := <id> <length> ( <version> | + <type_decl> | + <sample_decl> | + <sample_ref> | + <type_binding> | + <sample_data> ) +<version> := <string> +<sample_decl> := <sample_id> <string> <type> +<sample_ref> := <sample_id> <string> <type> +<type_decl> := <type_id> <string> <type> +<type_binding> := <sample_id> <type_id> +<user_id> := 0x40..0xffffffff <sample_id> : <user_id> <type_id> : <user_id> -<string> := <string_length> <char>* -<string_length>:= 0x00..0xffffffff -<char> := any UTF-8 char -<type> := <length> ( <basic_type> | <array_decl> | <struct_decl> | <type_id> ) -<basic_type> := ( <void_type> | <boolean_type> | <byte_type> | <short_type> | - <integer_type> | <long_type> | <float_type> | - <double_type> | <string_type> | <sample_ref>) -<void_type> := <struct_decl> 0 //void is encoded as empty struct -<boolean_type> := 0x20 -<byte_type> := 0x21 -<short_type> := 0x22 -<integer_type> := 0x23 -<long_type> := 0x24 -<float_type> := 0x25 -<double_type> := 0x26 -<string_type> := 0x27 -<sample_ref> := 0x28 -<array_decl> := 0x10 <number_of_indices> <indices> <type> -<number_of_indices> := 0x00..0xffffffff -<indices> := ( <variable_index> | <fixed_index> )* -<variable_index> := 0x00 -<fixed_index> := 0x01..0xffffffff -<struct_decl> := 0x11 <number_of_fields> <field>* -<number_of_fields> := 0x00..0xffffffff -<field> := <string> <type> -<sample_data> := packed sample data sent in network order, with +<string> := <string_length> <char>* +<string_length> := 0x00..0xffffffff +<char> := any UTF-8 char +<type> := <length> ( <basic_type> | + <array_decl> | + <struct_decl> | + <type_id> ) +<basic_type> := ( <void_type> | <boolean_type> | <byte_type> | <short_type> | + <integer_type> | <long_type> | <float_type> | + <double_type> | <string_type> | <sample_ref_type>) + +<void_type> := <struct_decl> 0 //void is encoded as empty struct +<boolean_type> := 0x20 +<byte_type> := 0x21 +<short_type> := 0x22 +<integer_type> := 0x23 +<long_type> := 0x24 +<float_type> := 0x25 +<double_type> := 0x26 +<string_type> := 0x27 +<sample_ref_type> := 0x28 +<array_decl> := 0x10 <nbr_of_indices> <indices> <type> +<nbr_of_indices> := 0x00..0xffffffff +<indices> := ( <variable_index> | <fixed_index> )* +<variable_index> := 0x00 +<fixed_index> := 0x01..0xffffffff +<struct_decl> := 0x11 <nbr_of_fields> <field>* +<nbr_of_fields> := 0x00..0xffffffff +<field> := <string> <type> +<sample_data> := packed sample data sent in network order, with primitive type elements encoded according to the sizes above \end{lstlisting} @@ -624,8 +630,9 @@ The labcomm sytem packet ids are: \begin{lstlisting}[basicstyle=\footnotesize\ttfamily] version: 0x01 sample_decl: 0x02 -type_decl: 0x03 -type_binding: 0x04 +sample_ref: 0x03 +type_decl: 0x04 +type_binding: 0x05 \end{lstlisting} Note that since the signature transmitted in a \verb+<sample_def>+ is flattened, the \verb+<type>+ transmitted in a \verb+<sample_def>+ may diff --git a/lib/python/labcomm/LabComm.py b/lib/python/labcomm/LabComm.py index c4b353c63d7c73994249ab4ab6221276f3a4d121..57172143d4c1716069edae6b971e87881a430ee9 100644 --- a/lib/python/labcomm/LabComm.py +++ b/lib/python/labcomm/LabComm.py @@ -29,11 +29,29 @@ # | ... # +----+-- # +# LabComm2014 SAMPLE_REF: +# +# +----+----+----+----+ +# | id = 0x03 (packed32) +# +----+----+----+----+ +# | length (packed32) +# +----+----+----+----+ +# | type number (packed32) +# +----+----+----+----+ +# | type name (UTF8) +# | ... +# +----+----+----+----+ +# | signature length (packed32) +# +----+----+----+----+ +# | type signature +# | ... +# +----+-- +# # LabComm2014 TYPE_DEF: (as SAMPLE_DEF, but signatures are hierarchical, # i.e., may contain references to other types # # +----+----+----+----+ -# | id = 0x03 (packed32) +# | id = 0x04 (packed32) # +----+----+----+----+ # | length (packed32) # +----+----+----+----+ @@ -51,7 +69,7 @@ # LabComm2014 TYPE_BINDING # # +----+----+----+----+ -# | id = 0x04 (packed32) +# | id = 0x05 (packed32) # +----+----+----+----+ # | length (packed32) # +----+----+----+----+