添加小板程序版本读取

This commit is contained in:
ranchuan
2024-03-12 17:04:07 +08:00
parent 5aa013e168
commit 5bd29dd25d
11 changed files with 164 additions and 26 deletions

View File

@@ -260,6 +260,9 @@ class sch_data(object):
for row in check_data: for row in check_data:
# 这里过滤检测异常的结果 # 这里过滤检测异常的结果
# if(row[3]==0): # if(row[3]==0):
err=str(row[3])
if((err=='3') or (err=='20') or (err=='208') or (err=='255')):
continue
s=row[5].split(',') s=row[5].split(',')
for i in range(len(s)): for i in range(len(s)):
data_list[i].append(int(s[i])) data_list[i].append(int(s[i]))

27
autotest/auto.py Normal file
View File

@@ -0,0 +1,27 @@
from pynput.mouse import Controller, Button
import time
if __name__ == '__main__':
mouse = Controller()
print("10秒后开始 自动点击")
time.sleep(10)
for i in range(50000):
print(f"点击第 {i}")
# 模拟左键点击
mouse.click(Button.left)
time.sleep(12)

View File

@@ -91,23 +91,23 @@ class port:
tick+=1 tick+=1
start = time.perf_counter() start = time.perf_counter()
print("当前={d1},总共={d2}".format(d1=tick,d2=times)) print("当前={d1},总共={d2}".format(d1=tick,d2=times))
# 开始检测 # # 开始检测
self.send(bytearray([0x59, 0x6D, 0x05, 0x00, 0x01, 0x66, 0x04, 0x05, 0x00, 0x2F, 0xD9])) # self.send(bytearray([0x59, 0x6D, 0x05, 0x00, 0x01, 0x66, 0x04, 0x05, 0x00, 0x2F, 0xD9]))
# 接收指令应答 # # 接收指令应答
self.recv(13) # self.recv(13)
# 接收检测结果 # # 接收检测结果
self.recv(42) # self.recv(42)
end = time.perf_counter() # end = time.perf_counter()
print("检测耗时:",end-start) # print("检测耗时:",end-start)
start2=time.perf_counter() start2=time.perf_counter()
# # 开始注码 # # 开始注码
# self.send(bytearray([0x59,0x6D,0x94,0x00,0x02,0xBE,0x01,0x0A,0x32,0x30,0x32,0x33,0x00,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x39,0x01,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x38,0x02,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x37,0x03,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x36,0x04,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x35,0x05,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x34,0x06,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x33,0x07,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x32,0x08,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x31,0x09,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x30,0x44,0xC1])) self.send(bytearray([0x59,0x6D,0x94,0x00,0x02,0xBE,0x01,0x0A,0x32,0x30,0x32,0x33,0x00,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x39,0x01,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x38,0x02,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x37,0x03,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x36,0x04,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x35,0x05,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x34,0x06,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x33,0x07,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x32,0x08,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x31,0x09,0x35,0x38,0x33,0x30,0x36,0x31,0x39,0x41,0x30,0x34,0x30,0x30,0x30,0x44,0xC1]))
# # 接收指令应答 # 接收指令应答
# self.recv(12) self.recv(12)
# # 接收注码 结果 # 接收注码 结果
# self.recv(401) self.recv(401)
# end = time.perf_counter() end = time.perf_counter()
# print("注码耗时:",end-start2) print("注码耗时:",end-start2)
end = time.perf_counter() end = time.perf_counter()
print("总耗时:",end-start) print("总耗时:",end-start)

View File

@@ -0,0 +1,70 @@
import ctypes as C
import os
class uid:
def __init__(self) -> None:
path="./creat_uid.dll"
try:
if os.path.exists(path):
self.dll=C.windll.LoadLibrary(path)
else:
print(f"dll {path} not found.")
self.dll=None
except Exception as e:
print("load dll faled.",str(e))
self.dll=None
def info(self):
if(self.dll is None):
return ""
p_info=C.create_string_buffer(50)
self.dll.info(p_info,C.c_int(50))
return p_info.value.decode()
def shell_to_uid_gen1(self,shell:bytearray,year:bytearray):
if(self.dll is None):
return ""
p_info=C.create_string_buffer(50)
self.dll.shell_to_uid_gen1(p_info,C.c_char_p(shell),C.c_char_p(year))
# print(len(p_info.value))
return p_info.value.decode()
def uid_to_save_psw_gen1(self,shell:bytearray,year:bytearray):
uid=self.shell_to_uid_gen1(shell,year)
p_save=C.create_string_buffer(50)
p_psw=C.create_string_buffer(50)
self.dll.uid_to_save_psw_gen1(p_save,p_psw,C.c_char_p(uid.encode()))
return p_save.value.hex(),p_psw.value.hex()
def shell_to_uid_gen2(self,shell:bytearray,year:bytearray):
if(self.dll is None):
return ""
p_info=C.create_string_buffer(50)
self.dll.shell_to_uid_gen2(p_info,C.c_char_p(shell),C.c_char_p(year))
# print(len(p_info.value))
return p_info.value.decode()
def uid_to_save_psw_gen2(self,shell:bytearray,year:bytearray):
uid=self.shell_to_uid_gen2(shell,year)
p_save=C.create_string_buffer(50)
p_psw=C.create_string_buffer(50)
self.dll.uid_to_save_psw_gen2(p_save,p_psw,C.c_char_p(uid.encode()))
return p_save.value.hex(),p_psw.value.hex()
if __name__ == "__main__":
u=uid()
for i in range(10000):
u.shell_to_uid_gen1(b"6640124G08001J",b"2024")
u.shell_to_uid_gen2(b"6640124G08001J",b"2024")
u.uid_to_save_psw_gen1(b"6640124G08001J",b"2024")[1]
u.uid_to_save_psw_gen2(b"6640124G08001J",b"2024")[1]
print("end")

