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

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Show changes
Showing
with 199 additions and 91 deletions
#dummy script to test the on-the-fly compilation
javac -cp .:../../compiler/labComm.jar:../../lib/java/labcomm.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test/TestLabcommGen.java
javac -cp .:../../compiler/labcomm2014_compiler.jar:../../lib/java/labcomm2014.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test/TestLabcommGen.java
javac test/HandlerContext.java
java -cp .:../../compiler/labComm.jar:../../lib/java/labcomm.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test.TestLabcommGen simple_type.lc handlers_type.txt encoded_data
java -cp .:../../compiler/labcomm2014_compiler.jar:../../lib/java/labcomm2014.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test.TestLabcommGen simple_type.lc handlers_type.txt encoded_data
LCDIR=../..
LCC=java -jar ${LCDIR}/compiler/labComm.jar
CLASSPATH=.:${LCDIR}/lib/java/labcomm.jar
LABCOMM_JAR=../../compiler/labcomm2014_compiler.jar
LABCOMM=java -jar $(LABCOMM_JAR)
CLASSPATH=.:${LCDIR}/lib/java/labcomm2014.jar
JAVA_PKG=labcommTCPtest
SAMPLENAME=foo
LCC=java -jar ${LCDIR}/compiler/labComm.jar
LCLIBDIR=${LCDIR}/lib/c
LCFILE=jg
......@@ -12,7 +12,7 @@ TLCFILE=turtle1
TAUX=turtle_enc.c turtle_dec.c
${JAVA_PKG}/gen/foo.java: ${LCFILE}.lc
${LCC} --javapackage=${JAVA_PKG}.gen --java=${JAVA_PKG}/gen $<
${LABCOMM} --javapackage=${JAVA_PKG}.gen --java=${JAVA_PKG}/gen $<
${JAVA_PKG}/gen/${SAMPLENAME}.class: ${JAVA_PKG}/gen/${SAMPLENAME}.java
javac -cp ${CLASSPATH} $<
......@@ -24,9 +24,11 @@ ${JAVA_PKG}/client/TestClient.class: ${JAVA_PKG}/client/TestClient.java ${JAVA_P
javac -cp ${CLASSPATH} $<
.PHONY: runjavaserver
runjavaserver : ${JAVA_PKG}/server/TestServer.class
java -cp ${CLASSPATH} $(<:.class=)
.PHONY: runjavaclient
runjavaclient : ${JAVA_PKG}/client/TestClient.class
java -cp ${CLASSPATH} $(<:.class=)
......@@ -36,27 +38,34 @@ client: client.c ${LCFILE}.c ${AUX} ${AUX:.c=.h}
testserver: testserver.c ${LCFILE}.c ${AUX} ${AUX:.c=.h}
${CC} -o $@ testserver.c ${AUX} ${LCFILE}.c -I${LCLIBDIR} -L${LCLIBDIR} -llabcomm
turtleclient: turtleclient.c ${TLCFILE}.c ${TAUX} ${TAUX:.c=.h}
${CC} -o $@ turtleclient.c ${TAUX} ${TLCFILE}.c -I${LCLIBDIR} -L${LCLIBDIR} -llabcomm
${LCFILE}.c : ${LCFILE}.lc
${LCC} -C ${LCFILE}.lc
${LABCOMM} -C ${LCFILE}.lc
${TLCFILE}.c : ${TLCFILE}.lc
${LCC} -C ${TLCFILE}.lc
${LABCOMM} -C ${TLCFILE}.lc
all: client testserver ${JAVA_PKG}/server/TestServer.class ${JAVA_PKG}/client/TestClient.class turtleclient
.PHONY: clean runclient runserver runjavaserver runjavaclient turtleclient
.PHONY: clean
clean :
rm ${LCFILE}.c ${LCFILE}.h client testserver turtleclient
rm ${JAVA_PKG}/server/*.class ${JAVA_PKG}/client/*.class ${JAVA_PKG}/gen/*
rm -f ${LCFILE}.c ${LCFILE}.h client testserver turtleclient
rm -f ${JAVA_PKG}/server/*.class ${JAVA_PKG}/client/*.class
rm -f ${JAVA_PKG}/gen/*
.PHONY: distclean
distclean: clean
.PHONY: runclient
runclient : client
LD_LIBRARY_PATH=${LCLIBDIR} ./$< localhost 9999
.PHONY: runserver
runserver : testserver
LD_LIBRARY_PATH=${LCLIBDIR} ./$< 9999
.PHONY: runtclient
runtclient : turtleclient
LD_LIBRARY_PATH=${LCLIBDIR} ./$< localhost 8082
......@@ -6,8 +6,8 @@ import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import se.lth.control.labcomm.LabCommDecoderChannel;
import se.lth.control.labcomm.LabCommEncoderChannel;
import se.lth.control.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.EncoderChannel;
import labcommTCPtest.gen.foo;
import labcommTCPtest.gen.foo.Handler;
......@@ -25,7 +25,7 @@ public class TestClient implements Handler {
public void test() {
try {
LabCommEncoderChannel e = new LabCommEncoderChannel(out );
EncoderChannel e = new EncoderChannel(out );
foo.register(e);
foo sample = new foo();
sample.c = 17;
......@@ -36,7 +36,7 @@ public class TestClient implements Handler {
printSample("Client sending", sample);
foo.encode(e, sample);
LabCommDecoderChannel c = new LabCommDecoderChannel(in);
DecoderChannel c = new DecoderChannel(in);
foo.register(c,this);
c.run();
} catch (Exception e) {
......
......@@ -6,8 +6,8 @@ import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import se.lth.control.labcomm.LabCommDecoderChannel;
import se.lth.control.labcomm.LabCommEncoderChannel;
import se.lth.control.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.EncoderChannel;
import labcommTCPtest.gen.FooSample;
import labcommTCPtest.gen.FooSample.Handler;
......@@ -25,7 +25,7 @@ public class TestClientSingleshot implements Handler {
public void test() {
try {
LabCommEncoderChannel e = new LabCommEncoderChannel(out );
EncoderChannel e = new EncoderChannel(out );
FooSample.register(e);
FooSample sample = new FooSample();
sample.x = 17;
......@@ -35,7 +35,7 @@ public class TestClientSingleshot implements Handler {
printSample("Client sending", sample);
FooSample.encode(e, sample);
LabCommDecoderChannel c = new LabCommDecoderChannel(in);
DecoderChannel c = new DecoderChannel(in);
FooSample.register(c,this);
c.runOne();
} catch (Exception e) {
......
......@@ -8,8 +8,8 @@ import java.lang.reflect.Method;
import java.net.ServerSocket;
import java.net.Socket;
import se.lth.control.labcomm.LabCommDecoderChannel;
import se.lth.control.labcomm.LabCommEncoderChannel;
import se.lth.control.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.EncoderChannel;
import labcommTCPtest.gen.foo;
import labcommTCPtest.gen.foo.Handler;
......@@ -38,7 +38,7 @@ public class TestServer implements Handler {
public void runOne() {
try {
LabCommDecoderChannel c = new LabCommDecoderChannel(in);
DecoderChannel c = new DecoderChannel(in);
foo.register(c,this);
c.runOne();
} catch (Exception e) {
......@@ -47,7 +47,7 @@ public class TestServer implements Handler {
}
public void handle_foo(foo sample) throws Exception {
LabCommEncoderChannel e = new LabCommEncoderChannel(out );
EncoderChannel e = new EncoderChannel(out );
foo.register(e);
System.out.println("TestServer.handle_foo...");
sample.b *= 2;
......
......@@ -3,4 +3,4 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
</configuration>
......@@ -46,4 +46,4 @@ MODULE Follow
RETURN;
ENDPROC
ENDMODULE
\ No newline at end of file
ENDMODULE
......@@ -35,4 +35,4 @@ sample struct {
float eax_e;
float eax_f;
} extax;
} jointtarget;
\ No newline at end of file
} jointtarget;
all:
clean:
distclean:
using se.lth.control.labcomm;
using se.lth.control.labcomm2014;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace RobotCtrl
{
class Program
class Specification
{
public static string IP_ADDRESS = "127.0.0.1";
......@@ -20,11 +20,11 @@ namespace RobotCtrl
{
jointtarget val = new jointtarget { robax = new jointtarget.struct_robax(), extax = new jointtarget.struct_extax() };
TcpClient client = new TcpClient();
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Program.IP_ADDRESS), Program.PORT);
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Specification.IP_ADDRESS), Specification.PORT);
try
{
client.Connect(serverEndPoint);
LabCommEncoder enc = new LabCommEncoderChannel(client.GetStream(), true);
Encoder enc = new EncoderChannel(client.GetStream(), true);
jointtarget.register(enc);
jointtarget.encode(enc, val);
for (int i = 0; i < 10; i++)
......
......@@ -42,7 +42,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="LCRobot.cs" />
<Compile Include="Program.cs" />
<Compile Include="Specification.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......@@ -62,4 +62,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
</Project>
encoded_data
encoded_data06
example_decoder
example_decoder06
example_encoder
example_encoder06
gen
gen06
......@@ -2,24 +2,25 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import se.lth.control.labcomm.LabCommDecoderChannel;
import se.lth.control.labcomm2014.DecoderChannel;
public class Decoder
implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler
implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler, doavoid.Handler
{
LabCommDecoderChannel decoder;
DecoderChannel decoder;
public Decoder(InputStream in)
throws Exception
{
decoder = new LabCommDecoderChannel(in);
decoder = new DecoderChannel(in);
theTwoInts.register(decoder, this);
anotherTwoInts.register(decoder, this);
IntString.register(decoder, this);
TwoArrays.register(decoder, this);
TwoFixedArrays.register(decoder, this);
doavoid.register(decoder, this);
try {
System.out.println("Running decoder.");
......@@ -72,6 +73,10 @@ public class Decoder
}
System.out.println();
}
public void handle_doavoid() throws java.io.IOException {
System.out.println("Got doavoid");
}
public static void main(String[] arg) throws Exception {
......
......@@ -2,7 +2,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import se.lth.control.labcomm.LabCommEncoderChannel;
import se.lth.control.labcomm2014.EncoderChannel;
/**
* Simple encoder
......@@ -10,18 +10,20 @@ import se.lth.control.labcomm.LabCommEncoderChannel;
public class Encoder
{
LabCommEncoderChannel encoder;
EncoderChannel encoder;
public Encoder(OutputStream out)
throws Exception
{
encoder = new LabCommEncoderChannel(out);
encoder = new EncoderChannel(out);
doavoid.register(encoder);
theTwoInts.register(encoder);
IntString.register(encoder);
TwoArrays.register(encoder);
}
public void doEncode() throws java.io.IOException {
TwoInts x = new TwoInts();
x.a = 17;
x.b = 42;
......@@ -35,6 +37,9 @@ public class Encoder
// ta.variable = new int[][] {{1,2},{0x11,0x12},{0x21,0x22},{0x31,0x32}};
ta.variable = new int[][] {{1,2, 3, 4},{0x21,0x22,0x23,0x24}};
System.out.println("Encoding doavoid");
doavoid.encode(encoder);
System.out.println("Encoding theTwoInts, a="+x.a+", b="+x.b);
theTwoInts.encode(encoder, x);
......
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import se.lth.control.labcomm2014.EncoderChannel;
/**
* Simple encoder
*/
public class EncoderIS
{
EncoderChannel encoder;
public EncoderIS(OutputStream out)
throws Exception
{
encoder = new EncoderChannel(out);
// doavoid.register(encoder);
// theTwoInts.register(encoder);
IntString.register(encoder);
// TwoArrays.register(encoder);
}
public void doEncodeIS() throws java.io.IOException {
IntString a = new IntString();
a.x = 17;
a.s = "A string";
IntString b = new IntString();
b.x = 9;
b.s = "Hej";
IntString c = new IntString();
c.x = 133742;
c.s = "Thirteenthirtysevenfourtytwo";
System.out.println("Encoding IntStrings");
IntString.encode(encoder, a);
IntString.encode(encoder, b);
IntString.encode(encoder, c);
}
public static void main(String[] arg) throws Exception {
FileOutputStream fos = new FileOutputStream(arg[0]);
EncoderIS example = new EncoderIS(fos);
example.doEncodeIS();
fos.close();
}
}
all:
clean:
distclean:
rm -rf gen
rm -f *.class
rm -f example_encoder
rm -f example_decoder
rm -f encoded_data
#!/bin/sh
set -x
set -e
### Example compile script, showing the steps required to build a labcomm application
### (including compiler and libs). Also illustrates how versions 2013 and 2006 coexist
# For current version (2013)
(cd ../..; make all)
mkdir -p gen
java -jar ../../compiler/labComm.jar --java=gen --c=gen/simple.c --h=gen/simple.h --python=gen/simple.py simple.lc
java -jar ../../compiler/labcomm2014_compiler.jar --java=gen --c=gen/simple.c --h=gen/simple.h --python=gen/simple.py simple.lc
javac -cp ../../lib/java:. gen/*.java Encoder.java Decoder.java
javac -cp ../../lib/java/labcomm2014.jar:. gen/*.java Encoder.java Decoder.java
gcc -Wall -Werror -I. -I../../lib/c -L../../lib/c \
gcc -Wall -Werror -Wno-unused-function \
-I. -I../../lib/c/2014 -L../../lib/c \
-o example_encoder example_encoder.c gen/simple.c \
-llabcomm -Tlabcomm.linkscript
gcc -Wall -Werror -I . -I ../../lib/c -L../../lib/c \
-llabcomm2014
gcc -Wall -Werror -I . -I ../../lib/c/2014 -L../../lib/c \
-o example_decoder example_decoder.c gen/simple.c \
-llabcomm -Tlabcomm.linkscript
#gcc -o example_encoder -I . -I ../../lib/c example_encoder.c gen/simple.c ../../lib/c/labcomm.c ../../lib/c/labcomm_fd_reader_writer.c
#gcc -o example_decoder -I . -I ../../lib/c example_decoder.c gen/simple.c ../../lib/c/labcomm.c ../../lib/c/labcomm_fd_reader_writer.c
-llabcomm2014
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <labcomm_fd_reader.h>
#include <labcomm_default_error_handler.h>
#include <labcomm_default_memory.h>
#include <labcomm_default_scheduler.h>
#include <labcomm2014_fd_reader.h>
#include <labcomm2014_default_error_handler.h>
#include <labcomm2014_default_memory.h>
#include <labcomm2014_default_scheduler.h>
#include "gen/simple.h"
#include <stdio.h>
static void handle_simple_doavoid(simple_doavoid *v, void *context) {
printf("Got a void.\n");
}
static void handle_simple_theTwoInts(simple_TwoInts *v,void *context) {
printf("Got theTwoInts. a=%d, b=%d\n", v->a, v->b);
}
......@@ -53,32 +57,33 @@ static void handle_simple_TwoFixedArrays(simple_TwoFixedArrays *d,void *context)
int main(int argc, char *argv[]) {
int fd;
struct labcomm_decoder *decoder;
struct labcomm2014_decoder *decoder;
void *context = NULL;
char *filename = argv[1];
printf("C decoder reading from %s\n", filename);
fd = open(filename, O_RDONLY);
decoder = labcomm_decoder_new(labcomm_fd_reader_new(
labcomm_default_memory, fd, 1),
labcomm_default_error_handler,
labcomm_default_memory,
labcomm_default_scheduler);
decoder = labcomm2014_decoder_new(labcomm2014_fd_reader_new(
labcomm2014_default_memory, fd, 1),
labcomm2014_default_error_handler,
labcomm2014_default_memory,
labcomm2014_default_scheduler);
if (!decoder) {
printf("Failed to allocate decoder %s:%d\n", __FUNCTION__, __LINE__);
return 1;
}
labcomm_decoder_register_simple_theTwoInts(decoder, handle_simple_theTwoInts, context);
labcomm_decoder_register_simple_anotherTwoInts(decoder, handle_simple_anotherTwoInts, context);
labcomm_decoder_register_simple_IntString(decoder, handle_simple_IntString, context);
labcomm_decoder_register_simple_TwoArrays(decoder, handle_simple_TwoArrays, context);
labcomm_decoder_register_simple_TwoFixedArrays(decoder, handle_simple_TwoFixedArrays, context);
labcomm2014_decoder_register_simple_doavoid(decoder, handle_simple_doavoid, context);
labcomm2014_decoder_register_simple_theTwoInts(decoder, handle_simple_theTwoInts, context);
labcomm2014_decoder_register_simple_anotherTwoInts(decoder, handle_simple_anotherTwoInts, context);
labcomm2014_decoder_register_simple_IntString(decoder, handle_simple_IntString, context);
labcomm2014_decoder_register_simple_TwoArrays(decoder, handle_simple_TwoArrays, context);
labcomm2014_decoder_register_simple_TwoFixedArrays(decoder, handle_simple_TwoFixedArrays, context);
printf("Decoding:\n");
labcomm_decoder_run(decoder);
labcomm2014_decoder_run(decoder);
printf("--- End Of File ---:\n");
labcomm_decoder_free(decoder);
labcomm2014_decoder_free(decoder);
return 0;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <labcomm_fd_writer.h>
#include <labcomm_default_error_handler.h>
#include <labcomm_default_memory.h>
#include <labcomm_default_scheduler.h>
#include <labcomm2014_fd_writer.h>
#include <labcomm2014_default_error_handler.h>
#include <labcomm2014_default_memory.h>
#include <labcomm2014_default_scheduler.h>
#include "gen/simple.h"
#include <stdio.h>
int main(int argc, char *argv[]) {
int fd;
struct labcomm_encoder *encoder;
struct labcomm2014_encoder *encoder;
char *filename = argv[1];
printf("C encoder writing to %s\n", filename);
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
encoder = labcomm_encoder_new(labcomm_fd_writer_new(
labcomm_default_memory, fd, 1),
labcomm_default_error_handler,
labcomm_default_memory,
labcomm_default_scheduler);
labcomm_encoder_register_simple_theTwoInts(encoder);
labcomm_encoder_register_simple_anotherTwoInts(encoder);
labcomm_encoder_register_simple_IntString(encoder);
encoder = labcomm2014_encoder_new(labcomm2014_fd_writer_new(
labcomm2014_default_memory, fd, 1),
labcomm2014_default_error_handler,
labcomm2014_default_memory,
labcomm2014_default_scheduler);
labcomm2014_encoder_register_simple_doavoid(encoder);
labcomm2014_encoder_register_simple_theTwoInts(encoder);
labcomm2014_encoder_register_simple_anotherTwoInts(encoder);
labcomm2014_encoder_register_simple_IntString(encoder);
labcomm2014_encode_simple_doavoid(encoder);
simple_IntString is;
is.x = 24;
is.s = "Hello, LabComm!";
printf("Encoding IntString, x=%d, s=%s\n", is.x, is.s);
labcomm_encode_simple_IntString(encoder, &is);
labcomm2014_encode_simple_IntString(encoder, &is);
simple_theTwoInts ti;
ti.a = 13;
ti.b = 37;
printf("Encoding theTwoInts, a=%d, b=%d\n", ti.a, ti.b);
labcomm_encode_simple_theTwoInts(encoder, &ti);
labcomm2014_encode_simple_theTwoInts(encoder, &ti);
simple_anotherTwoInts ati;
ati.a = 23;
ati.b = 47;
printf("Encoding anotherTwoInts, a=%d, b=%d\n", ati.a, ati.b);
labcomm_encode_simple_anotherTwoInts(encoder, &ati);
labcomm2014_encode_simple_anotherTwoInts(encoder, &ati);
int foo[20];
labcomm_encoder_register_simple_TwoArrays(encoder);
labcomm2014_encoder_register_simple_TwoArrays(encoder);
simple_TwoArrays ta;
ta.fixed.a[0] = 17;
......@@ -57,12 +61,12 @@ int main(int argc, char *argv[]) {
}
printf("Encoding TwoArrays...\n");
labcomm_encode_simple_TwoArrays(encoder, &ta);
labcomm2014_encode_simple_TwoArrays(encoder, &ta);
ti.a = 23;
ti.b = 47;
printf("Encoding theTwoInts, a=%d, b=%d\n", ti.a, ti.b);
labcomm_encode_simple_theTwoInts(encoder, &ti);
labcomm2014_encode_simple_theTwoInts(encoder, &ti);
simple_TwoFixedArrays tfa;
......@@ -78,8 +82,8 @@ int main(int argc, char *argv[]) {
tfa.b.a[1][2] = 63;
printf("Encoding TwoFixedArrays...\n");
labcomm_encoder_register_simple_TwoFixedArrays(encoder);
labcomm_encode_simple_TwoFixedArrays(encoder, &tfa);
labcomm2014_encoder_register_simple_TwoFixedArrays(encoder);
labcomm2014_encode_simple_TwoFixedArrays(encoder, &tfa);
return 0;
}
#!/usr/bin/python
import labcomm
import labcomm2014
import sys
import simple
if __name__ == '__main__':
encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')))
version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
encoder = labcomm2014.Encoder(labcomm2014.StreamWriter(open(sys.argv[1], 'w')), version)
encoder.add_decl(simple.theTwoInts.signature)
encoder.add_decl(simple.IntString.signature)
foo = simple.theTwoInts()
......