添加小板程序版本读取

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

@@ -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
# 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
data=bytearray([5])
# u.cmd=0x42
# data=bytearray([5])
# 设置硬件版本号
# 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])
@@ -493,12 +493,15 @@ if __name__ == "__main__":
# u.cmd=0x44
# data=bytearray([5])
# 赋码仪新检测命令
u.cmd=0x10
data=bytearray([0xff,0x03,0,0,0,0])
# u.cmd=0x10
# data=bytearray([0xff,0x03,0,0,0,0])
# 批检仪新检测命令,写入流水号
# u.cmd=0x48
# 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(' '))
# with open("file/EX_Coder_Test_2023-07-6.json","rb") as f:
# 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 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