电机下压
This commit is contained in:
@@ -120,7 +120,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name>5</Name>
|
||||
<Name>d</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
125
python/checker_test.py
Normal file
125
python/checker_test.py
Normal file
@@ -0,0 +1,125 @@
|
||||
import serial
|
||||
import serial.tools.list_ports
|
||||
import threading
|
||||
import time
|
||||
import socket
|
||||
|
||||
# 把tcp封装为串口
|
||||
class utcp:
|
||||
is_open=False
|
||||
def __init__(self,port:int)->None:
|
||||
self.ser = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.ser.bind(("",port))
|
||||
self.ser.settimeout(10)
|
||||
self.ser.listen(128)
|
||||
print("wait for mcu connect.")
|
||||
self.client,self.client_addr=self.ser.accept()
|
||||
print("client:",self.client_addr)
|
||||
self.is_open=True
|
||||
def read(self,len:int):
|
||||
return self.client.recv(len)
|
||||
def write(self,data:bytearray):
|
||||
return self.client.send(data)
|
||||
def close(self):
|
||||
self.client.close()
|
||||
self.ser.close()
|
||||
self.is_open=False
|
||||
|
||||
class port:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
def open(self,name:str,bsp:int):
|
||||
if(name!="utcp"):
|
||||
self.ser = serial.Serial(port=name, baudrate=bsp,bytesize=serial.EIGHTBITS,parity=serial.PARITY_NONE,
|
||||
stopbits=serial.STOPBITS_ONE,timeout=None)
|
||||
else:
|
||||
self.ser=utcp(9527)
|
||||
def start_recv(self):
|
||||
self.thread_ = threading.Thread(target=self.recv, args=())
|
||||
self.thread_.start()
|
||||
def recv(self,num:int):
|
||||
d=bytes()
|
||||
try:
|
||||
d=self.ser.read(num)
|
||||
except Exception as a:
|
||||
print("port closed")
|
||||
return
|
||||
# print("recv:",d.hex(" "))
|
||||
def send(self,data:bytearray):
|
||||
self.ser.write(data)
|
||||
# 测试上位机
|
||||
def ecode_test(self,times:int):
|
||||
print("检测赋码系统耗时测试:")
|
||||
tick=0
|
||||
while(tick<times):
|
||||
tick+=1
|
||||
print("当前={d1},总共={d2}".format(d1=tick,d2=times))
|
||||
# 等待数据库写入
|
||||
time.sleep(3)
|
||||
start = time.perf_counter()
|
||||
# 开始检测
|
||||
self.send(bytearray([0xB0, 0x00, 0x02, 0x00, 0x60]))
|
||||
# 接收指令应答
|
||||
self.recv(5)
|
||||
# 接收检测结果
|
||||
self.recv(24)
|
||||
end = time.perf_counter()
|
||||
print("检测耗时:",end-start)
|
||||
start2=time.perf_counter()
|
||||
# 开始注码
|
||||
self.send(bytearray([0xF0, 0x00, 0x02, 0xE0, 0x41, 0xB1, 0x00, 0x02, 0x00, 0xFB]))
|
||||
# 接收指令应答
|
||||
self.recv(5)
|
||||
# 接收注码 结果
|
||||
self.recv(305)
|
||||
end = time.perf_counter()
|
||||
print("注码耗时:",end-start2)
|
||||
# 打标结束,保存数据库
|
||||
self.send(bytearray([0xF0, 0x00, 0x02, 0xE2, 0x23, 0xB2, 0x00, 0x02, 0x00, 0x67]))
|
||||
# 接收指令应答
|
||||
self.recv(5)
|
||||
end = time.perf_counter()
|
||||
print("总耗时:",end-start)
|
||||
# 测试注码仪
|
||||
def coder_test(self,times:int):
|
||||
print("赋码仪耗时测试:")
|
||||
tick=0
|
||||
while(tick<times):
|
||||
tick+=1
|
||||
start = time.perf_counter()
|
||||
print("当前={d1},总共={d2}".format(d1=tick,d2=times))
|
||||
# 开始检测
|
||||
self.send(bytearray([0x59, 0x6D, 0x05, 0x00, 0x01, 0x66, 0x04, 0x05, 0x00, 0x2F, 0xD9]))
|
||||
# 接收指令应答
|
||||
self.recv(13)
|
||||
# 接收检测结果
|
||||
self.recv(72)
|
||||
end = time.perf_counter()
|
||||
print("检测耗时:",end-start)
|
||||
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.recv(12)
|
||||
# 接收注码 结果
|
||||
self.recv(401)
|
||||
end = time.perf_counter()
|
||||
print("注码耗时:",end-start2)
|
||||
end = time.perf_counter()
|
||||
print("总耗时:",end-start)
|
||||
|
||||
if __name__ == "__main__":
|
||||
p=port()
|
||||
# 检测赋码仪系统测试
|
||||
p.open("com8",115200)
|
||||
p.ecode_test(5)
|
||||
|
||||
# 赋码仪设备串口测试
|
||||
# p.open("com5",9600)
|
||||
# p.coder_test(5)
|
||||
# p.open("com5",115200)
|
||||
# p.coder_test(5)
|
||||
|
||||
# 赋码仪设备网口测试
|
||||
# p.open("utcp",0)
|
||||
# p.coder_test(5)
|
283
python/file/EX三码绑定测试2023-06-08 - 副本.json
Normal file
283
python/file/EX三码绑定测试2023-06-08 - 副本.json
Normal file
@@ -0,0 +1,283 @@
|
||||
{
|
||||
"PlanID": 46534786,
|
||||
"CheckSoftVersion": [
|
||||
1
|
||||
],
|
||||
"CheckHardVersion": [
|
||||
1
|
||||
],
|
||||
"TimeOutS": 4,
|
||||
"TimeOutM": 10,
|
||||
"TimeOutUI": 12,
|
||||
"TaskIDMax": 26,
|
||||
"TaskArray": [
|
||||
{
|
||||
"TaskID": 0,
|
||||
"TaskIndex": 0,
|
||||
"ParamCount": 1,
|
||||
"ParamVal": [
|
||||
88
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 1,
|
||||
"TaskIndex": 1,
|
||||
"ParamCount": 3,
|
||||
"ParamVal": [
|
||||
88,
|
||||
5000,
|
||||
400
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 95,
|
||||
"Min": 80
|
||||
},
|
||||
{
|
||||
"Max": 600,
|
||||
"Min": 100
|
||||
}
|
||||
],
|
||||
"ReturnCount": 2,
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
23,
|
||||
22
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 5,
|
||||
"TaskIndex": 2,
|
||||
"ParamCount": 4,
|
||||
"ParamVal": [
|
||||
8,
|
||||
4,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 32,
|
||||
"TaskIndex": 3,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 8,
|
||||
"Min": 8
|
||||
},
|
||||
{
|
||||
"Max": 4,
|
||||
"Min": 4
|
||||
},
|
||||
{
|
||||
"Max": 1,
|
||||
"Min": 1
|
||||
}
|
||||
],
|
||||
"ReturnCount": 3,
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
28,
|
||||
28,
|
||||
28,
|
||||
255
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 4,
|
||||
"TaskIndex": 4,
|
||||
"ParamCount": 2,
|
||||
"ParamVal": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 24,
|
||||
"TaskIndex": 5,
|
||||
"ParamCount": 2,
|
||||
"ParamVal": [
|
||||
128,
|
||||
0
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 11,
|
||||
"TaskIndex": 6,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 240,
|
||||
"Min": 0
|
||||
}
|
||||
],
|
||||
"ReturnCount": 1,
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
30
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 8,
|
||||
"TaskIndex": 7,
|
||||
"ParamCount": 5,
|
||||
"ParamVal": [
|
||||
34,
|
||||
5000,
|
||||
100,
|
||||
600,
|
||||
5
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 3500,
|
||||
"Min": 1000
|
||||
},
|
||||
{
|
||||
"Max": 600,
|
||||
"Min": 200
|
||||
},
|
||||
{
|
||||
"Max": 80,
|
||||
"Min": 10
|
||||
}
|
||||
],
|
||||
"ReturnCount": 3,
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
34,
|
||||
35,
|
||||
32,
|
||||
255
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 7,
|
||||
"TaskIndex": 8,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 40,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 26,
|
||||
"TaskIndex": 9,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 45,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 4,
|
||||
"TaskIndex": 10,
|
||||
"ParamCount": 2,
|
||||
"ParamVal": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 31,
|
||||
"TaskIndex": 11,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 24,
|
||||
"TaskIndex": 12,
|
||||
"ParamCount": 2,
|
||||
"ParamVal": [
|
||||
32,
|
||||
32
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 29,
|
||||
"TaskIndex": 13,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
@@ -433,5 +433,13 @@ if __name__ == "__main__":
|
||||
# u.init("utcp:7777")
|
||||
# u.send_file(0xee,"file/JQ_JCXB_V54.bin")
|
||||
# u.send_file(0xed,"../Objects/checker_gen1_app_20230602.bin")
|
||||
u.cmd=0x34
|
||||
u.cmd=0x31
|
||||
print(u.encode(bytearray()).hex(' '))
|
||||
|
||||
|
||||
# 开始检测
|
||||
# 59 6d 03 00 30 00 00 60 0f
|
||||
# 结束应答
|
||||
# 59 6D 03 00 31 00 00 31 CF
|
||||
|
||||
|
||||
|
@@ -115,6 +115,7 @@
|
||||
赋码仪读写参数命令添加读写位,解决写参数时少偏移了一位导致的写参数失败的问题
|
||||
2023.6.20
|
||||
赋码失败返回时返回小板的错误码
|
||||
|
||||
2023.6.25
|
||||
电机下压
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-06-20 17:40:53"
|
||||
#define BUILD_DATE "2023-06-25 17:31:20"
|
||||
#define SOFT_VERSION "0.01"
|
||||
|
||||
|
||||
|
@@ -78,7 +78,7 @@ sig_thread thread_creat(int pro)
|
||||
slot_run_def *run=calloc(1,sizeof(slot_run_def));
|
||||
run->run=1;
|
||||
sprintf(name,"sig_mq#%d",count);
|
||||
run->mb=rt_mq_create(name,(sizeof(slot_msg_def)+sizeof(uint32_t)*8),50,RT_IPC_FLAG_FIFO);
|
||||
run->mb=rt_mq_create(name,(sizeof(slot_msg_def)+sizeof(uint32_t)*8),100,RT_IPC_FLAG_FIFO);
|
||||
sprintf(name,"sig_t#%d",count);
|
||||
rt_thread_t rt_t=rt_thread_create(name,slot_run,run,2048,pro,20);
|
||||
rt_thread_startup(rt_t);
|
||||
|
@@ -24,6 +24,8 @@ typedef struct{
|
||||
int count;
|
||||
int max_count;
|
||||
moter_stat stat;
|
||||
void (*fun_in_end)(void *t);
|
||||
void *t;
|
||||
}self_def;
|
||||
|
||||
|
||||
@@ -73,12 +75,42 @@ static void moter_run(void *t)
|
||||
s->stat=STOP;
|
||||
DBG_LOG("moter stoped.");
|
||||
emit moter_end_signal(s);
|
||||
if(s->fun_in_end){
|
||||
s->fun_in_end(s->t);
|
||||
s->fun_in_end=0;
|
||||
s->t=0;
|
||||
}
|
||||
}
|
||||
ev=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD>
|
||||
void moter_down(void (*fun)(void *t),void *t)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
if(fun){
|
||||
s->fun_in_end=fun;
|
||||
s->t=t;
|
||||
}
|
||||
moter_start(0,MOTER_MAX_COUNT-s->count);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD>
|
||||
void moter_up(void (*fun)(void *t),void *t)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
if(fun){
|
||||
s->fun_in_end=fun;
|
||||
s->t=t;
|
||||
}
|
||||
moter_start(0,-s->count-100);
|
||||
}
|
||||
|
||||
|
||||
void moter_start(int fre,int step_count)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
@@ -101,6 +133,7 @@ void moter_start_slot(void *t,int fre,int step_count)
|
||||
if(s->count+step_count>s->max_count)
|
||||
{
|
||||
DBG_WARN("steps count exceeded limit!,max=%d",s->max_count);
|
||||
end_irq(s);
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
|
@@ -16,6 +16,9 @@ void moter_start_slot(void *t,int fre,int step_count);
|
||||
|
||||
void moter_start(int fre,int step_count);
|
||||
|
||||
void moter_down(void (*fun)(void *t),void *t);
|
||||
|
||||
void moter_up(void (*fun)(void *t),void *t);
|
||||
|
||||
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include "handle_for_checker.h"
|
||||
#include "compiler_info.h"
|
||||
#include "dev_backup.h"
|
||||
#include "moter.h"
|
||||
|
||||
|
||||
|
||||
@@ -81,10 +82,29 @@ static void check_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_s
|
||||
arr_append(a,0);
|
||||
arr_appends(a,w->ack,w->ack_size);
|
||||
emit tran_send_signal(w->u.p,0x31,arr_temp(a));
|
||||
// 把命令字改为0x31用于接收主机应答
|
||||
w->u.cmd=0x31;
|
||||
tran_set_busy(w->u.p,0);
|
||||
}
|
||||
}
|
||||
|
||||
// 电机上升之后解除忙状态
|
||||
static void check_when_moter_up(void *t)
|
||||
{
|
||||
ucport_def *u=t;
|
||||
tran_set_busy(u->p,0);
|
||||
}
|
||||
|
||||
|
||||
static int check_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
|
||||
{
|
||||
if(cmd==0x31)
|
||||
{
|
||||
moter_up(check_when_moter_up,u);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void check_del(ucport_def *u)
|
||||
{
|
||||
@@ -92,6 +112,23 @@ static void check_del(ucport_def *u)
|
||||
}
|
||||
|
||||
|
||||
// 电机下降之后开始检测
|
||||
static void check_when_moter_down(void *t)
|
||||
{
|
||||
ucport_def *u=t;
|
||||
for(int i=0;i<20;i++)
|
||||
{
|
||||
port_mcu *mcu=tran_get_portm(u->p,i);
|
||||
// 这里打开检测
|
||||
if(mcu){
|
||||
port_start(mcu,check_creat(check_scheme()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static ucport_def *check(tran_def *t, uint8_t cmd,array_def *data)
|
||||
{
|
||||
int return_size=(check_scheme()->range_num*2+8+(check_scheme()->range_num+7)/8);
|
||||
@@ -100,18 +137,11 @@ static ucport_def *check(tran_def *t, uint8_t cmd,array_def *data)
|
||||
u->ack_size=return_size*20;
|
||||
u->u.p=t;
|
||||
u->u.del=check_del;
|
||||
u->u.dolater=check_dolater;
|
||||
u->u.doend=check_end;
|
||||
DBG_LOG("check: skip=%d",u->ret_skip);
|
||||
tran_set_busy(t,1);
|
||||
for(int i=0;i<20;i++)
|
||||
{
|
||||
port_mcu *mcu=tran_get_portm(u->u.p,i);
|
||||
// 这里打开检测
|
||||
if(mcu){
|
||||
port_start(mcu,check_creat(check_scheme()));
|
||||
}
|
||||
}
|
||||
|
||||
moter_down(check_when_moter_down,u);
|
||||
array_def *a=arr_creat();
|
||||
arr_append(a,0);
|
||||
emit tran_reply_signal(u->u.p,arr_temp(a));
|
||||
|
Reference in New Issue
Block a user