diff --git a/.gitignore b/.gitignore index 336ae928c44fec58c79e01628adf660fc873f3ad..002536b55491e783ffb65cd79f9a9922c96cf0e9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,9 @@ lib/c/liblabcomm.so.1 lib/c/liblabcomm2006.so.1 lib/c/liblabcomm2006.so lib/c/liblabcomm2006.a -lib/c/liblabcomm2013.so.1 -lib/c/liblabcomm2013.so -lib/c/liblabcomm2013.a +lib/c/liblabcomm20141009.so.1 +lib/c/liblabcomm20141009.so +lib/c/liblabcomm20141009.a lib/c/test/test_labcomm lib/c/test/test_labcomm_basic_type_encoding lib/c/test/test_labcomm_copy diff --git a/examples/simple/Makefile b/examples/simple/Makefile index b11fc291e27c724e062e0b55ffbe1a421abcebb3..e12fb678ad0e8a583f3c1d64cfca56788fbdae0e 100644 --- a/examples/simple/Makefile +++ b/examples/simple/Makefile @@ -10,3 +10,4 @@ distclean: rm -f example_encoder06 rm -f example_decoder rm -f example_decoder06 + rm -f encoded_data diff --git a/examples/simple/compile.sh b/examples/simple/compile.sh index a5566fc61fb48e8d90681415033a17b9ff878d47..113f7f261a9840fcd923b6493a8211901fda7d87 100644 --- a/examples/simple/compile.sh +++ b/examples/simple/compile.sh @@ -7,15 +7,15 @@ mkdir -p gen java -jar ../../compiler/labComm.jar --java=gen --c=gen/simple.c --h=gen/simple.h --python=gen/simple.py simple.lc -javac -cp ../../lib/java/labcomm2013.jar:. gen/*.java Encoder.java Decoder.java +javac -cp ../../lib/java/labcomm20141009.jar:. gen/*.java Encoder.java Decoder.java gcc -Wall -Werror -Wno-unused-function \ -I. -I../../lib/c -L../../lib/c \ -o example_encoder example_encoder.c gen/simple.c \ - -llabcomm2013 -Tlabcomm.linkscript + -llabcomm20141009 -Tlabcomm.linkscript gcc -Wall -Werror -I . -I ../../lib/c -L../../lib/c \ -o example_decoder example_decoder.c gen/simple.c \ - -llabcomm2013 -Tlabcomm.linkscript + -llabcomm20141009 -Tlabcomm.linkscript # For version 2006 diff --git a/examples/simple/example_encoder.py b/examples/simple/example_encoder.py index 277eb93589e7b77bd8224a3c91888d065698a003..fea1dbcf9209b21e0bde16891234b4a2e1468c94 100755 --- a/examples/simple/example_encoder.py +++ b/examples/simple/example_encoder.py @@ -5,7 +5,7 @@ import sys import simple if __name__ == '__main__': - version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013" + version = sys.argv[2] if len(sys.argv) == 3 else "LabComm20141009" encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version) encoder.add_decl(simple.theTwoInts.signature) encoder.add_decl(simple.IntString.signature) diff --git a/examples/simple/run.sh b/examples/simple/run.sh index 192225d33f8522c12c4a14e956b37c9fb5cfe4b9..bc9a10a7ddddf939350ea9b1f78c556d0872a5eb 100644 --- a/examples/simple/run.sh +++ b/examples/simple/run.sh @@ -5,17 +5,17 @@ echo "*** Running example for version 2013 ***" echo "********************************************" echo -java -cp .:../../lib/java/labcomm2013.jar:gen Encoder encoded_data +java -cp .:../../lib/java/labcomm20141009.jar:gen Encoder encoded_data ./example_decoder encoded_data PYTHONPATH=../../lib/python:gen ./example_encoder.py encoded_data -java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data +java -cp .:../../lib/java/labcomm20141009.jar:gen Decoder encoded_data ./example_encoder encoded_data -java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data +java -cp .:../../lib/java/labcomm20141009.jar:gen Decoder encoded_data echo "running python decoder (from wiki_example):" -PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2013 +PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm20141009 echo echo "*******************************************************" diff --git a/examples/user_types/Makefile b/examples/user_types/Makefile index 757301e818275ec4ae55c10514b825483b2ce0b8..4d68ea9a1ab28408177b093e73c730a919a01919 100644 --- a/examples/user_types/Makefile +++ b/examples/user_types/Makefile @@ -4,3 +4,4 @@ clean: distclean: rm -rf gen + rm -f encoded_data diff --git a/examples/user_types/compile.sh b/examples/user_types/compile.sh index e1029d83815313c72f21915695fdf66464bd8113..3daee1b679adae1c166eb9897fa4caba2637092e 100644 --- a/examples/user_types/compile.sh +++ b/examples/user_types/compile.sh @@ -7,16 +7,16 @@ mkdir -p gen java -jar ../../compiler/labComm.jar --java=gen --c=gen/test.c --h=gen/test.h --python=gen/test.py test.lc -javac -cp ../../lib/java/labcomm2013.jar:. gen/*.java Encoder.java Decoder.java +javac -cp ../../lib/java/labcomm20141009.jar:. gen/*.java Encoder.java Decoder.java # for macOS, add -DLABCOMM_COMPAT=\"labcomm_compat_osx.h\" \ gcc -Wall -Werror -Wno-unused-function \ -I. -I../../lib/c -L../../lib/c \ -o example_encoder example_encoder.c gen/test.c \ - -llabcomm2013 + -llabcomm20141009 gcc -Wall -Werror -I . -I ../../lib/c -L../../lib/c \ -o example_decoder example_decoder.c gen/test.c \ - -llabcomm2013 + -llabcomm20141009 #-Tlabcomm.linkscript diff --git a/examples/user_types/example_encoder.py b/examples/user_types/example_encoder.py index f20d42c47bac064273a32880f091f717a88a08c8..987a2b117b33fc472604e12f2daf332f731ab751 100755 --- a/examples/user_types/example_encoder.py +++ b/examples/user_types/example_encoder.py @@ -5,7 +5,7 @@ import sys import test if __name__ == '__main__': - version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013" + version = sys.argv[2] if len(sys.argv) == 3 else "LabComm20141009" encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version) encoder.add_decl(test.twoLines.signature) l1 = test.line() diff --git a/examples/user_types/run.sh b/examples/user_types/run.sh index 2bdc6eea0cdf570c61a26f24e0aa9c294dfd9758..1b791ecae8e3d96115f809d06be63d207cbec0f4 100644 --- a/examples/user_types/run.sh +++ b/examples/user_types/run.sh @@ -5,34 +5,34 @@ echo "*** Running example for version 2013 ***" echo "********************************************" echo -java -cp .:../../lib/java/labcomm2013.jar:gen Encoder encoded_data +java -cp .:../../lib/java/labcomm20141009.jar:gen Encoder encoded_data echo "running Java decoder:" -java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data +java -cp .:../../lib/java/labcomm20141009.jar:gen Decoder encoded_data echo "running C decoder:" ./example_decoder encoded_data echo "running python decoder (from wiki_example):" -PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2013 +PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm20141009 echo "running C encoder:" ./example_encoder encoded_data echo "running Java decoder:" -java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data +java -cp .:../../lib/java/labcomm20141009.jar:gen Decoder encoded_data echo "running C decoder:" ./example_decoder encoded_data echo "running python decoder (from wiki_example):" -PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2013 +PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm20141009 echo "running python encoder:" PYTHONPATH=../../lib/python:gen ./example_encoder.py encoded_data2 echo "running Java decoder:" -java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data2 +java -cp .:../../lib/java/labcomm20141009.jar:gen Decoder encoded_data2 echo "running C decoder:" ./example_decoder encoded_data2 diff --git a/examples/wiki_example/example_decoder.py b/examples/wiki_example/example_decoder.py index a72533062a083eea23c67bbb4843ad666168ea09..6f5813e375a1fb8071f8cef24a224d7155ce5a8e 100755 --- a/examples/wiki_example/example_decoder.py +++ b/examples/wiki_example/example_decoder.py @@ -4,7 +4,7 @@ import labcomm import sys if __name__ == "__main__": - version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013" + version = sys.argv[2] if len(sys.argv) == 3 else "LabComm20141009" d = labcomm.Decoder(labcomm.StreamReader(open(sys.argv[1])), version) while True: diff --git a/lib/Makefile b/lib/Makefile index ed696a878ae4cc8bdbb0292731f8e2e69cbbe32d..8f5b6da81b17cb553c991b1f03f11bcd7f6013b4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -10,8 +10,10 @@ clean: cd c ; make clean cd csharp ; make clean cd java ; make clean + $(MAKE) -C python clean distclean: cd c ; make distclean cd csharp ; make clean cd java ; make clean + $(MAKE) -C python clean diff --git a/lib/RAPID/README b/lib/RAPID/README index f296d4d0de253a5758efb8ce408c759c247f9c79..0e45345ca329482257fdef1d75d46c5f49026776 100644 --- a/lib/RAPID/README +++ b/lib/RAPID/README @@ -34,7 +34,7 @@ or $ VAR Encoder e; $ Init_Encoder e, st; This will read/write the version of LabComm to ensure compatibility, current -version is "LabComm2013". +version is "LabComm20141009". # Initiate the labcomm samples: LabComm trusts the application to manage each sample. It requests the samples, diff --git a/lib/c/Makefile b/lib/c/Makefile index 43e892ff1f7d3b5c942083e287c5d227c75636d9..ed97fc48edd6335cb4300ac48fc0f3d91d3aaf6a 100644 --- a/lib/c/Makefile +++ b/lib/c/Makefile @@ -1,6 +1,6 @@ ## Macros UNAME_S=$(shell uname -s) -ALL_DEPS=liblabcomm.a liblabcomm.so.1 liblabcomm2006.a liblabcomm2006.so.1 liblabcomm2013.a liblabcomm2013.so.1 +ALL_DEPS=liblabcomm.a liblabcomm.so.1 liblabcomm2006.a liblabcomm2006.so.1 liblabcomm20141009.a liblabcomm20141009.so.1 ifeq ($(UNAME_S),Linux) CFLAGS=-std=c99 -g -Wall -Werror -O3 -I. -Itest -I2006 @@ -95,10 +95,10 @@ liblabcomm.a: $(OBJS) $(OBJS2006) liblabcomm.so.1: $(OBJS:%.o=%.pic.o) $(OBJS2006:%.o=%.pic.o) $(call MAKESHARED,$@,$@,$^) -liblabcomm2013.a: $(OBJS) +liblabcomm20141009.a: $(OBJS) ar -r $@ $^ -liblabcomm2013.so.1: $(OBJS:%.o=%.pic.o) +liblabcomm20141009.so.1: $(OBJS:%.o=%.pic.o) $(call MAKESHARED,$@,$@,$^) liblabcomm2006.a: $(OBJS2006) @@ -178,8 +178,8 @@ distclean: clean $(RM) liblabcomm.a $(RM) liblabcomm2006.so.1 $(RM) liblabcomm2006.a - $(RM) liblabcomm2013.so.1 - $(RM) liblabcomm2013.a + $(RM) liblabcomm20141009.so.1 + $(RM) liblabcomm20141009.a # Extra dependencies $(TEST_DIR)/test_labcomm_basic_type_encoding.o: labcomm_private.h diff --git a/lib/c/labcomm.c b/lib/c/labcomm.c index ed4e61779d2d21eb2025fd7f16ca6430e26ec0de..3ec7d88b2a6a263e0c16c5a4608aca0b87d654b6 100644 --- a/lib/c/labcomm.c +++ b/lib/c/labcomm.c @@ -37,7 +37,7 @@ #include "labcomm_ioctl.h" #include "labcomm_dynamic_buffer_writer.h" -#define LABCOMM_VERSION "LabComm2013" +#define LABCOMM_VERSION "LabComm20141009" /* Unwrapping reader/writer functions */ #define UNWRAP_ac(rw, ac, ...) ac diff --git a/lib/c/labcomm_decoder.c b/lib/c/labcomm_decoder.c index 0de42d3d1be477be7ee46bd60788c853a2b2c512..ee433d9a0f4277524247a5d6aab5dfc6de3643d7 100644 --- a/lib/c/labcomm_decoder.c +++ b/lib/c/labcomm_decoder.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define LABCOMM_VERSION "LabComm2013" +#define LABCOMM_VERSION "LabComm20141009" #include <errno.h> #include "labcomm.h" @@ -166,7 +166,7 @@ out: return result; } -static int decode_typedef_or_sample(struct labcomm_decoder *d, int kind) +static int decode_sample(struct labcomm_decoder *d, int kind) { int result; @@ -310,8 +310,8 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d) result = d->reader->error; goto out; } - if (remote_index == LABCOMM_TYPEDEF || remote_index == LABCOMM_SAMPLE) { - result = decode_typedef_or_sample(d, remote_index); + if (remote_index == LABCOMM_SAMPLE) { + result = decode_sample(d, remote_index); } else { int *local_index; struct call_handler_context wrap = { diff --git a/lib/c/labcomm_encoder.c b/lib/c/labcomm_encoder.c index 92307428dc877e539d9c0dfbcb6275508adb99a8..3983e43fbf7d4941182219f065bd4a4e9dfab89d 100644 --- a/lib/c/labcomm_encoder.c +++ b/lib/c/labcomm_encoder.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define LABCOMM_VERSION "LabComm2013" +#define LABCOMM_VERSION "LabComm20141009" #include <errno.h> #include "labcomm.h" diff --git a/lib/csharp/se/lth/control/labcomm/LabComm.cs b/lib/csharp/se/lth/control/labcomm/LabComm.cs index 93efe6813aa68f97dcdef394e2eaef9931973901..32ec6cfdafc359001f2ddb956d4b15749f531dbb 100644 --- a/lib/csharp/se/lth/control/labcomm/LabComm.cs +++ b/lib/csharp/se/lth/control/labcomm/LabComm.cs @@ -2,7 +2,7 @@ namespace se.lth.control.labcomm { public class LabComm { - public const string VERSION = "LabComm2013"; + public const string VERSION = "LabComm20141009"; /* * Predeclared aggregate type indices diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs b/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs index 2d6b8d4126daac41875ea3864e6eedfdf91bb54a..76fa4e9e3069cd20def11cc09587e7af314cdb72 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs +++ b/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs @@ -25,7 +25,6 @@ namespace se.lth.control.labcomm { while (!done) { int tag = decodePacked32(); switch (tag) { - case LabComm.TYPEDEF: case LabComm.SAMPLE: { int index = decodePacked32(); String name = decodeString(); diff --git a/lib/java/Makefile b/lib/java/Makefile index 48204f46e11adc1a71d1cff40ace66d2576f8cd7..f3f60c275c4918df19d34603b69a0c03896e2d46 100644 --- a/lib/java/Makefile +++ b/lib/java/Makefile @@ -13,13 +13,13 @@ MODULES=LabCommDispatcher \ LabCommReader \ WriterWrapper -all: labcomm.jar labcomm2013.jar labcomm2006.jar +all: labcomm.jar labcomm20141009.jar labcomm2006.jar labcomm.jar: gen/JAVAC echo $@ cd gen ; jar cf ../$@ se/lth/control/labcomm/*.class se/lth/control/labcomm2006/*.class -labcomm2013.jar: gen/JAVAC +labcomm20141009.jar: gen/JAVAC echo $@ cd gen ; jar cf ../$@ se/lth/control/labcomm/*.class @@ -38,5 +38,5 @@ gen/JAVAC: $(MODULES:%=se/lth/control/labcomm/%.java) $(MODULES:%=se/lth/control .PHONY: clean clean: - rm -rf labcomm.jar labcomm2006.jar labcomm2013.jar gen + rm -rf labcomm.jar labcomm2006.jar labcomm20141009.jar gen diff --git a/lib/java/se/lth/control/labcomm/LabComm.java b/lib/java/se/lth/control/labcomm/LabComm.java index 99c74c201a8f7dee87776f23e534000617679aa7..0a89ea39579c28cab1122dc3070f9340968edfcf 100644 --- a/lib/java/se/lth/control/labcomm/LabComm.java +++ b/lib/java/se/lth/control/labcomm/LabComm.java @@ -2,7 +2,7 @@ package se.lth.control.labcomm; public class LabComm { - public static final String VERSION = "LabComm2013"; + public static final String VERSION = "LabComm20141009"; /* * Predeclared aggregate type indices diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java b/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java index 0fe0e8261dee9977ccb510b814408796f1489ab5..605487590d653b714dfd64f77f18a58c02331e68 100644 --- a/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java +++ b/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java @@ -26,7 +26,6 @@ public class LabCommDecoderChannel implements LabCommDecoder { while (!done) { int tag = decodePacked32(); switch (tag) { - case LabComm.TYPEDEF: case LabComm.SAMPLE: { int index = decodePacked32(); String name = decodeString(); diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java b/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java index d0767b03cc05b93863cc361095410c3d4468a1df..28077b58a543b113117b9cf217cc2ce91f65a856 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java +++ b/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java @@ -20,7 +20,6 @@ public class LabCommDecoderChannel implements LabCommDecoder { while (!done) { int tag = decodePacked32(); switch (tag) { - case LabComm.TYPEDEF: case LabComm.SAMPLE: { int index = decodePacked32(); String name = decodeString(); @@ -135,7 +134,7 @@ public class LabCommDecoderChannel implements LabCommDecoder { } /** - method for API harmonization with labcomm2013. + method for API harmonization with labcomm20141009. Labcomm2006 encodes lengths etc as 32 bit ints. */ public int decodePacked32() throws IOException { diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java b/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java index 6cd8804240b57698a23dbc117ded34118dd1dadd..173ff50a30359b585c70d23e4631e719e3144360 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java +++ b/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java @@ -94,7 +94,7 @@ public class LabCommEncoderChannel implements LabCommEncoder { } /** - method for API harmonization with labcomm2013. + method for API harmonization with labcomm20141009. Labcomm2006 encodes lengths etc as 32 bit ints. */ public void encodePacked32(long value) throws IOException { diff --git a/lib/python/Makefile b/lib/python/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7798ea9c77f5297ce46b92db52dce08cb5022453 --- /dev/null +++ b/lib/python/Makefile @@ -0,0 +1,5 @@ +clean: + find . -name '*.pyc' -exec rm {} \; + +distclean: + find . -name '*.pyc' -exec rm {} \; diff --git a/lib/python/labcomm/LabComm.py b/lib/python/labcomm/LabComm.py index ad9957982bcd37558660674abe67088a920baeea..5f8ab1322a1532400002fa145dd7365a55796c9f 100644 --- a/lib/python/labcomm/LabComm.py +++ b/lib/python/labcomm/LabComm.py @@ -96,14 +96,41 @@ import types import struct as packer -#VERSION = "LabComm2013" +DEFAULT_VERSION = "LabComm20141009" # Version testing def sendVersionString(version): - return version == "LabComm2013" + return version in [ "LabComm2013", "LabComm20141009" ] def usePacked32(version): - return version == "LabComm2013" + return version in [ "LabComm2013", "LabComm20141009" ] + +def usePacketLength(version): + return version in [ "LabComm20141009" ] + +class length_encoder: + def __init__(self, encoder): + import sys + self.encoder = encoder + self.data = "" + print>>sys.stderr, "INIT", self, self.encoder, self.encoder.writer + + def start(self, encoder, version): + self.version = version + pass + + def write(self, data): + import sys + print>>sys.stderr, [ data ] + print>>sys.stderr, "WRITE", self, self.encoder, self.encoder.writer + + def __enter__(self): + return Encoder(self) + + def __exit__(self, type, value, traceback): + print>>sys.stderr, "EXIT", value + + pass i_TYPEDEF = 0x01 i_SAMPLE = 0x02 @@ -269,6 +296,7 @@ class sample_or_typedef(object): self.decl = decl def encode_decl_tail(self, encoder): +# with length_encoder(encoder) as e: encoder.encode_type_number(self) encoder.encode_string(self.name) encoder.encode_type_number(self.decl) @@ -298,6 +326,12 @@ class sample_or_typedef(object): class sample(sample_or_typedef): def encode_decl(self, encoder): +# with length_encoder(encoder) as e: +# e.encode_type(i_SAMPLE) +# self.encode_decl_tail(e) + import sys + print>>sys.stderr, "AFTER" + encoder.encode_type(i_SAMPLE) self.encode_decl_tail(encoder) @@ -553,7 +587,7 @@ class Codec(object): class Encoder(Codec): - def __init__(self, writer, version="LabComm2013"): + def __init__(self, writer, version=DEFAULT_VERSION): super(Encoder, self).__init__() self.writer = writer self.version = version @@ -584,7 +618,7 @@ class Encoder(Codec): def encode_packed32(self, v): #if usePacked32(self.version) : - if self.version == "LabComm2013" : + if self.version in [ "LabComm2013", "LabComm20141009" ]: v = v & 0xffffffff tmp = [ v & 0x7f ] v = v >> 7 @@ -634,7 +668,7 @@ class Encoder(Codec): # self.pack("!i%ds" % len(s), len(s), s) class Decoder(Codec): - def __init__(self, reader, version="LabComm2013"): + def __init__(self, reader, version=DEFAULT_VERSION): super(Decoder, self).__init__() self.reader = reader self.version = version @@ -659,7 +693,7 @@ class Decoder(Codec): value = None index = self.decode_type_number() decl = self.index_to_decl[index] - if index == i_TYPEDEF or index == i_SAMPLE: + if index == i_SAMPLE: decl = decl.decode_decl(self) else: value = decl.decode(self) @@ -680,7 +714,7 @@ class Decoder(Codec): return result def decode_packed32(self): - if self.version == "LabComm2013" : + if self.version in [ "LabComm2013", "LabComm20141009" ] : result = 0 while True: tmp = self.decode_byte()