Skip to content
Snippets Groups Projects
Commit 6554806c authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

Merge branch 'master' of git.cs.lth.se:robotlab/labcomm-core

parents 9a724313 e7155139
No related branches found
No related tags found
No related merge requests found
% *** en embryo of a technical report describing the labcomm design rationale and implementation ***
\documentclass[a4paper]{article}
\usepackage{listings}
%\usepackage{verbatims}
%\usepackage{todo}
......@@ -253,73 +254,29 @@ But
With the following `example.lc` file:
\begin{verbatim}
sample struct {
int sequence;
struct {
boolean last;
string data;
} line[_];
} log_message;
sample float data;
\end{verbatim}
\lstinputlisting[basicstyle=\footnotesize]{../examples/wiki_example/example.lc}
and this \verb+example_encoder.c+ file
\lstinputlisting[basicstyle=\footnotesize,language=C]{../examples/wiki_example/example_encoder.c}
\begin{verbatim}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <labcomm_fd_reader.h>
#include <labcomm_fd_writer.h>
#include "example.h"
int main(int argc, char *argv[]) {
int fd;
struct labcomm_encoder *encoder;
int i, j;
fd = open("example.encoded", O_WRONLY|O_CREAT|O_TRUNC, 0644);
encoder = labcomm_encoder_new(labcomm_fd_writer, &fd);
labcomm_encoder_register_example_log_message(encoder);
labcomm_encoder_register_example_data(encoder);
for (i = 0 ; i < argc ; i++) {
example_log_message message;
message.sequence = i + 1;
message.line.n_0 = i;
message.line.a = malloc(message.line.n_0*sizeof(message.line));
for (j = 0 ; j < i ; j++) {
message.line.a[j].last = (j == message.line.n_0 - 1);
message.line.a[j].data = argv[j + 1];
}
labcomm_encode_example_log_message(encoder, &message);
free(message.line.a);
}
for (i = 0 ; i < argc ; i++) {
float f = i;
labcomm_encode_example_data(encoder, &f);
}
}
\end{verbatim}
Running \verb+./example_encoder one two+, will yield the following result in example.encoded:
\begin{verbatim}
00000000 02 40 0b 6c 6f 67 5f 6d 65 73 73 61 67 65 11 02 |.@.log_message..|
00000010 08 73 65 71 75 65 6e 63 65 23 04 6c 69 6e 65 10 |.sequence#.line.|
00000020 01 00 11 02 04 6c 61 73 74 20 04 64 61 74 61 27 |.....last .data'|
00000030 02 41 04 64 61 74 61 25 40 00 00 00 01 00 40 00 |.A.data%@.....@.|
00000040 00 00 02 01 01 03 6f 6e 65 40 00 00 00 03 02 00 |......one@......|
00000050 03 6f 6e 65 01 03 74 77 6f 41 00 00 00 00 41 3f |.one..twoA....A?|
00000060 80 00 00 41 40 00 00 00 |...A@...|
00000068
00000000 01 0c 0b 4c 61 62 43 6f 6d 6d 32 30 31 34 02 30 |...LabComm2014.0|
00000010 40 0b 6c 6f 67 5f 6d 65 73 73 61 67 65 22 11 02 |@.log_message"..|
00000020 08 73 65 71 75 65 6e 63 65 23 04 6c 69 6e 65 10 |.sequence#.line.|
00000030 01 00 11 02 04 6c 61 73 74 20 04 64 61 74 61 27 |.....last .data'|
00000040 02 08 41 04 64 61 74 61 01 25 40 04 00 00 00 01 |..A.data.%@.....|
00000050 00 40 09 00 00 00 02 01 01 03 6f 6e 65 40 0e 00 |.@........one@..|
00000060 00 00 03 02 00 03 6f 6e 65 01 03 74 77 6f 41 04 |......one..twoA.|
00000070 00 00 00 00 41 04 3f 80 00 00 41 04 40 00 00 00 |....A.?...A.@...|
00000080
\end{verbatim}
i.e.,
\begin{verbatim}
<sample_decl> <user_id: 0x40> <string: <len: 11> <"log_message">
<version> <length: 12> <string: <len: 11> <"LabComm2014">>
<sample_decl> <length: 48 <user_id: 0x40> <string: <len: 11> <"log_message">
<signature_length: 34>
<struct_decl:
<number_of_fields: 2>
<string: <len: 8> <"sequence"> <type: <integer_type>>
......@@ -332,8 +289,11 @@ i.e.,
>>
>
>
<sample_decl> <user_id: 0x41>
...
<sample_decl> <length: 8> <user_id: 0x41> <string: <len: 4> <"data">>
<signature_length: 1> <float_type>
<sample_data> <user_id: 40> <length: 4> <packed_sample_data>
<sample_data> <user_id: 40> <length: 9> <packed_sample_data>
<sample_data> <user_id: 40> <length: 14> <packed_sample_data>
\end{verbatim}
\section{Ideas/Discussion}:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment