From: Jannik ZANDER Date: Wed, 8 Jun 2016 11:18:25 +0000 (+0200) Subject: Add genilog.py X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=131f055d1d95750ae2262e5de44e1cb9d5a51914;p=dotfiles.git Add genilog.py --- diff --git a/.config/bash/rc/aliases b/.config/bash/rc/aliases index 6ed654f..7b05bdb 100644 --- a/.config/bash/rc/aliases +++ b/.config/bash/rc/aliases @@ -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 index 0000000..e28bbf0 --- /dev/null +++ b/.local/bin/genilog.py @@ -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) +