Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
LabComm
Commits
e1b71232
Commit
e1b71232
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into typedefs
parents
898fea44
dc098f4e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/tech_report.tex
+102
-37
102 additions, 37 deletions
doc/tech_report.tex
lib/python/labcomm/LabComm.py
+20
-2
20 additions, 2 deletions
lib/python/labcomm/LabComm.py
with
122 additions
and
39 deletions
doc/tech_report.tex
+
102
−
37
View file @
e1b71232
...
...
@@ -169,6 +169,22 @@ language covering most common use-cases.
sample string a
_
string;
\end{verbatim}
\subsection
{
The void type
}
There is a type,
\verb
+
void
+
, which can be used to send
a sample that contains no data.
\begin{verbatim}
typedef void an
_
empty
_
type;
sample an
_
empty
_
type no
_
data1;
sample void no
_
data2;
\end{verbatim}
\verb
+
void
+
type can may not be used as a field in a struct or
the element type of an array.
\subsection
{
Arrays
}
\begin{verbatim}
...
...
@@ -198,7 +214,46 @@ only arrays of arrays.
}
a
_
struct;
\end{verbatim}
\section
{
User defined types
}
\subsection
{
Sample type refereces
}
In addition to the primitive types, a sample may contain
a reference to a sample type. References are declared using
the
\verb
+
sample
+
keyword.
Examples:
\begin{verbatim}
sample sample a
_
ref;
sample sample ref
_
list[4];
sample struct
{
sample ref1;
sample ref2;
int x;
int y;
}
refs
_
and
_
ints;
\end{verbatim}
Sample references are need to be registered on both encoder and decoder
side, using the functions
\begin{verbatim}
int labcomm
_
decoder
_
sample
_
ref
_
register(
struct labcomm
_
decoder *decoder
\nonumber
const struct labcomm
_
signature *signature);
int labcomm
_
encoder
_
sample
_
ref
_
register(
struct labcomm
_
encoder *encoder
\nonumber
const struct labcomm
_
signature *signature);
\end{verbatim}
The value of an unregistered sample reference will be decoded as
\verb
+
null
+
.
\subsection
{
User defined types
}
User defined types are declared with the
\verb
+
typedef
+
reserved word,
and can then be used in type and sample declarations.
\begin{verbatim}
typedef struct
{
...
...
@@ -469,6 +524,7 @@ Field ::= Type <Name:String>;
abstract Type;
VoidType : Type;
SampleRefType : Type;
PrimType : Type ::= <Name:String> <Token:int>;
UserType : Type ::= <Name:String>;
StructType : Type ::= Field*;
...
...
@@ -529,10 +585,12 @@ The built-in data types are encoded as follows:
<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
...
...
@@ -541,10 +599,15 @@ The built-in data types are encoded as follows:
<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> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<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> )
<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
...
...
@@ -553,13 +616,14 @@ The built-in data types are encoded as follows:
<float
_
type> := 0x25
<double
_
type> := 0x26
<string
_
type> := 0x27
<array
_
decl> := 0x10 <number
_
of
_
indices> <indices> <type>
<number
_
of
_
indices> := 0x00..0xffffffff
<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 <n
umbe
r
_
of
_
fields> <field>*
<n
umbe
r
_
of
_
fields> := 0x00..0xffffffff
<struct
_
decl>
:= 0x11 <n
b
r
_
of
_
fields> <field>*
<n
b
r
_
of
_
fields>
:= 0x00..0xffffffff
<field> := <string> <type>
<sample
_
data> := packed sample data sent in network order, with
primitive type elements encoded according to
...
...
@@ -571,8 +635,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
...
...
This diff is collapsed.
Click to expand it.
lib/python/labcomm/LabComm.py
+
20
−
2
View file @
e1b71232
...
...
@@ -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 = 0x0
3
(packed32)
# | id = 0x0
4
(packed32)
# +----+----+----+----+
# | length (packed32)
# +----+----+----+----+
...
...
@@ -51,7 +69,7 @@
# LabComm2014 TYPE_BINDING
#
# +----+----+----+----+
# | id = 0x0
4
(packed32)
# | id = 0x0
5
(packed32)
# +----+----+----+----+
# | length (packed32)
# +----+----+----+----+
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment