From: Jannik Zander Date: Sat, 11 Jun 2016 06:56:49 +0000 (+0200) Subject: Remove genilog.py X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=98680903db27c26d01bf74ba947ebde39bce0a10;p=dotfiles.git Remove genilog.py --- diff --git a/.local/bin/genilog.py b/.local/bin/genilog.py deleted file mode 100755 index cb32c1a..0000000 --- a/.local/bin/genilog.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python3 - -#import serial -import fileinput -import matplotlib.pyplot as plt -import numpy as pl - -def readbyte(line): - str=line[0:2].strip() - byte=0 - if str!='': - byte=int(str,16) - tail=line[2:].strip() - return byte,tail - -def process_head(line): - ds,line=readbyte(line) - le,line=readbyte(line) - da,line=readbyte(line) - sa,line=readbyte(line) - typ="Error" - if ds==0x27: typ="Data Request" - if ds==0x27 and da==0xFE: typ="Connection Request" - if ds==0x27 and da==0xFF: typ="Broadcast Request" - if ds==0x26: typ="Data Message" - if ds==0x26 and da==0xF7: typ="Multicast Message" - if ds==0x24: typ="Data Reply" - return ds,le,da,sa,typ - -def process_pdu(line): - cl,line=readbyte(line) - cl=cl&0xF - le,line=readbyte(line) - os=(le&0xC0)>>6 - le=le&0x3F - apdu=line[0:3*le] - line=line[3*le:] - return cl,os,le,apdu,line - -def process_crc(line): - crc=line - return crc - -def process_isok(line): - isok=line - return line - -def process_timestamp(line): - timestamp=int(line) - return timestamp - -def process(line): - global timezero - global t - global ref - line=line[2:] - packet=line.split(" - ") - n=len(packet) - if n>0: - print("Header:",packet[0]) - ds,le,da,sa,typ=process_head(packet[0]) - print("Type:",typ,"Length",le,"Destination",da,"Source",sa) - if da==0xF7: - if n>1: - print("Payload:",packet[1]) - pdu=packet[1] - while len(pdu)>0: - cl,os,ale,apdu,pdu=process_pdu(pdu) - print("Class:",cl,"Operation:",os,"Length:",ale,"APDU:",apdu) - if cl==5: - id=[0]*4 - ref=[0]*4 - id[0],apdu=readbyte(apdu) - ref[0],apdu=readbyte(apdu) - id[1],apdu=readbyte(apdu) - ref[1],apdu=readbyte(apdu) - id[2],apdu=readbyte(apdu) - ref[2],apdu=readbyte(apdu) - id[3],apdu=readbyte(apdu) - ref[3],apdu=readbyte(apdu) - for i in range(0,4): - print("Id:",id[i],"Ref:",ref[i]) - 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()) - if timezero==0: - timezero=timestamp - t=t + [timestamp-timezero] -# ref[0].append([ref1[0]]) -# ref[1].append([ref1[1]]) -# ref[2].append([ref1[2]]) -# ref[3].append([ref1[3]]) - return - -timezero=0 -t=[] -ref=[] -ref.append([]) -ref.append([]) -ref.append([]) -ref.append([]) -for line in fileinput.input(): - process(line) - print("------------------------------------------------") - -fig=plt.figure() -plt.plot(t,ref[0]) -plt.plot(t,ref[1]) -plt.plot(t,ref[2]) -plt.plot(t,ref[3]) -plt.show() -plt.close(fig) -