From 475fc86451ecc6d7336bb85b3ba2f31b35100d45 Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Tue, 14 Jun 2016 20:33:59 +0200 Subject: [PATCH] Fix for more timestamps --- .local/bin/gf.py | 36 +++++++++--------------------------- .local/bin/gf_config.py | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.local/bin/gf.py b/.local/bin/gf.py index 2fd711c..cce7fb9 100755 --- a/.local/bin/gf.py +++ b/.local/bin/gf.py @@ -58,27 +58,14 @@ def readtimestamp(line): line=info[0] else: try: - h=int(info[0].split(' ')[1]) + h=int(info[0][-2:]) m=int(info[1]) - s=info[2].split('.') - ts=datetime.combine(date.today(),time(h,m,int(s[0]),int(s[1])*1000)) - line=info[3][1:] + s=int(info[2][:2]) + u=int(info[2][3:6])*1000 + ts=datetime.combine(date.today(),time(h,m,s,u)) + line=''.join(line.split(":")[2:])[7:] except: pass - -# if timestamp>1e9: # 2001-09-09 -# pass -# else: -# try: -# h=int(info[0].split(' ')[1]) -# m=int(info[1]) -# s=info[2].split('.') -# u=s[1].split(' ') -# ts=datetime.combine(date.today(),time(h,m,int(s[0]),int(u[0])*1000)) -# line=s[1][4:] -# except: -# pass -# print(ts) return ts,line @@ -86,6 +73,7 @@ def readtimestamp(line): ###################################################### def readbyte(line): byte=-1 + line=line.strip() while byte==-1 and len(line)>0: try: byte=int(line[0:2],16) @@ -131,7 +119,7 @@ def process_apdu(line): le,line=readbyte(line) os=(le&0xC0)>>6 le=le&0x3F - print("Class:",cl,"Operation:",os,"Length:",le) + print(gf.operation[os],"Class:",cl,"Length:",le) return cl,os,le,line # section: process_data {{{1 @@ -147,15 +135,9 @@ def process_data(line,le,size1,size2): tmp,line=readbyte(line) val[i]=(val[i]<<8)+tmp if size1>0 and size2>0: - if gf.params[cl][ids[i]] != "": - print(gf.params[cl][ids[i]],"=",val[i]) - else: - print("Id:",ids[i],"=",val[i]) + print("Id:",ids[i],repr(gf.params[cl][ids[i]]),"=",val[i]) elif size1>0: - if gf.params[cl][ids[i]] != "": - print(gf.params[cl][ids[i]]) - else: - print("Id:",ids[i]) + print("Id:",ids[i],repr(gf.params[cl][ids[i]])) elif size2>0: print("=",val[i]) return ids,val,line diff --git a/.local/bin/gf_config.py b/.local/bin/gf_config.py index 225aedb..e48b60a 100644 --- a/.local/bin/gf_config.py +++ b/.local/bin/gf_config.py @@ -5,13 +5,24 @@ DATA_REQUEST=0x27 DATA_MESSAGE=0x26 DATA_REPLY=0x24 + OS_GET=0 OS_SET=2 OS_INFO=3 +operation=[""]*4 +operation[OS_GET]="GET" +operation[OS_SET]="SET" +operation[OS_INFO]="INFO" + ACK_OK=0 -ACK_CLASS_UNKNOWN=1 +ACK_CL_UNKNOWN=1 ACK_ID_UNKNOWN=2 -ACK_OPERATION_UNKNOWN=3 +ACK_OP_UNKNOWN=3 +ack=[""]*4 +ack[ACK_OK]="ACK_OK" +ack[ACK_CL_UNKNOWN]="ACK_CLASS_UNKNOWN" +ack[ACK_ID_UNKNOWN]="ACK_ID_UNKNOWN" +ack[ACK_OP_UNKNOWN]="ACK_OPERATION_UNKNOWN" class0=[""]*4 class1=[] -- 2.43.0