From 5bb7f75fbc437d34c848e0fd9b8cb2623f39db6e Mon Sep 17 00:00:00 2001 From: vc4 <287920192@qq.com> Date: Fri, 14 Jun 2024 14:18:40 +0800 Subject: [PATCH] fix bugs --- scomm.py | 7 +++++-- usercfg.json | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/scomm.py b/scomm.py index 5ca591a..116482d 100755 --- a/scomm.py +++ b/scomm.py @@ -78,7 +78,10 @@ class UIproc(): return self.wait_sendData def getSendDataLoop(self): while True: - self.getSendData(cache=False) + try: + self.getSendData(cache=False) + except: + pass time.sleep(1) def dmesg(self, cate, data): _err = 0 @@ -99,7 +102,7 @@ class UIproc(): _i0,fg='end','black' if cate == 'send' and self.ckbtn_sendshow.var.get(): text += MARK('> ') - text += self.ckbtn_rhex.var.get() and tohex(data) or data.decode(encoding, 'ignore') + text += self.ckbtn_shex.var.get() and tohex(data) or data.decode(encoding, 'ignore') _i0 = self.text_recv.index('end') self.text_recv.insert('end', '\n%s'%text.translate({0:'<00>'})) self.lastRecvTicks = 0 diff --git a/usercfg.json b/usercfg.json index cbbf54f..efdc6a5 100644 --- a/usercfg.json +++ b/usercfg.json @@ -2,43 +2,43 @@ "baud": "9600", "btn-data01": { "hex": 1, - "title": "fan on", - "value": "01 10 30 12 00 01 02 00 01 54 E1" + "title": "DOWN", + "value": "55 AA 0A FC 01 10 01 01 10 02 01 00 05 EE EE" }, "btn-data02": { "hex": 1, - "title": "fan off", - "value": "01 10 30 12 00 01 02 00 02 14 E0" + "title": "UP", + "value": "55 AA 0A FC 01 10 01 01 10 02 01 00 04 EE EE" }, "btn-data03": { "hex": 1, "title": "reboot", - "value": "01 10 30 11 00 01 02 00 01 54 D2" + "value": "55 AA 0A FC 01 10 01 01 10 04 01 01 FF EE EE" }, "btn-data04": { "hex": 0, - "title": "set RTS", - "value": "{\"rts\":0,\"text\":\"1B\",\"hex\":1}" + "title": "DTR=1", + "value": "{\"dtr\":0,\"rts\":0,\"hex\":\"18FF\"}" }, "btn-data05": { "hex": 0, - "title": "reset RTS", - "value": "{\"rts\":1,\"text\":\"\"}" + "title": "DTR=0", + "value": "{\"dtr\":1,\"rts\":1,\"hex\":\"18FF\"}" }, "btn-data06": { - "hex": 1, - "title": "silent", - "value": "01 10 30 03 00 01 02 00 00 96 60" + "hex": 0, + "title": "random", + "value": "'%s'%__import__('random').random()" }, "btn-data07": { "hex": 1, - "title": "read.cfg", - "value": "01 03 30 00 00 16 5A EE" + "title": "wake", + "value": "55 AA 0A FC 01 10 01 01 10 04 01 03 00 EE EE\n" }, "btn-data08": { "hex": 1, - "title": "auto report", - "value": "01 10 30 03 00 01 02 00 01 57 A0" + "title": "page1", + "value": "55 AA 0A FC 01 10 01 01 10 04 01 02 01 EE EE\n" }, "btn-unpack01": { "title": "HEX print", @@ -52,12 +52,16 @@ "title": "hex2dec[-3:-2]", "value": "len(data)==26 and '\\t['+'%5d' % (data[-2]*256+data[-3])+']'" }, + "btn-unpack04": { + "title": "tc01-sens-data", + "value": "len(data)>=27 and data[2]==0x16 and '\\n\\ppbx10=%s\\nt=%s\\nad=%s\\nad0=%s\\nK=%s\\nadv=%s\\n' % (\nint16(data[5:]),\nuint16(data[7:]),\nuint16(data[11:]),\nuint16(data[13:]),\nuint16(data[15:]),\nuint16(data[21:]))\n" + }, "btn-unpack05": { - "title": "s17-eeprom", - "value": "'\\nad0fix=%s\\n' % (uint16(data[17:]))" + "title": "tc01-sens-cfg", + "value": "len(data)>=25 and data[2]==0x14 and '\\n\\K=%s\\nKuser=%s\\nad0fix=%s\\nmlevel=%s\\nfofactor=%s\\nKntc=%s\\n' % (\nuint16(data[9:]),\nuint16(data[11:]),\nuint16(data[13:]),\nuint16(data[15:]),\nuint16(data[17:]),\nuint16(data[19:]))\n\n" }, "cycle": "100", "encoding": "gbk", - "split": "500", - "uservar": "" + "split": "100", + "uservar": "HELLO" } \ No newline at end of file