]> git.zndr.dk Git - dotfiles.git/commitdiff
Decode cl5 speed ref
authorJannik ZANDER <jzander@grundfos.com>
Wed, 8 Jun 2016 15:45:45 +0000 (17:45 +0200)
committerJannik ZANDER <jzander@grundfos.com>
Wed, 8 Jun 2016 15:45:45 +0000 (17:45 +0200)
.config/profile/environ.sh
.local/bin/genilog.py

index b4cf297b79877109beb68afc83377c50a4920dac..f6b2624a54fbae6c9249b5d4db1df89a69a7462b 100644 (file)
@@ -10,7 +10,7 @@ export PAGER='less -X'
 export MANPAGER="less -X"
 export BROWSER='lynx -vikeys -use_mouse'
 
-# Larger bash history (allow 32³ entries; default is 500)
+# Larger bash history (allow 32³ entries; default is 500)
 export HISTSIZE=32768;
 export HISTFILESIZE=$HISTSIZE;
 export HISTCONTROL=ignoreboth;
@@ -19,7 +19,8 @@ export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help";
 
 # Prefer US language and UTF-8
 export LANG="en_US.UTF-8";
-export LC_ALL="en_DK.UTF-8";
+export LC_ALL="en_US.UTF-8";
+#export LC_ALL="en_DK.UTF-8";
 #export LC_NUMERIC=en_DK.UTF-8
 #export LC_TIME=en_DK.UTF-8
 #export LC_MONETARY=en_DK.UTF-8
index e28bbf030e411a58d3993656f94d8ef9a77bcff4..6270cfa43bb7688e7b5c6ee8d6490cdc38d95d72 100644 (file)
@@ -3,51 +3,69 @@
 #import serial
 import fileinput
 
-def process_header(line):
-  str=""
+def process_head(line):
   ds=line[0:2]
   le=line[3:5]
   da=line[6:8]
   sa=line[9:11]
-  if ds=="27":              str="Data Request:  "
-  if ds=="27" and da=="FE": str="Connection Req:"
-  if ds=="27" and da=="FF": str="Broadcast Req: "
-  if ds=="27" and da=="F7": str="Multicast Req:"
-  if ds=="26":              str="Data Message:  "
-  if ds=="24":              str="Data Reply:    "
-  print(str,"payload length:",le,"receiver:",da,"sender:",sa)
-  return
+  typ=""
+  if ds=="27":              typ="Data Request"
+  if ds=="27" and da=="FE": typ="Connection Request"
+  if ds=="27" and da=="FF": typ="Broadcast Request"
+  if ds=="26":              typ="Data Message"
+  if ds=="26" and da=="F7": typ="Multicast Message"
+  if ds=="24":              typ="Data Reply"
+  return ds,le,da,sa,typ
 
-def process_payload(line):
-  print(line)
-  return
+def process_pdu(line):
+  cl0=int(line[0:2],16)&0xF
+  os0=(int(line[3:5],16)&0xC0)>>6
+  le0=int(line[3:5],16)&0x3F
+  apdu0=line[6:6+3*le0]
+  line1=line[6+3*le0:]
+  cl1=int(line1[0:2],16)&0xF
+  os1=(int(line1[3:5],16)&0xC0)>>6
+  le1=int(line1[3:5],16)&0x3F
+  apdu1=line1[6:6+3*le1]
+  return cl0,os0,le0,apdu0,cl1,os1,le1,apdu1
 
 def process_crc(line):
-  print(line)
-  return
+  crc=line
+  return crc
 
-def process_iscrcok(line):
-  print(line)
-  return
+def process_isok(line):
+  isok=line
+  return line
 
 def process_timestamp(line):
-  print(line)
-  return
+  timestamp=line
+  return timestamp
 
 def process(line):
   # parse line
   line=line[2:]
   packet=line.split(" - ")
   n=len(packet)
-  if n>0: process_header(packet[0])
-#  if n>1: process_payload(packet[1])
-#  if n>2: process_crc(packet[2])
-  if n>3:
-    info=packet[3].split("   : ")
-    m=len(info)
-#    if m>0: process_iscrcok(info[0])
-#    if m>1: process_timestamp(info[1].strip())
-  print("--------------------------------------------------------------------------------------------------------")
+
+  if n>0:
+    ds,le,da,sa,typ=process_head(packet[0])
+  if da=="F7":
+    if n>1:
+      cl0,os0,le0,apdu0,cl1,os1,le1,apdu1=process_pdu(packet[1])
+    if n>2:
+      crc=process_crc(packet[2])
+    if n>3:
+      info=packet[3].split("   : ")
+      m=len(info)
+      if m>0:
+        isok=process_isok(info[0])
+      if m>1:
+        timestamp=process_timestamp(info[1].strip())
+    print("--------------------------------------------------------------------------------------------------------")
+    print("Payload:",packet[1])
+    print("Type:",typ)
+    print("Class:",cl0,"Operation:",os0,"Length:",le0,"APDU:",apdu0)
+    print("Class:",cl1,"Operation:",os1,"Length:",le1,"APDU:",apdu1)
   return
 
 for line in fileinput.input():