]> git.zndr.dk Git - dotfiles.git/commitdiff
Add genilog.py
authorJannik ZANDER <jzander@grundfos.com>
Wed, 8 Jun 2016 11:18:25 +0000 (13:18 +0200)
committerJannik ZANDER <jzander@grundfos.com>
Wed, 8 Jun 2016 11:18:31 +0000 (13:18 +0200)
.config/bash/rc/aliases
.local/bin/genilog.py [new file with mode: 0644]

index 6ed654f8b9fd2bc3c036e94545c13d59a31475f1..7b05bdb5aa5fa26335a050c62b0b65d3c6388c80 100644 (file)
@@ -88,5 +88,5 @@ alias sumatra='startSumatra.sh'
 alias lynx='lynx -use_mouse -vikeys'
 alias startvnc='vncserver -geometry 1870x980 -depth 24'
 alias startvnc4='vnc4server -geometry 1870x980 -depth 24'
-alias python='/usr/local/bin/python3'
+#alias python='/usr/local/bin/python3'
 alias git_local='git --git-dir=.git_local'
diff --git a/.local/bin/genilog.py b/.local/bin/genilog.py
new file mode 100644 (file)
index 0000000..e28bbf0
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+#import serial
+import fileinput
+
+def process_header(line):
+  str=""
+  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
+
+def process_payload(line):
+  print(line)
+  return
+
+def process_crc(line):
+  print(line)
+  return
+
+def process_iscrcok(line):
+  print(line)
+  return
+
+def process_timestamp(line):
+  print(line)
+  return
+
+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("--------------------------------------------------------------------------------------------------------")
+  return
+
+for line in fileinput.input():
+  process(line)
+