From: Jannik Zander Date: Sun, 12 Jun 2016 10:00:40 +0000 (+0200) Subject: Add class 10 object X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=417b56caf871bcb7257c27ce5e80d0c80667dd5f;p=dotfiles.git Add class 10 object --- diff --git a/.local/bin/gf.py b/.local/bin/gf.py index 11d58d5..a3368ed 100755 --- a/.local/bin/gf.py +++ b/.local/bin/gf.py @@ -117,7 +117,6 @@ def process_data(line,le,size1,size2): print("Value:",val[i]) return ids,val,line - # section: process_string {{{1 ###################################################### def process_string(line,le,size1,size2): @@ -128,21 +127,32 @@ def process_string(line,le,size1,size2): for i in range(0,size2): val[i],line=readbyte(line) string=''.join(chr(i) for i in val) - + string=string[:-1] if size1>0 and size2>0: - print("Id:",ids,"Value:",val,"String:",repr(string[:-1])) + print("Id:",ids,"Value:",val,"String:",repr(string)) elif size1>0: print("Id:",ids) elif size2>0: - print("Value:",val,"String:",repr(string[:-1])) - return ids,string,line + print("Value:",val,"String:",repr(string)) + return ids,val,line # section: process_object {{{1 ###################################################### -def process_object(line,le): +def process_object(line,le,size1,size2): + ids=[0]*size1 + val=[0]*size2 + if size1>0: + ids,line=readbyte(line) + for i in range(0,size2): + val[i],line=readbyte(line) + if size1>0 and size2>0: + print("Id:",ids,"Value:",val) + elif size1>0: + print("Id:",ids) + elif size2>0: + print("Value:",val) return ids,val,line - # section: process_crc {{{-1 ###################################################### def process_crc(line): @@ -224,8 +234,12 @@ def process_telegram(line): elif cl==7 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids7,val7,line=process_string(line,ale,1,ale-1) # section: class 10 {{{2 -# elif cl==10: -# ids10,val10,line=process_object(line,ale) + elif cl==10 and ds==gf.DATA_REQUEST and os==gf.OS_GET: + ids10,val10,line=process_object(line,ale,1,0) + elif cl==10 and ds==gf.DATA_REPLY and os==gf.OS_GET: + ids10,val10,line=process_object(line,ale,0,ale) + elif cl==10 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: + ids10,val10,line=process_object(line,ale,1,ale-1) # section: class 11 {{{2 elif cl==11 and ds==gf.DATA_REQUEST and os==gf.OS_GET: ids11,val11,line=process_data(line,ale,1,0)