移植到stm32f1,实现手动线赋码控制器功能
This commit is contained in:
@@ -264,6 +264,8 @@ class protu(QObject):
|
||||
end_signal = pyqtSignal([bool,str])
|
||||
# 接收到数据信号
|
||||
recv_signal =pyqtSignal([int,bytearray,str])
|
||||
# 接收到字符串信号
|
||||
recv_str_signal =pyqtSignal([int,str,str])
|
||||
|
||||
hand=handle()
|
||||
def __init__(self) -> None:
|
||||
@@ -359,6 +361,7 @@ class protu(QObject):
|
||||
def recv(self):
|
||||
# self.recv_signal.connect(self.send_file_next)
|
||||
data=bytearray()
|
||||
data_str=bytearray()
|
||||
while(self.ser.is_open):
|
||||
d=bytes()
|
||||
try:
|
||||
@@ -368,6 +371,7 @@ class protu(QObject):
|
||||
print("port closed")
|
||||
return
|
||||
data+=d
|
||||
data_str+=d
|
||||
if(len(data)==3):
|
||||
if(data[0]==0x59 and data[1]==0x6d and data[2]==0x43):
|
||||
self.num_to_recv=5
|
||||
@@ -395,6 +399,18 @@ class protu(QObject):
|
||||
# self.send_file_next(self.cmd,t,self.str_err)
|
||||
# print("sent signal---")
|
||||
data.clear()
|
||||
data_str.clear()
|
||||
elif(len(data_str)>=2):
|
||||
if((data_str[-2]==0x0d) and (data_str[-1]==0x0a)):
|
||||
data_str=data_str[:-2]
|
||||
recv_str=""
|
||||
try:
|
||||
recv_str=data_str.decode("utf-8")
|
||||
self.recv_str_signal.emit(0,recv_str,"ok")
|
||||
data_str.clear()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
# print(recv_str)
|
||||
# else:
|
||||
# print("len(data)={d1},num_ro_recv={d2}".format(d1=len(data),d2=self.num_to_recv))
|
||||
def send(self,cmd:int,data:bytearray):
|
||||
@@ -481,8 +497,8 @@ if __name__ == "__main__":
|
||||
# u.send_file(0xed,"../Objects/checker_gen1_app_20230602.bin")
|
||||
|
||||
# 设置电阻 矫正值
|
||||
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])
|
||||
# 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])
|
||||
# 测量电阻
|
||||
# u.cmd=0x42
|
||||
# data=bytearray([0])
|
||||
@@ -494,6 +510,8 @@ if __name__ == "__main__":
|
||||
# data=bytearray([0x01,100,0])
|
||||
# data=bytearray([0x02]) # 上升
|
||||
# data=bytearray([0x03]) # 下降
|
||||
u.cmd=0x8a
|
||||
data=bytearray([0])
|
||||
|
||||
print(u.encode(data).hex(' '))
|
||||
# with open("file/EX_Coder_Test_2023-07-6.json","rb") as f:
|
||||
|
Reference in New Issue
Block a user