Binary file not shown.

View File

@@ -479,8 +479,8 @@ if __name__ == "__main__":
# u.cmd=0x41 # u.cmd=0x41
# data=bytearray([1,100,0x00,2,0,0x00,3,0,0x00,4,0,0x00,5,0,0x00,6,0,0x00,7,0,0x00,8,0,0x00,9,0,0x00,10,0,0x00,11,0,0x00,12,0,0x00,13,0,0x00,14,0,0x00,15,0,0x00,16,0,0x00,17,0,0x00,18,0,0x00,19,0,0x00,20,0,0x00]) # data=bytearray([1,100,0x00,2,0,0x00,3,0,0x00,4,0,0x00,5,0,0x00,6,0,0x00,7,0,0x00,8,0,0x00,9,0,0x00,10,0,0x00,11,0,0x00,12,0,0x00,13,0,0x00,14,0,0x00,15,0,0x00,16,0,0x00,17,0,0x00,18,0,0x00,19,0,0x00,20,0,0x00])
# 测量电阻 # 测量电阻
u.cmd=0x42 # u.cmd=0x42
data=bytearray([5]) # data=bytearray([5])
# 设置硬件版本号 # 设置硬件版本号
# u.cmd=0x43 # u.cmd=0x43
# data=bytearray([1,50,0x00,2,51,0x00,3,52,0x00,4,53,0x00,5,54,0x00,6,55,0x00,7,56,0x00,8,57,0x00,9,58,0x00,10,59,0x00,11,60,0x00,12,61,0x00,13,62,0x00,14,63,0x00,15,64,0x00,16,65,0x00,17,66,0x00,18,67,0x00,19,68,0x00,20,69,0x00]) # data=bytearray([1,50,0x00,2,51,0x00,3,52,0x00,4,53,0x00,5,54,0x00,6,55,0x00,7,56,0x00,8,57,0x00,9,58,0x00,10,59,0x00,11,60,0x00,12,61,0x00,13,62,0x00,14,63,0x00,15,64,0x00,16,65,0x00,17,66,0x00,18,67,0x00,19,68,0x00,20,69,0x00])
@@ -493,12 +493,15 @@ if __name__ == "__main__":
# u.cmd=0x44 # u.cmd=0x44
# data=bytearray([5]) # data=bytearray([5])
# 赋码仪新检测命令 # 赋码仪新检测命令
u.cmd=0x10 # u.cmd=0x10
data=bytearray([0xff,0x03,0,0,0,0]) # data=bytearray([0xff,0x03,0,0,0,0])
# 批检仪新检测命令,写入流水号 # 批检仪新检测命令,写入流水号
# u.cmd=0x48 # u.cmd=0x48
# data=bytearray([2,1,2,3,0, 3,5,6,7,0, 9,8,9,10,0]) # data=bytearray([2,1,2,3,0, 3,5,6,7,0, 9,8,9,10,0])
u.cmd=0x50
data=bytearray([7])
print(u.encode(data).hex(' ')) print(u.encode(data).hex(' '))
# with open("file/EX_Coder_Test_2023-07-6.json","rb") as f: # with open("file/EX_Coder_Test_2023-07-6.json","rb") as f:
# json_obj=json.loads(f.read()) # json_obj=json.loads(f.read())
@@ -523,3 +526,19 @@ if __name__ == "__main__":
# 直接检测 # 直接检测
# 59 6d 04 00 44 00 00 05 d5 6c # 59 6d 04 00 44 00 00 05 d5 6c
# 电机归零
# 59 6d 04 00 50 00 00 01 d1 5f
# 电机下降20000步
# 59 6d 06 00 50 00 00 02 20 4e f4 45
# 电机上升20000步
# 59 6d 06 00 50 00 00 03 20 4e a5 85
# 测量桥丝阻值
# 59 6d 04 00 50 00 00 04 11 5c
# 总线设置20V
# 59 6d 06 00 50 00 00 05 c8 00 8b b0
# 关总线
# 59 6D 43 05 00 50 00 00 00 06 0E 0E
# 检总线电流
# 59 6d 04 00 50 00 00 07 51 5d

View File

@@ -34,8 +34,6 @@ def crc8(data:bytearray,seed:int=0xff):
# 把tcp封装为串口 # 把tcp封装为串口
class utcp: class utcp:
is_open=False is_open=False

