]> git.zndr.dk Git - dotfiles.git/commitdiff
Add class 10 object
authorJannik Zander <jannikz@gmail.com>
Sun, 12 Jun 2016 10:00:40 +0000 (12:00 +0200)
committerJannik Zander <jannikz@gmail.com>
Sun, 12 Jun 2016 10:00:40 +0000 (12:00 +0200)
.local/bin/gf.py

index 11d58d5942e6bd4780c6649acc00aae1f7bb5702..a3368edc56e466df79609374e61ae694a8cd6367 100755 (executable)
@@ -117,7 +117,6 @@ def process_data(line,le,size1,size2):
       print("Value:",val[i])
   return ids,val,line
 
-
 # section: process_string {{{1
 ######################################################
 def process_string(line,le,size1,size2):
@@ -128,21 +127,32 @@ def process_string(line,le,size1,size2):
   for i in range(0,size2):
     val[i],line=readbyte(line)
   string=''.join(chr(i) for i in val)
-
+  string=string[:-1]
   if size1>0 and size2>0:
-    print("Id:",ids,"Value:",val,"String:",repr(string[:-1]))
+    print("Id:",ids,"Value:",val,"String:",repr(string))
   elif size1>0:
     print("Id:",ids)
   elif size2>0:
-    print("Value:",val,"String:",repr(string[:-1]))
-  return ids,string,line
+    print("Value:",val,"String:",repr(string))
+  return ids,val,line
 
 # section: process_object {{{1
 ######################################################
-def process_object(line,le):
+def process_object(line,le,size1,size2):
+  ids=[0]*size1
+  val=[0]*size2
+  if size1>0:
+    ids,line=readbyte(line)
+  for i in range(0,size2):
+    val[i],line=readbyte(line)
+  if size1>0 and size2>0:
+    print("Id:",ids,"Value:",val)
+  elif size1>0:
+    print("Id:",ids)
+  elif size2>0:
+    print("Value:",val)
   return ids,val,line
 
-
 # section: process_crc {{{-1
 ######################################################
 def process_crc(line):
@@ -224,8 +234,12 @@ def process_telegram(line):
     elif cl==7 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET:
       ids7,val7,line=process_string(line,ale,1,ale-1)
     # section: class 10 {{{2
-#    elif cl==10:
-#      ids10,val10,line=process_object(line,ale)
+    elif cl==10 and ds==gf.DATA_REQUEST and os==gf.OS_GET:
+      ids10,val10,line=process_object(line,ale,1,0)
+    elif cl==10 and ds==gf.DATA_REPLY and os==gf.OS_GET:
+      ids10,val10,line=process_object(line,ale,0,ale)
+    elif cl==10 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET:
+      ids10,val10,line=process_object(line,ale,1,ale-1)
     # section: class 11 {{{2
     elif cl==11 and ds==gf.DATA_REQUEST and os==gf.OS_GET:
       ids11,val11,line=process_data(line,ale,1,0)