From: Jannik Zander Date: Sun, 12 Jun 2016 09:43:37 +0000 (+0200) Subject: Add class 7 string X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=1cefa2e8a65886980cb872abe7b4db3df9a982ff;p=dotfiles.git Add class 7 string --- diff --git a/.local/bin/gf.py b/.local/bin/gf.py index 857b1a5..11d58d5 100755 --- a/.local/bin/gf.py +++ b/.local/bin/gf.py @@ -120,13 +120,21 @@ def process_data(line,le,size1,size2): # section: process_string {{{1 ###################################################### -def process_string(line,le): - val=[0]*le - ids,line=readbyte(line) - for i in range(0,le-1): +def process_string(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) string=''.join(chr(i) for i in val) - print("Id:",ids, "Value:",string) + + if size1>0 and size2>0: + print("Id:",ids,"Value:",val,"String:",repr(string[:-1])) + elif size1>0: + print("Id:",ids) + elif size2>0: + print("Value:",val,"String:",repr(string[:-1])) return ids,string,line # section: process_object {{{1 @@ -177,8 +185,6 @@ def process_telegram(line): # section: class 3 {{{2 elif cl==3 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids3,val3,line=process_data(line,ale,1,0) - elif cl==3 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids3,val3,line=process_data(line,ale,0,0) elif cl==3 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids3,val3,line=process_data(line,ale,1,0) elif cl==3 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -190,8 +196,6 @@ def process_telegram(line): ids4,val4,line=process_data(line,ale,0,1) elif cl==4 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids4,val4,line=process_data(line,ale,1,1) - elif cl==4 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids4,val4,line=process_data(line,ale,0,0) elif cl==4 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids4,val4,line=process_data(line,ale,1,0) elif cl==4 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -203,8 +207,6 @@ def process_telegram(line): ids5,val5,line=process_data(line,ale,0,1) elif cl==5 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids5,val5,line=process_data(line,ale,1,1) - elif cl==5 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids5,val5,line=process_data(line,ale,0,0) elif cl==5 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids5,val5,line=process_data(line,ale,1,0) elif cl==5 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -215,8 +217,12 @@ def process_telegram(line): for i in range(4): speed[i]=speed[i]+[val5[i]/254] # section: class 7 {{{2 -# elif cl==7: -# ids7,val7,line=process_string(line,ale) + elif cl==7 and ds==gf.DATA_REQUEST and os==gf.OS_GET: + ids7,val7,line=process_string(line,ale,1,0) + elif cl==7 and ds==gf.DATA_REPLY and os==gf.OS_GET: + ids7,val7,line=process_string(line,ale,0,ale) + 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) @@ -227,8 +233,6 @@ def process_telegram(line): ids11,val11,line=process_data(line,ale,0,2) elif cl==11 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids11,val11,line=process_data(line,ale,1,2) - elif cl==11 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids11,val11,line=process_data(line,ale,0,0) elif cl==11 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids11,val11,line=process_data(line,ale,1,0) elif cl==11 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -240,8 +244,6 @@ def process_telegram(line): ids12,val12,line=process_data(line,ale,0,2) elif cl==12 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids12,val12,line=process_data(line,ale,1,2) - elif cl==12 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids12,val12,line=process_data(line,ale,0,0) elif cl==12 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids12,val12,line=process_data(line,ale,1,0) elif cl==12 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -253,8 +255,6 @@ def process_telegram(line): ids13,val13,line=process_data(line,ale,0,2) elif cl==13 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids13,val13,line=process_data(line,ale,1,2) - elif cl==13 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids13,val13,line=process_data(line,ale,0,0) elif cl==13 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids13,val13,line=process_data(line,ale,1,0) elif cl==13 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -266,8 +266,6 @@ def process_telegram(line): ids14,val14,line=process_data(line,ale,0,3) elif cl==14 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids14,val14,line=process_data(line,ale,1,3) - elif cl==14 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids14,val14,line=process_data(line,ale,0,0) elif cl==14 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids14,val14,line=process_data(line,ale,1,0) elif cl==14 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -279,8 +277,6 @@ def process_telegram(line): ids15,val15,line=process_data(line,ale,0,3) elif cl==15 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids15,val15,line=process_data(line,ale,1,3) - elif cl==15 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids15,val15,line=process_data(line,ale,0,0) elif cl==15 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids15,val15,line=process_data(line,ale,1,0) elif cl==15 and ds==gf.DATA_REPLY and os==gf.OS_INFO: @@ -292,8 +288,6 @@ def process_telegram(line): ids16,val16,line=process_data(line,ale,0,3) elif cl==16 and (ds==gf.DATA_REQUEST or ds==gf.DATA_MESSAGE) and os==gf.OS_SET: ids16,val16,line=process_data(line,ale,1,3) - elif cl==16 and ds==gf.DATA_REPLY and os==gf.OS_SET: - ids16,val16,line=process_data(line,ale,0,0) elif cl==16 and ds==gf.DATA_REQUEST and os==gf.OS_INFO: ids16,val16,line=process_data(line,ale,1,0) elif cl==16 and ds==gf.DATA_REPLY and os==gf.OS_INFO: