From 989919a73c5ebd46368991b6c3ff6959e32490b6 Mon Sep 17 00:00:00 2001 From: tao_z <tzj0429@163.com> Date: Tue, 23 Aug 2022 22:06:32 +0800 Subject: [PATCH] 完善did读取显示 --- widgets/ShifterTool.py | 8 ++++++-- Shifter.py | 3 +++ USBCAN.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Shifter.py b/Shifter.py index 48472d0..5e4c249 100644 --- a/Shifter.py +++ b/Shifter.py @@ -180,6 +180,9 @@ 0xDF03: PartNumberCodec(3), 0xDF04: PartNumberCodec(3), 0x1000: PartNumberCodec(2), + 0xF010: AsciiCodec(16), + 0xF019: AsciiCodec(16), + 0x2102: AsciiCodec(64) } try: config = configparser.ConfigParser() diff --git a/USBCAN.py b/USBCAN.py index 42ee2d2..e197752 100644 --- a/USBCAN.py +++ b/USBCAN.py @@ -420,7 +420,7 @@ USBCAN_DLL.VCI_Transmit(self.device, self.device_index, self.channel, byref(raw_message), 1) - def Receive(self, len=10, timeout=None): + def Receive(self, len=1, timeout=None): raw_message = (VCI_CAN_OBJ * len)() timeout = -1 if timeout is None else c_int(timeout * 1000) diff --git a/widgets/ShifterTool.py b/widgets/ShifterTool.py index d357388..7d869d8 100644 --- a/widgets/ShifterTool.py +++ b/widgets/ShifterTool.py @@ -1,4 +1,5 @@ from ast import Not, Pass +from asyncio.windows_events import NULL from concurrent.futures import thread from curses import flash from logging import exception @@ -833,8 +834,11 @@ self.UI.lineEdit_2.clear() data = self.ReadByDID(tempdid) if data is not None and len(str(data[tempdid])): - # print(data[tempdid]) - self.UI.lineEdit_2.setText(data[tempdid]) + if '\x00' in data[tempdid]: + out1, out2 = data[tempdid].split('\x00', 1) + self.UI.lineEdit_2.setText(out1) + else: + self.UI.lineEdit_2.setText(data[tempdid]) def WriteDataByID(self): tempdid = DID_dic[self.UI.comboBox_6.currentText()] -- Gitblit v1.8.0