alias startvnc4='vnc4server -geometry 1870x980 -depth 24'
#alias python='/usr/local/bin/python3'
alias git_local='git --git-dir=.git_local'
+
+# alias for genibus
+alias gf='gf.py'
+alias com1='GENIsnus_1_lin_pr_tgm.exe COM1 9600 log 5'
+alias com2='GENIsnus_1_lin_pr_tgm.exe COM2 9600 log 5'
+alias com3='GENIsnus_1_lin_pr_tgm.exe COM3 9600 log 5'
+alias com4='GENIsnus_1_lin_pr_tgm.exe COM4 9600 log 5'
+alias com5='GENIsnus_1_lin_pr_tgm.exe COM5 9600 log 5'
+alias com6='GENIsnus_1_lin_pr_tgm.exe COM6 9600 log 5'
+alias com7='GENIsnus_1_lin_pr_tgm.exe COM7 9600 log 5'
+alias com8='GENIsnus_1_lin_pr_tgm.exe COM8 9600 log 5'
--- /dev/null
+#!/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)
+
#FIXME: does not work in general
info=line.split(":")
try:
- timestamp=int(info[1].strip())/1000
+ timestamp=int(info[1].strip())
print(timestamp)
return timestamp
except:
# Process received data
typ,ds,le,da,sa,line=process_head(line)
numbytes=le-2
+ print("head",numbytes)
if da==0xF7:
while numbytes>0:
cl,os,ale,line=process_apdu(line)
numbytes=numbytes-2
+ print("apdu",numbytes)
if cl==5:
id,val,line=process_class5(line,int(ale/2))
numbytes=numbytes-ale
+ print("cl5",numbytes)
# Debugging info....
- t=t+[timestamp-timezero]
+ t=t+[(timestamp-timezero)/1000]
master=master+[1+(sa-31)/10]
for i in range(4):
speed[i]=speed[i]+[val[i]/254]
else:
line=line[ale*3:]
numbytes=numbytes-ale
+ print("clxxx",numbytes)
crc=process_crc(line)
return