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

restructuring etc

parent 5f5757fe
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 *** % *** en embryo of a technical report describing the labcomm design rationale and implementation ***
\documentclass[a4paper]{article} \documentclass[a4paper]{article}
\usepackage{listings}
%\usepackage{verbatims} %\usepackage{verbatims}
%\usepackage{todo} %\usepackage{todo}
...@@ -222,73 +223,29 @@ But ...@@ -222,73 +223,29 @@ But
With the following `example.lc` file: With the following `example.lc` file:
\begin{verbatim} \lstinputlisting[basicstyle=\footnotesize]{../examples/wiki_example/example.lc}
sample struct {
int sequence;
struct {
boolean last;
string data;
} line[_];
} log_message;
sample float data;
\end{verbatim}
and this \verb+example_encoder.c+ file 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: Running \verb+./example_encoder one two+, will yield the following result in example.encoded:
\begin{verbatim} \begin{verbatim}
00000000 02 40 0b 6c 6f 67 5f 6d 65 73 73 61 67 65 11 02 |.@.log_message..| 00000000 01 0c 0b 4c 61 62 43 6f 6d 6d 32 30 31 34 02 30 |...LabComm2014.0|
00000010 08 73 65 71 75 65 6e 63 65 23 04 6c 69 6e 65 10 |.sequence#.line.| 00000010 40 0b 6c 6f 67 5f 6d 65 73 73 61 67 65 22 11 02 |@.log_message"..|
00000020 01 00 11 02 04 6c 61 73 74 20 04 64 61 74 61 27 |.....last .data'| 00000020 08 73 65 71 75 65 6e 63 65 23 04 6c 69 6e 65 10 |.sequence#.line.|
00000030 02 41 04 64 61 74 61 25 40 00 00 00 01 00 40 00 |.A.data%@.....@.| 00000030 01 00 11 02 04 6c 61 73 74 20 04 64 61 74 61 27 |.....last .data'|
00000040 00 00 02 01 01 03 6f 6e 65 40 00 00 00 03 02 00 |......one@......| 00000040 02 08 41 04 64 61 74 61 01 25 40 04 00 00 00 01 |..A.data.%@.....|
00000050 03 6f 6e 65 01 03 74 77 6f 41 00 00 00 00 41 3f |.one..twoA....A?| 00000050 00 40 09 00 00 00 02 01 01 03 6f 6e 65 40 0e 00 |.@........one@..|
00000060 80 00 00 41 40 00 00 00 |...A@...| 00000060 00 00 03 02 00 03 6f 6e 65 01 03 74 77 6f 41 04 |......one..twoA.|
00000068 00000070 00 00 00 00 41 04 3f 80 00 00 41 04 40 00 00 00 |....A.?...A.@...|
00000080
\end{verbatim} \end{verbatim}
i.e., i.e.,
\begin{verbatim} \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: <struct_decl:
<number_of_fields: 2> <number_of_fields: 2>
<string: <len: 8> <"sequence"> <type: <integer_type>> <string: <len: 8> <"sequence"> <type: <integer_type>>
...@@ -301,8 +258,11 @@ i.e., ...@@ -301,8 +258,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} \end{verbatim}
\section{Ideas/Discussion}: \section{Ideas/Discussion}:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment