Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Select Git revision
Show changes
/* LabComm declarations:
sample struct {
int sequence;
struct {
boolean last;
string data;
} line[_];
} log_message;
sample float data;
*/
#ifndef __LABCOMM_example_H__
#define __LABCOMM_example_H__
#include "labcomm.h"
#ifndef PREDEFINED_example_log_message
typedef struct {
int sequence;
struct {
int n_0;
struct {
unsigned char last;
char* data;
} *a;
} line;
} example_log_message;
#endif
void labcomm_decoder_register_example_log_message(
struct labcomm_decoder *d,
void (*handler)(
example_log_message *v,
void *context
),
void *context
);
void labcomm_encoder_register_example_log_message(
struct labcomm_encoder *e);
void labcomm_encode_example_log_message(
struct labcomm_encoder *e,
example_log_message *v
);
extern int labcomm_sizeof_example_log_message(example_log_message *v);
#ifndef PREDEFINED_example_data
typedef float example_data;
#endif
void labcomm_decoder_register_example_data(
struct labcomm_decoder *d,
void (*handler)(
example_data *v,
void *context
),
void *context
);
void labcomm_encoder_register_example_data(
struct labcomm_encoder *e);
void labcomm_encode_example_data(
struct labcomm_encoder *e,
example_data *v
);
extern int labcomm_sizeof_example_data(example_data *v);
#define LABCOMM_FORALL_SAMPLES_example(func, sep) \
func(log_message, example_log_message) sep \
func(data, example_data)
#endif
#!/usr/bin/python
# Auto generated example
import labcomm
class log_message(object):
signature = labcomm.sample('log_message',
labcomm.struct([
('sequence', labcomm.INTEGER()),
('line', labcomm.array([0],
labcomm.struct([
('last', labcomm.BOOLEAN()),
('data', labcomm.STRING())])))]))
class data(object):
signature = labcomm.sample('data',
labcomm.FLOAT())
/*
sample struct {
int sequence;
struct {
boolean last;
string data;
} line[_];
} log_message;
*/
import java.io.IOException;
import se.lth.control.labcomm.LabCommDecoder;
import se.lth.control.labcomm.LabCommDispatcher;
import se.lth.control.labcomm.LabCommEncoder;
import se.lth.control.labcomm.LabCommHandler;
import se.lth.control.labcomm.LabCommSample;
public class log_message implements LabCommSample {
public static class struct_line {
public boolean last;
public String data;
}
public int sequence;
public struct_line[] line;
public interface Handler extends LabCommHandler {
public void handle_log_message(log_message value) throws Exception;
}
public static void register(LabCommDecoder d, Handler h) throws IOException {
d.register(new Dispatcher(), h);
}
public static void register(LabCommEncoder e) throws IOException {
e.register(new Dispatcher());
}
private static class Dispatcher implements LabCommDispatcher {
public Class getSampleClass() {
return log_message.class;
}
public String getName() {
return "log_message";
}
public byte[] getSignature() {
return signature;
}
public void decodeAndHandle(LabCommDecoder d,
LabCommHandler h) throws Exception {
((Handler)h).handle_log_message(log_message.decode(d));
}
}
public static void encode(LabCommEncoder e, log_message value) throws IOException {
e.begin(log_message.class);
e.encodeInt(value.sequence);
e.encodeInt(value.line.length);
int i_0_max = value.line.length;
for (int i_0 = 0 ; i_0 < i_0_max ; i_0++) {
e.encodeBoolean(value.line[i_0].last);
e.encodeString(value.line[i_0].data);
}
e.end(log_message.class);
}
public static log_message decode(LabCommDecoder d) throws IOException {
log_message result;
result = new log_message();
result.sequence = d.decodeInt();
{
int i_0_max = d.decodeInt();
result.line = new struct_line[i_0_max];
for (int i_0 = 0 ; i_0 < i_0_max ; i_0++) {
result.line[i_0] = new struct_line();
result.line[i_0].last = d.decodeBoolean();
result.line[i_0].data = d.decodeString();
}
}
return result;
}
private static byte[] signature = new byte[] {
// struct { 2 fields
0, 0, 0, 17,
0, 0, 0, 2,
// int 'sequence'
0, 0, 0, 8,
115, 101, 113, 117, 101, 110, 99, 101,
0, 0, 0, 35,
// array [_] 'line'
0, 0, 0, 4,
108, 105, 110, 101,
// array [_]
0, 0, 0, 16,
0, 0, 0, 1,
0, 0, 0, 0,
// struct { 2 fields
0, 0, 0, 17,
0, 0, 0, 2,
// boolean 'last'
0, 0, 0, 4,
108, 97, 115, 116,
0, 0, 0, 32,
// string 'data'
0, 0, 0, 4,
100, 97, 116, 97,
0, 0, 0, 39,
// }
// }
// }
};
}
#!/bin/sh
# Auto generate code from .lc file
java -jar /opt/robot/java/labComm.jar \
--c=example.c --h=example.h \
--java=. \
--cs=example.cs \
--python=example.py \
example.lc
# Compile executables
gcc -o example_encoder -I ../lib/c/ \
example_encoder.c \
example.c \
../lib/c/labcomm.c \
../lib/c//labcomm_fd_reader_writer.c
javac -cp ../lib/java:. *.java
# Run through all executables (c->java->Python)
./example_encoder one two
java -cp ../lib/java:. example_decoder_encoder example.encoded example.javaencoded
PYTHONPATH=../lib/python ./example_decoder.py example.javaencoded