From: Jannik ZANDER Date: Thu, 16 Jun 2016 19:28:14 +0000 (+0200) Subject: Add RF logging to gf.py X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=5e182f75a54c51aa109f54b1d6cd4eae006110e1;p=dotfiles.git Add RF logging to gf.py --- diff --git a/.config/bash/rc/aliases b/.config/bash/rc/aliases index 3667be6..d3c4044 100644 --- a/.config/bash/rc/aliases +++ b/.config/bash/rc/aliases @@ -60,6 +60,7 @@ alias cp='cp -i' alias mv='mv -i' alias md='mkdir -p' alias rd='rmdir' +alias mkdate='mkdir "$(date +'%Y%m%d')"' if [ ! -x "$(which tree 2>/dev/null)" ] then @@ -91,7 +92,7 @@ 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 dot='git --git-dir=$HOME/.dot --work-tree=$HOME' +alias git_local='git --git-dir=.git_local' # alias for genibus alias gf='gf.py' diff --git a/.local/bin/gf.py b/.local/bin/gf.py index cce7fb9..9565536 100755 --- a/.local/bin/gf.py +++ b/.local/bin/gf.py @@ -27,16 +27,16 @@ def dbg_speed(ids5,val5,ts,sa): global td global master global speed - td=td+[ts.timestamp()] master=master+[1+(sa-31)/10] - for i in range(4): - speed[i]=speed[i]+[val5[i]/254] + for i in range(len(ids5)): + if ids5[i] in range(67,71): + speed[ids5[i]-67]=speed[ids5[i]-67]+[val5[i]/254] return td,master,speed -# section: checkline {{{1 +# section: checkcrc {{{1 ###################################################### -def checkline(line): +def checkcrc(line): ok=False if len(line)>16 and not "ERR" in line.upper(): ok=True @@ -69,6 +69,22 @@ def readtimestamp(line): print(ts) return ts,line +# section: checkglowpan {{{1 +###################################################### +def checkglowpan(line): + isgenidata=False + line=line[32:] + #print(repr(line)) + mac_hi,line=readbyte(line) + mac_lo,line=readbyte(line) + #print(mac_hi,mac_lo) + #print(repr(line)) + if mac_hi==8 and mac_lo==4: + isgenidata=True + #print(repr(line)) + #print(isgenidata) + return isgenidata,line + # section: readbyte {{{1 ###################################################### def readbyte(line): @@ -87,6 +103,9 @@ def readbyte(line): # section: process_header {{{1 ###################################################### def process_header(line): + +# print(repr(line)) + sd,line=readbyte(line) if sd==gf.DATA_REQUEST: typ="DATA_REQUEST --->" @@ -119,7 +138,8 @@ def process_apdu(line): le,line=readbyte(line) os=(le&0xC0)>>6 le=le&0x3F - print(gf.operation[os],"Class:",cl,"Length:",le) + print(gf.operation[os],"Cl.",cl,"Len.",le) +# print(gf.operation[os],"Cl. {02}",cl) return cl,os,le,line # section: process_data {{{1 @@ -154,9 +174,9 @@ def process_string(line,le,size1,size2): string=''.join(chr(i) for i in val) string=string[:-1] if size1>0 and size2>0: - print(gf.params[cl][ids],"=",repr(string)) + print("Id:",ids,repr(gf.params[cl][ids]),"=",repr(string)) elif size1>0: - print(gf.params[cl][ids]) + print("Id:",ids,repr(gf.params[cl][ids])) elif size2>0: print("=",repr(string)) return ids,val,line @@ -172,9 +192,9 @@ def process_object(line,le,size1,size2): val[i],line=readbyte(line) if size1>0 and size2>0: - print(gf.params[cl][ids],"=",val) + print("Id:",ids,repr(gf.params[cl][ids]),"=",val) elif size1>0: - print(gf.params[cl][ids]) + print("Id:",ids,repr(gf.params[cl][ids])) elif size2>0: print("=",val) return ids,val,line @@ -197,10 +217,13 @@ def process_telegram(line): global cl # Check if timestamp exists ts,line=readtimestamp(line) + # Filter non geni data if glowpan frame + isgenidata,line=checkglowpan(line) + if not isgenidata: return # Check if line is ok - ok=checkline(line) - if not ok: return - # Process telegram + iscrcok=checkcrc(line) + if not iscrcok: return + # Process geni data typ,ds,le,da,sa,line=process_header(line) numbytes=le-2 while numbytes>0 and len(line)>=2*numbytes: @@ -329,7 +352,7 @@ for line in fileinput.input(): # print(line) process_telegram(line) -# section: plotting {{{1 +# section: plot {{{1 ###################################################### # Calculate timedelta diff --git a/.vimrc b/.vimrc index f2c84f2..bb82207 100644 --- a/.vimrc +++ b/.vimrc @@ -185,8 +185,7 @@ map v :so ~/.vimrc " -------------------------- if has("autocmd") filetype plugin indent on - autocmd bufnewfile,bufread *.md set filetype=markdown - autocmd bufnewfile,bufread *.gradle set filetype=groovy +autocmd bufnewfile,bufreadpost *.md set filetype=markdown endif " has("autocmd") " }}}1 " section: visual {{{1 diff --git a/README.md b/README.md index 41f5ecf..5b42f27 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -# dotfiles +# dotfiles What you need to do on the new box is this: $ cd $HOME - $ alias dot='git --git-dir=$HOME/.dot --work-tree=$HOME' - $ git init --bare $HOME/.dot - $ dot remote add origin git@bitbucket.org:jannikz/dotfiles.git - $ dot fetch - $ dot reset --hard origin/master - $ dot branch -u origin/master \ No newline at end of file + $ git init + $ git remote add origin https://github.com/jannikz/dotfiles.git + $ git fetch origin master + $ git reset --hard origin/master + $ git branch -u origin/master