From 4956b946c55fa485d176d2e43f0fc1a2f874c64f Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Mon, 1 Jun 2015 17:11:43 +0200
Subject: [PATCH] Changed protocol version to 'LabComm2014.v1'

---
 lib/c/2014/labcomm2014_decoder.c              |  2 +-
 lib/c/2014/labcomm2014_encoder.c              |  2 +-
 .../test/test_labcomm_generated_encoding.c    |  4 ++--
 .../2014/test/test_labcomm_renaming_encoder.c |  4 ++--
 .../se/lth/control/labcomm2014/Constant.cs    |  2 +-
 .../se/lth/control/labcomm2014/Constant.java  |  2 +-
 lib/python/labcomm2014/LabComm.py             | 19 +++++++------------
 7 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/lib/c/2014/labcomm2014_decoder.c b/lib/c/2014/labcomm2014_decoder.c
index b1cfcd8..5b64182 100644
--- a/lib/c/2014/labcomm2014_decoder.c
+++ b/lib/c/2014/labcomm2014_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 CURRENT_VERSION "LabComm2014"
+#define CURRENT_VERSION "LabComm2014.v1"
 
 #include <errno.h>
 #include "labcomm2014.h"
diff --git a/lib/c/2014/labcomm2014_encoder.c b/lib/c/2014/labcomm2014_encoder.c
index c49798d..59a34ef 100644
--- a/lib/c/2014/labcomm2014_encoder.c
+++ b/lib/c/2014/labcomm2014_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 CURRENT_VERSION "LabComm2014"
+#define CURRENT_VERSION "LabComm2014.v1"
 
 #include <errno.h>
 #include "labcomm2014.h"
diff --git a/lib/c/2014/test/test_labcomm_generated_encoding.c b/lib/c/2014/test/test_labcomm_generated_encoding.c
index 868b1b6..d9c463b 100644
--- a/lib/c/2014/test/test_labcomm_generated_encoding.c
+++ b/lib/c/2014/test/test_labcomm_generated_encoding.c
@@ -206,8 +206,8 @@ int main(void)
     labcomm2014_default_error_handler,
     labcomm2014_default_memory,
     labcomm2014_pthread_scheduler_new(labcomm2014_default_memory));
-  EXPECT({ 0x01, 0x0c, 0x0b, 
-           'L', 'a', 'b', 'C', 'o', 'm', 'm', '2','0', '1', '4' });
+  EXPECT({ 0x01, 0x0f, 0x0e, 
+        'L', 'a', 'b', 'C', 'o', 'm', 'm', '2','0', '1', '4', '.', 'v', '1' });
 
   labcomm2014_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
   /* Register twice to make sure that only one registration gets encoded */
diff --git a/lib/c/2014/test/test_labcomm_renaming_encoder.c b/lib/c/2014/test/test_labcomm_renaming_encoder.c
index f5bbd88..70ff4a0 100644
--- a/lib/c/2014/test/test_labcomm_renaming_encoder.c
+++ b/lib/c/2014/test/test_labcomm_renaming_encoder.c
@@ -228,8 +228,8 @@ static int do_test(int argc, char *argv[])
                                             registry,
                                             labcomm2014_renaming_suffix,
                                             ".s");
-  EXPECT({ 0x01, 0x0c, 0x0b, 
-           'L', 'a', 'b', 'C', 'o', 'm', 'm', '2','0', '1', '4' });
+  EXPECT({ 0x01, 0x0f, 0x0e, 
+        'L', 'a', 'b', 'C', 'o', 'm', 'm', '2','0', '1', '4', '.', 'v', '1' });
 
   labcomm2014_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
   /* Register twice to make sure that only one registration gets encoded */
diff --git a/lib/csharp/se/lth/control/labcomm2014/Constant.cs b/lib/csharp/se/lth/control/labcomm2014/Constant.cs
index 19f18ad..92d3f62 100644
--- a/lib/csharp/se/lth/control/labcomm2014/Constant.cs
+++ b/lib/csharp/se/lth/control/labcomm2014/Constant.cs
@@ -2,7 +2,7 @@ namespace se.lth.control.labcomm2014 {
 
   public class Constant {
 
-    public const string CURRENT_VERSION = "LabComm2014";
+    public const string CURRENT_VERSION = "LabComm2014.v1";
 
     /*
      * Allowed packet tags
diff --git a/lib/java/se/lth/control/labcomm2014/Constant.java b/lib/java/se/lth/control/labcomm2014/Constant.java
index f46018a..8aed416 100644
--- a/lib/java/se/lth/control/labcomm2014/Constant.java
+++ b/lib/java/se/lth/control/labcomm2014/Constant.java
@@ -2,7 +2,7 @@ package se.lth.control.labcomm2014;
 
 public class Constant {
 
-  public static final String CURRENT_VERSION = "LabComm2014";
+  public static final String CURRENT_VERSION = "LabComm2014.v1";
 
   /*
    * Allowed packet tags
diff --git a/lib/python/labcomm2014/LabComm.py b/lib/python/labcomm2014/LabComm.py
index 8d05a05..4b536ac 100644
--- a/lib/python/labcomm2014/LabComm.py
+++ b/lib/python/labcomm2014/LabComm.py
@@ -169,7 +169,7 @@
 import types
 import struct as packer
 
-DEFAULT_VERSION = "LabComm2014"
+DEFAULT_VERSION = "LabComm2014.v1"
 
 # Allowed packet tags
 i_VERSION     = 0x01
@@ -197,7 +197,7 @@ i_SAMPLE  = 0x28
 
 # Version testing
 def usePacketLength(version):
-    return version in [ None, "LabComm2014" ]
+    return version in [ None, DEFAULT_VERSION ]
 
 class length_encoder:
     def __init__(self, encoder):
@@ -774,12 +774,12 @@ class Encoder(Codec):
         super(Encoder, self).__init__(codec)
         self.writer = writer
         self.version = version
-        if self.version in [ "LabComm2014" ]:
+        if self.version ==  DEFAULT_VERSION:
             self.encode_type(i_VERSION)
             with length_encoder(self) as e:
                 e.encode_string(version)
-        elif self.version in [ None,  "LabComm2006" ]:
-            pass
+        elif self.version == None:
+            pass # Don't send version on a length encoder
         else:
             raise Exception("Unsupported labcomm version %s" % self.version)    
 
@@ -825,7 +825,7 @@ class Encoder(Codec):
             decl.encode_decl(self)
             
     def encode_packed32(self, v):
-        if self.version in [ None, "LabComm2014" ]:
+        if self.version in [ None, DEFAULT_VERSION ]:
             v = v & 0xffffffff
             tmp = [ v & 0x7f ]
             v = v >> 7
@@ -834,9 +834,6 @@ class Encoder(Codec):
                 v = v >> 7
             for c in reversed(tmp):
                 self.encode_byte(c) 
-        elif self.version == "LabComm2006" :
-            v = v & 0xffffffff
-            self.encode_int(v)
         else :
             raise Exception("Unsupported labcomm version %s" % self.version)
 
@@ -961,7 +958,7 @@ class Decoder(Codec):
         return result
     
     def decode_packed32(self):
-        if self.version in [ "LabComm2013", "LabComm2014" ] :
+        if self.version in [ DEFAULT_VERSION ] :
             result = 0
             while True:
                 tmp = self.decode_byte()
@@ -969,8 +966,6 @@ class Decoder(Codec):
                 if (tmp & 0x80) == 0:
                     break
             return result
-        elif self.version == "LabComm2006" :
-            return self.decode_int()
         else :
             raise Exception("Unsupported labcomm version %s" % self.version)
 
-- 
GitLab