From 9bfa7c1467189f2b8eab1c8b588aeab130e7314b Mon Sep 17 00:00:00 2001
From: Sven Gestegard Robertz <sven.robertz@cs.lth.se>
Date: Sat, 25 Oct 2014 15:15:09 +0200
Subject: [PATCH] c encoding, java skipping pragma
---
examples/user_types/example_encoder.c | 12 ++++++------
lib/c/labcomm.h | 4 ++++
lib/c/labcomm_encoder.c | 3 ++-
lib/java/se/lth/control/labcomm/DecoderChannel.java | 6 ++++++
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/examples/user_types/example_encoder.c b/examples/user_types/example_encoder.c
index fb8f97a..cc70bbb 100644
--- a/examples/user_types/example_encoder.c
+++ b/examples/user_types/example_encoder.c
@@ -23,15 +23,15 @@ int main(int argc, char *argv[]) {
labcomm_default_scheduler);
labcomm_encoder_register_test_twoLines(encoder);
-#ifdef OLD_METADATA
- struct labcomm_encoder *mdt = labcomm_metadata_begin(encoder,
- &labcomm_signature_test_twoLines);
- labcomm_encoder_register_test_Comment(mdt);
+#ifndef WITHOUT_PRAGMA
+ struct labcomm_encoder *pb = labcomm_pragma_builder_new(encoder,
+ "se.lth.cs.sven.pragma");
+ labcomm_encoder_register_test_Comment(pb);
test_Comment comment;
comment.id = 17;
comment.comment = "This is a metadata comment...";
- labcomm_encode_test_Comment(mdt, &comment);
- labcomm_metadata_end(mdt);
+ labcomm_encode_test_Comment(pb, &comment);
+ labcomm_pragma_send(pb);
#endif
test_twoLines tl;
diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h
index 07ff12d..b543e98 100644
--- a/lib/c/labcomm.h
+++ b/lib/c/labcomm.h
@@ -126,6 +126,10 @@ int labcomm_decoder_ioctl(struct labcomm_decoder *decoder,
...);
/* pragma */
+struct labcomm_encoder *labcomm_pragma_builder_new(
+ struct labcomm_encoder *e,
+ char * pragma_type) ;
+int labcomm_pragma_send(struct labcomm_encoder* e);
struct labcomm_pragma_handler {
//struct labcomm_decoder_registry *registry;
//TODO: implement map (char * pragma_type) --> decoder_registry *
diff --git a/lib/c/labcomm_encoder.c b/lib/c/labcomm_encoder.c
index c7246be..ff38dfe 100644
--- a/lib/c/labcomm_encoder.c
+++ b/lib/c/labcomm_encoder.c
@@ -97,7 +97,8 @@ struct pragma_packet_builder {
struct labcomm_encoder *labcomm_pragma_builder_new(
struct labcomm_encoder *e,
- char * pragma_type) {
+ char * pragma_type)
+{
struct labcomm_writer *dyn_writer = labcomm_dynamic_buffer_writer_new(
e->memory);
struct labcomm_encoder *pb = labcomm_encoder_new(dyn_writer,
diff --git a/lib/java/se/lth/control/labcomm/DecoderChannel.java b/lib/java/se/lth/control/labcomm/DecoderChannel.java
index 9c5b94d..bd2b0dd 100644
--- a/lib/java/se/lth/control/labcomm/DecoderChannel.java
+++ b/lib/java/se/lth/control/labcomm/DecoderChannel.java
@@ -37,6 +37,12 @@ public class DecoderChannel implements Decoder {
ReadBytes(signature, signature_length);
registry.add(index, name, signature);
} break;
+ case Constant.PRAGMA: {
+ System.out.println("Pragma: skipping "+length+" bytes");
+ for(int i=0; i<length; i++) {
+ decodeByte();
+ }
+ } break;
default: {
DecoderRegistry.Entry e = registry.get(tag);
if (e == null) {
--
GitLab