View File

@@ -95,12 +95,13 @@ def _detail_lua(name:str):
ret=[" |文件类型:批检仪/赋码仪检测结果判定脚本"] ret=[" |文件类型:批检仪/赋码仪检测结果判定脚本"]
return ret return ret
def _detail_pkt(name:str): def _detail_pkt(name:str):
ret=[" |文件类型:MCU程序在线升级文件"] ret=[" |文件类型:批检仪/赋码仪小板程序在线升级文件"]
with open(name,"rb") as f: with open(name,"rb") as f:
data=f.read() data=f.read()
ret.append(" |打包时间:{d}".format(d=_bytes_to_str(data[4:4+20]))) ret.append(" |打包时间:{d}".format(d=_bytes_to_str(data[4:4+20])))
ret.append(" |主机接口:{d}".format(d=_bytes_to_str(data[40:40+8]))) ret.append(" |主机接口:{d}".format(d=_bytes_to_str(data[40:40+8])))
ret.append(" |设备类型:{d}".format(d=_bytes_to_str(data[48:48+12]))) ret.append(" |设备类型:{d}".format(d=_bytes_to_str(data[48:48+12])))
ret.append(" |软件版本:{d}".format(d=_bytes_to_str(data[60:60+12])))
return ret return ret
def _detail_py(name:str): def _detail_py(name:str):

View File

@@ -318,7 +318,6 @@ class handle:
class protu(QObject): class protu(QObject):
# 进度信号ip1~100 # 进度信号ip1~100
rate_signal =pyqtSignal([int]) rate_signal =pyqtSignal([int])
@@ -552,12 +551,15 @@ def int2str(num:int):
return s return s
ddd=0
if __name__ == "__main__": if __name__ == "__main__":
u=protu() u=protu()
# u.init("utcp:7777") # u.init("utcp:7777")
# u.send_file(0xee,"file/JQ_JCXB_V54.bin") # u.send_file(0xee,"file/JQ_JCXB_V54.bin")
# u.send_file(0xed,"../Objects/checker_gen1_app_20230602.bin") # u.send_file(0xed,"../Objects/checker_gen1_app_20230602.bin")
ddd+=1
# 设置电阻 矫正值 # 设置电阻 矫正值
u.cmd=0x41 u.cmd=0x41
data=bytearray([1,0,0x00,2,0,0x00,3,0,0x00,4,0,0x00,5,0,0x00,6,0,0x00,7,0,0x00,8,0,0x00,9,0,0x00,10,0,0x00,11,0,0x00,12,0,0x00,13,0,0x00,14,0,0x00,15,0,0x00,16,0,0x00,17,0,0x00,18,0,0x00,19,0,0x00,20,0,0x00]) data=bytearray([1,0,0x00,2,0,0x00,3,0,0x00,4,0,0x00,5,0,0x00,6,0,0x00,7,0,0x00,8,0,0x00,9,0,0x00,10,0,0x00,11,0,0x00,12,0,0x00,13,0,0x00,14,0,0x00,15,0,0x00,16,0,0x00,17,0,0x00,18,0,0x00,19,0,0x00,20,0,0x00])

View File

@@ -321,10 +321,10 @@ if __name__ == "__main__":
u=pt.protu() u=pt.protu()
# 检测并写入流水号 # 检测并写入流水号
# data=coder_check_write_sn(0,12345) data=coder_check_write_sn(0,12345)
# 检测并读取工厂信息和延时 # 检测并读取工厂信息和延时
data=coder_check_read_fatinfo(0) # data=coder_check_read_fatinfo(0)
# data=bytearray.fromhex("0d 00 00 0d 01 1f 0a 01 18 02 0a 05 01 14 00 04 00") # data=bytearray.fromhex("0d 00 00 0d 01 1f 0a 01 18 02 0a 05 01 14 00 04 00")
u.cmd=0x21 u.cmd=0x21

View File

@@ -24,6 +24,24 @@
</div> </div>
</div> </div>
<div class="layui-colla-item">
<div class="layui-colla-title" style="height: 1.8rem; line-height: 1.8rem; display: flex;flex-wrap: nowrap;">
<span style="height:100%; min-width:2rem" class="task_index_span">
(task_info_size - 1)
</span>
<input type="text" class="layui-input task_alias_input"
style="height: 1.8rem; line-height: 1.8rem; padding-left:0px; border:none;background-color:rgb(0,0,0,0)"
task_id=taskid value=task_show_alias>
</div>
<div class="layui-colla-content layui-show">
<p>
[ task_info.TaskID : task_info.TaskName ]
task_info.TaskBrief
</p>
<h1>Hello world</h1> <h1>Hello world</h1>
<button id="but_id" onClick="buttonClick()">Click me</button> <button id="but_id" onClick="buttonClick()">Click me</button>
<input id="select_dir_id" disabled="disabled" style="width: 400px" placeholder="显示选择的目录"> <input id="select_dir_id" disabled="disabled" style="width: 400px" placeholder="显示选择的目录">