Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tommy Olofsson
LabComm
Commits
df8c6467
Commit
df8c6467
authored
Jan 19, 2015
by
Sven Gestegård Robertz
Browse files
Merge branch 'master' of git.cs.lth.se:robotlab/labcomm-core
parents
1fed9bf1
bcfd7192
Changes
1
Show whitespace changes
Inline
Side-by-side
doc/tech_report.tex
View file @
df8c6467
...
...
@@ -289,6 +289,7 @@ With the following `example.lc` file:
and this
\verb
+
example_encoder.c
+
file
\lstinputlisting
[basicstyle=\footnotesize,language=C]
{
../examples/wiki
_
example/example
_
encoder.c
}
\newpage
Running
\verb
+
./example_encoder one two
+
, will yield the following result in example.encoded:
\begin{verbatim}
...
...
@@ -306,7 +307,9 @@ Running \verb+./example_encoder one two+, will yield the following result in exa
i.e.,
\begin{verbatim}
<version> <length: 12> <string: <len: 11> <"LabComm2014">>
<sample
_
decl> <length: 48 <user
_
id: 0x40> <string: <len: 11> <"log
_
message">
<sample
_
decl> <length: 48
<user
_
id: 0x40>
<string: <len: 11> <"log
_
message">
<signature
_
length: 34>
<struct
_
decl:
<number
_
of
_
fields: 2>
...
...
@@ -379,37 +382,25 @@ VariableSize : Exp;
\section
{
The LabComm protocol
}
\label
{
sec:ProtocolGrammar
}
Each LabComm2014 packet has the layout
\begin{verbatim}
<id> <length> <data...>
\end{verbatim}
where
\verb
+
length
+
is the number of bytes of the
\verb
+
data
+
part
(i.e., excluding the
\verb
+
id
+
and
\verb
+
length
+
fields), and
the
\verb
+
id
+
gives the layout of the
\verb
+
data
+
part as defined
in
\ref
{
sec:ConcreteGrammar
}
\subsection
{
Data encoding
}
LabComm primitive types are encoded as fixed width values, sent in
network order. Type fields, user IDs, number of indices and lengths are
sent in a variable length (
\emph
{
varint
}
) form. A varint integer value
is sent as a sequence of bytes where the lower seven bits contain a
chunk of the actual number and the high bit indicates if more chunks
follow. The sequence of chunks are sent with the least significant chunk
first.
The built-in data types are encoded as follows:
\begin{verbatim}
<packet> := ( <type
_
decl> | <sample
_
decl> | <sample
_
data> )*
<type
_
decl> := 0x01 ''(packed)'' <user
_
id> <string> <type>
<sample
_
decl> := 0x02 ''(packed)''<user
_
id> <string> <type>
<user
_
id> := 0x40..0xffffffff ''(packed)''
<string> := <string
_
length> <char>*
<string
_
length> := 0x00..0xffffffff ''(packed)''
<char> := any UTF-8 char
<type> := ( <basic
_
type> | <user
_
id> | <array
_
decl> | <struct
_
decl> )
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<integer
_
type> | <long
_
type> | <float
_
type> |
<double
_
type> | <string
_
type> )
<boolean
_
type> := 0x20 ''(packed)''
<byte
_
type> := 0x21 ''(packed)''
<short
_
type> := 0x22 ''(packed)''
<integer
_
type> := 0x23 ''(packed)''
<long
_
type> := 0x24 ''(packed)''
<float
_
type> := 0x25 ''(packed)''
<double
_
type> := 0x26 ''(packed)''
<string
_
type> := 0x27 ''(packed)''
<array
_
decl> := 0x10 ''(packed)'' <number
_
of
_
indices> <indices> <type>
<number
_
of
_
indices> := 0x00..0xffffffff ''(packed)''
<indices> := ( <variable
_
index> | <fixed
_
index> )*
<variable
_
index> := 0x00 ''(packed)''
<fixed
_
index> := 0x01..0xffffffff ''(packed)''
<struct
_
decl> := 0x11 ''(packed)'' <number
_
of
_
fields> <field>*
<number
_
of
_
fields> := 0x00..0xffffffff ''(packed)''
<field> := <string> <type>
<sample
_
data> := <user
_
id> <packed
_
sample
_
data>
<packed
_
sample
_
data> := is sent in network order, sizes are as follows:
||Type ||Encoding/Size ||
||---------------||------------------------------------------------------||
||boolean || 8 bits ||
...
...
@@ -419,18 +410,46 @@ VariableSize : Exp;
||long || 64 bits ||
||float || 32 bits ||
||double || 64 bits ||
||string || length
''(packed)''
, followed by UTF8 encoded string ||
||array || each variable index
''(packed)'',
||
||string || length
(varint)
, followed by UTF8 encoded string
||
||array || each variable index
(varint),
||
|| || followed by encoded elements ||
||struct || concatenation of encoding of each element ||
|| || in declaration order ||
\end{verbatim}
Type fields, user IDs, number of indices and lengths are sent in a packed, or
variable length, form. An integer is sent as a sequence of bytes where the
lower seven bits contain a chunk of the actual number and the high bit
indicates if more chunks follow. The sequence of chunks are sent with the least
significant chunk first. (The numbers encoded in this form are indicated above
with
\textit
{
(packed)
}
.)
\subsection
{
Protocol grammar
}
\label
{
sec:ConcreteGrammar
}
\begin{verbatim}
<packet> := ( <version> | <type
_
decl> | <sample
_
decl> | <sample
_
data> )*
<version> := 0x01 <length> <string>
<sample
_
def> := 0x02 <length> <user
_
id> <string> <type>
<type
_
def> := 0x03 <length> <user
_
id> <string> <type>
<user
_
id> := 0x40..0xffffffff
<string> := <string
_
length> <char>*
<string
_
length> := 0x00..0xffffffff
<char> := any UTF-8 char
<type> := <length> ( <basic
_
type> | <user
_
id> | <array
_
decl> | <struct
_
decl> )
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<integer
_
type> | <long
_
type> | <float
_
type> |
<double
_
type> | <string
_
type> )
<boolean
_
type> := 0x20
<byte
_
type> := 0x21
<short
_
type> := 0x22
<integer
_
type> := 0x23
<long
_
type> := 0x24
<float
_
type> := 0x25
<double
_
type> := 0x26
<string
_
type> := 0x27
<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> := <user
_
id> <packed
_
sample
_
data>
<packed
_
sample
_
data> := is sent in network order, encoded :
\end{verbatim}
\end{document}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment