赋码仪错误判断
This commit is contained in:
@@ -1177,7 +1177,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>rt_thread</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@@ -2297,6 +2297,18 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>13</GroupNumber>
|
||||
<FileNumber>142</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\coder\coder_judge.c</PathWithFileName>
|
||||
<FilenameWithoutPath>coder_judge.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
@@ -2307,7 +2319,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>14</GroupNumber>
|
||||
<FileNumber>142</FileNumber>
|
||||
<FileNumber>143</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@@ -1351,6 +1351,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\coder\coder_lib.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>coder_judge.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\coder\coder_judge.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -4266,6 +4271,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\coder\coder_lib.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>coder_judge.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\coder\coder_judge.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@@ -3,6 +3,8 @@ import lupa
|
||||
from lupa import LuaRuntime
|
||||
import execjs
|
||||
import json
|
||||
import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +20,16 @@ def lua_test(lua_file:str,json_file:str,data:bytearray):
|
||||
save_prints=lua.eval("function(a) prints=a end")
|
||||
with open("file/prints.lua",encoding="utf-8") as f:
|
||||
save_prints(lua.execute(f.read()))
|
||||
|
||||
# 初始化全局变量 cfg_name
|
||||
lua.execute("cfg_name=\""+json_file+"\"\n")
|
||||
# lua.execute("cfg_name=\""+json_file+"\"\n")
|
||||
|
||||
# 初始化配置字符串
|
||||
save_cfg_str=lua.eval("function(a) check_cfg_str=a end")
|
||||
with open(json_file,encoding="utf-8") as f:
|
||||
a=f.read()
|
||||
save_cfg_str(a)
|
||||
|
||||
# 初始化全局变量 check_data
|
||||
s=data.hex(' ')
|
||||
# print("输入数据",s)
|
||||
@@ -28,15 +38,20 @@ def lua_test(lua_file:str,json_file:str,data:bytearray):
|
||||
lua.execute("check_data={"+s+"}\n")
|
||||
# 执行判定脚本
|
||||
with open(lua_file,encoding="utf-8") as f:
|
||||
a,b=lua.execute(f.read())
|
||||
print(a,b)
|
||||
lua.execute(f.read())
|
||||
a,b=lua.globals().main()
|
||||
return a,b
|
||||
return "脚本执行失败",0xd1
|
||||
|
||||
|
||||
|
||||
|
||||
class save:
|
||||
def __init__(self,scheme:str) -> None:
|
||||
def __init__(self,scheme:str,script:str) -> None:
|
||||
self.scheme=scheme
|
||||
self.script=script
|
||||
self.save_file=scheme.split(".")[0]+".csv"
|
||||
print("save file:",self.save_file)
|
||||
with open(scheme,"rb") as f:
|
||||
self.json_obj=json.loads(f.read())
|
||||
|
||||
@@ -54,24 +69,34 @@ class save:
|
||||
def save(self,data:bytearray):
|
||||
d=data[1:]
|
||||
ret_num=self.calc_retnum()*2+8+self.calc_parerrnum()
|
||||
for i in range(20):
|
||||
self.save_item(d[i*ret_num:i*ret_num+ret_num])
|
||||
def save_item(self,d:bytearray):
|
||||
slave_num=len(d)//ret_num
|
||||
for i in range(slave_num):
|
||||
print("slave:",i+1)
|
||||
self.save_item(i+1,d[i*ret_num:i*ret_num+ret_num])
|
||||
|
||||
# 保存一个条目
|
||||
def save_item(self,slave_addr:int,d:bytearray):
|
||||
# print("save_item",d.hex(" "))
|
||||
errnum=self.calc_parerrnum()
|
||||
s='=\"'+d[0:8].hex()+'\"'+','
|
||||
s=str(slave_addr)+','
|
||||
s+='=\"'+d[0:8].hex()+'\"'+','
|
||||
s+='=\"'+self.hex2bit(d[8:8+errnum])+'\"'+','
|
||||
s+=self.hex2int(d[8+errnum:])
|
||||
# print(d[8:8+errnum].hex(' '))
|
||||
a,b=lua_test(self.script,self.scheme,d)
|
||||
s=s+a+','+str(b)
|
||||
print(s)
|
||||
lua_test("file/judge-xt.lua",self.scheme,d)
|
||||
with open("./file/save.csv","+a") as f:
|
||||
with open(self.save_file,"+a") as f:
|
||||
f.write(s+'\n')
|
||||
|
||||
# 把两个字节拼为一个int
|
||||
def hex2int(self,d:bytearray):
|
||||
s=""
|
||||
for i in range(len(d)//2):
|
||||
s+=str(d[i*2]|(d[i*2+1]<<8))+','
|
||||
return s
|
||||
|
||||
# 把数据转换为二进制字符串
|
||||
def hex2bit(self,d:bytearray):
|
||||
s=""
|
||||
for i in range(len(d)*8):
|
||||
|
@@ -58,7 +58,7 @@ class port:
|
||||
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)
|
||||
self.ser=utcp(bsp)
|
||||
def start_recv(self):
|
||||
self.thread_ = threading.Thread(target=self.recv, args=())
|
||||
self.thread_.start()
|
||||
@@ -123,7 +123,7 @@ class port:
|
||||
length=data[8]|(data[9]<<8)|(data[10]<<16)|(data[11]<<24)
|
||||
self.num_to_recv=5+length+2
|
||||
if(self.num_to_recv>0 and self.num_to_recv==len(data)):
|
||||
# print("recv:",data.hex(" "))
|
||||
print("recv:",data.hex(" "))
|
||||
return self.decode(data)
|
||||
def encode(self,data:bytearray):
|
||||
t=bytearray()
|
||||
@@ -148,10 +148,10 @@ class port:
|
||||
# print("send:",d.hex(","))
|
||||
self.ser.write(d)
|
||||
# 测试批检仪
|
||||
def checker_test(self,times:int,scheme:str):
|
||||
def checker_test(self,times:int,scheme:str,script:str):
|
||||
print("批检仪测试:")
|
||||
tick=0
|
||||
save=checker_save.save(scheme)
|
||||
save=checker_save.save(scheme,script)
|
||||
data=bytearray()
|
||||
while(tick<times):
|
||||
tick+=1
|
||||
@@ -175,5 +175,5 @@ if __name__ == "__main__":
|
||||
p=port()
|
||||
# 批检仪测试
|
||||
# p.open("com5",115200)
|
||||
p.open("utcp",115200)
|
||||
p.checker_test(5,"file/EX_Coder_Test_2023-07-4.json")
|
||||
p.open("utcp",9527)
|
||||
p.checker_test(5000,"file/EX_Coder_Test_2023-07-4.json","file/judge-xt.lua")
|
||||
|
@@ -11,6 +11,237 @@
|
||||
"TimeOutM": 10,
|
||||
"TimeOutUI": 12,
|
||||
"TaskIDMax": 26,
|
||||
|
||||
|
||||
"MajorErrInfo": [
|
||||
{
|
||||
"Info": "执行成功",
|
||||
"MajorErrCode": 0,
|
||||
"SubErrCode": []
|
||||
},
|
||||
{
|
||||
"Info": "检测器异常",
|
||||
"MajorErrCode": 1,
|
||||
"SubErrCode": [
|
||||
21,
|
||||
23,
|
||||
254
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "主电容异常",
|
||||
"MajorErrCode": 2,
|
||||
"SubErrCode": [
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
42
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "接触异常",
|
||||
"MajorErrCode": 3,
|
||||
"SubErrCode": [
|
||||
27
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "桥丝阻值异常",
|
||||
"MajorErrCode": 4,
|
||||
"SubErrCode": [
|
||||
30,
|
||||
41,
|
||||
42
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "芯片异常",
|
||||
"MajorErrCode": 5,
|
||||
"SubErrCode": [
|
||||
22,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "其他异常",
|
||||
"MajorErrCode": 20,
|
||||
"SubErrCode": [
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "通信失败",
|
||||
"MajorErrCode": 208,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "脚本执行失败",
|
||||
"MajorErrCode": 209,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "数据长度与方案不符",
|
||||
"MajorErrCode": 210,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "方案ID不符",
|
||||
"MajorErrCode": 211,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "检测项目不足,无法判定",
|
||||
"MajorErrCode": 212,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "数据不合规",
|
||||
"MajorErrCode": 213,
|
||||
"SubErrCode": [
|
||||
]
|
||||
}
|
||||
],
|
||||
"SubErrInfo": [
|
||||
{
|
||||
"Info": "预设电压异常",
|
||||
"ErrCode": 21
|
||||
},
|
||||
{
|
||||
"Info": "上电充能错误",
|
||||
"ErrCode": 22
|
||||
},
|
||||
{
|
||||
"Info": "电压设置异常",
|
||||
"ErrCode": 23
|
||||
},
|
||||
{
|
||||
"Info": "UID扫描错误",
|
||||
"ErrCode": 24
|
||||
},
|
||||
{
|
||||
"Info": "OTP错误",
|
||||
"ErrCode": 25
|
||||
},
|
||||
{
|
||||
"Info": "通讯电流错误",
|
||||
"ErrCode": 26
|
||||
},
|
||||
{
|
||||
"Info": "基本电流错误",
|
||||
"ErrCode": 27
|
||||
},
|
||||
{
|
||||
"Info": "读取芯片ID错误",
|
||||
"ErrCode": 28
|
||||
},
|
||||
{
|
||||
"Info": "密码验证错误",
|
||||
"ErrCode": 29
|
||||
},
|
||||
{
|
||||
"Info": "DAC比较错误",
|
||||
"ErrCode": 30
|
||||
},
|
||||
{
|
||||
"Info": "高压充能错误",
|
||||
"ErrCode": 31
|
||||
},
|
||||
{
|
||||
"Info": "充电电流错误",
|
||||
"ErrCode": 32
|
||||
},
|
||||
{
|
||||
"Info": "高压充末电流错误",
|
||||
"ErrCode": 33
|
||||
},
|
||||
{
|
||||
"Info": "低压充电能量错误",
|
||||
"ErrCode": 34
|
||||
},
|
||||
{
|
||||
"Info": "低压充末电流错误",
|
||||
"ErrCode": 35
|
||||
},
|
||||
{
|
||||
"Info": "写延时错误",
|
||||
"ErrCode": 36
|
||||
},
|
||||
{
|
||||
"Info": "读延时错误",
|
||||
"ErrCode": 37
|
||||
},
|
||||
{
|
||||
"Info": "芯片程测错误",
|
||||
"ErrCode": 38
|
||||
},
|
||||
{
|
||||
"Info": "时钟校准错误",
|
||||
"ErrCode": 39
|
||||
},
|
||||
{
|
||||
"Info": "写工厂信息错误",
|
||||
"ErrCode": 40
|
||||
},
|
||||
{
|
||||
"Info": "模拟起爆错误",
|
||||
"ErrCode": 41
|
||||
},
|
||||
{
|
||||
"Info": "芯片状态码异常",
|
||||
"ErrCode": 42
|
||||
},
|
||||
{
|
||||
"Info": "通信电流错误",
|
||||
"ErrCode": 43
|
||||
},
|
||||
{
|
||||
"Info": "反码时长错误",
|
||||
"ErrCode": 44
|
||||
},
|
||||
{
|
||||
"Info": "复位放电错误",
|
||||
"ErrCode": 45
|
||||
},
|
||||
{
|
||||
"Info": "检测器执行异常",
|
||||
"ErrCode": 254
|
||||
},
|
||||
{
|
||||
"Info": "返回参数判断",
|
||||
"ErrCode": 255
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
"TaskArray": [
|
||||
{
|
||||
"TaskID": 0,
|
||||
|
785
python/file/EX_Coder_Test_2023-07-6.json
Normal file
785
python/file/EX_Coder_Test_2023-07-6.json
Normal file
@@ -0,0 +1,785 @@
|
||||
{
|
||||
"PlanID": 48631940,
|
||||
"PlanBrief": "模拟工厂注码",
|
||||
"CheckSoftVersion": [
|
||||
1
|
||||
],
|
||||
"CheckHardVersion": [
|
||||
1
|
||||
],
|
||||
"TimeOutS": 4,
|
||||
"TimeOutM": 10,
|
||||
"TimeOutUI": 12,
|
||||
"TaskIDMax": 26,
|
||||
"TaskArray": [
|
||||
{
|
||||
"TaskID": 0,
|
||||
"TaskBrief": "电源准备",
|
||||
"TaskIndex": 0,
|
||||
"ParamCount": 1,
|
||||
"ParamInfo": [
|
||||
"预设电压1"
|
||||
],
|
||||
"ParamVal": [
|
||||
88
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 1,
|
||||
"TaskBrief": "上电充能",
|
||||
"TaskIndex": 1,
|
||||
"ParamCount": 3,
|
||||
"ParamInfo": [
|
||||
"总线电压",
|
||||
"采样超时0.1ms",
|
||||
"计时启停ADC"
|
||||
],
|
||||
"ParamVal": [
|
||||
88,
|
||||
5000,
|
||||
400
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 95,
|
||||
"Min": 80
|
||||
},
|
||||
{
|
||||
"Max": 800,
|
||||
"Min": 100
|
||||
}
|
||||
],
|
||||
"ReturnCount": 2,
|
||||
"ReturnInfo": [
|
||||
"总线电压",
|
||||
"大于启停的时间"
|
||||
],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
23,
|
||||
22
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 5,
|
||||
"TaskBrief": "写配置参数",
|
||||
"TaskIndex": 2,
|
||||
"ParamCount": 4,
|
||||
"ParamInfo": [
|
||||
"UID长度",
|
||||
"密码长度",
|
||||
"电流挡位",
|
||||
"版本号"
|
||||
],
|
||||
"ParamVal": [
|
||||
8,
|
||||
4,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 28,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 1
|
||||
},
|
||||
{
|
||||
"TaskID": 32,
|
||||
"TaskBrief": "加载配置",
|
||||
"TaskIndex": 3,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 8,
|
||||
"Min": 8
|
||||
},
|
||||
{
|
||||
"Max": 4,
|
||||
"Min": 4
|
||||
},
|
||||
{
|
||||
"Max": 1,
|
||||
"Min": 1
|
||||
}
|
||||
],
|
||||
"ReturnCount": 3,
|
||||
"ReturnInfo": [
|
||||
"UID长度",
|
||||
"密码长度",
|
||||
"版本号"
|
||||
],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 29,
|
||||
"ResultErrCode": [
|
||||
29,
|
||||
29,
|
||||
29,
|
||||
255
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 3,
|
||||
"TaskBrief": "获取总线电流(0.1uA)",
|
||||
"TaskIndex": 4,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 400,
|
||||
"Min": 120
|
||||
},
|
||||
{
|
||||
"Max": 400,
|
||||
"Min": 120
|
||||
}
|
||||
],
|
||||
"ReturnCount": 2,
|
||||
"ReturnInfo": [
|
||||
"总线正电流",
|
||||
"总线反电流"
|
||||
],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
27,
|
||||
27
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 4,
|
||||
"TaskBrief": "扫描UID",
|
||||
"TaskIndex": 5,
|
||||
"ParamCount": 2,
|
||||
"ParamInfo": [
|
||||
"UID长度",
|
||||
"使1/失0UID对比"
|
||||
],
|
||||
"ParamVal": [
|
||||
8,
|
||||
0
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 14,
|
||||
"ExecuteErrCode": 24,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 11,
|
||||
"TaskBrief": "桥丝检测",
|
||||
"TaskIndex": 6,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 240,
|
||||
"Min": 0
|
||||
}
|
||||
],
|
||||
"ReturnCount": 1,
|
||||
"ReturnInfo": [
|
||||
"桥丝ADC"
|
||||
],
|
||||
"ErrJumpTo": 14,
|
||||
"ExecuteErrCode": 30,
|
||||
"ResultErrCode": [
|
||||
30
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 8,
|
||||
"TaskBrief": "充能统计",
|
||||
"TaskIndex": 7,
|
||||
"ParamCount": 5,
|
||||
"ParamInfo": [
|
||||
"充电挡位",
|
||||
"统计超时",
|
||||
"电流判线AD",
|
||||
"充电结束值0.1uA",
|
||||
"充电超时0.1S"
|
||||
],
|
||||
"ParamVal": [
|
||||
34,
|
||||
5000,
|
||||
100,
|
||||
600,
|
||||
5
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 4000,
|
||||
"Min": 1000
|
||||
},
|
||||
{
|
||||
"Max": 600,
|
||||
"Min": 120
|
||||
},
|
||||
{
|
||||
"Max": 100,
|
||||
"Min": 10
|
||||
}
|
||||
],
|
||||
"ReturnCount": 3,
|
||||
"ReturnInfo": [
|
||||
"充能值0.1ms",
|
||||
"充末电流0.1uA",
|
||||
"最大充电电流0.1mA"
|
||||
],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [
|
||||
34,
|
||||
35,
|
||||
32,
|
||||
255
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 24,
|
||||
"TaskBrief": "状态码检测",
|
||||
"TaskIndex": 8,
|
||||
"ParamCount": 2,
|
||||
"ParamInfo": [
|
||||
"比较掩码",
|
||||
"比较位"
|
||||
],
|
||||
"ParamVal": [
|
||||
130,
|
||||
0
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 255,
|
||||
"Min": 0
|
||||
}
|
||||
],
|
||||
"ReturnCount": 1,
|
||||
"ReturnInfo": [
|
||||
"状态值"
|
||||
],
|
||||
"ErrJumpTo": 14,
|
||||
"ExecuteErrCode": 46,
|
||||
"ResultErrCode": [
|
||||
46
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 26,
|
||||
"TaskBrief": "复位",
|
||||
"TaskIndex": 9,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 9,
|
||||
"TaskBrief": "设置现场值",
|
||||
"TaskIndex": 10,
|
||||
"ParamCount": 3,
|
||||
"ParamInfo": [
|
||||
"编号",
|
||||
"延时",
|
||||
"孔号"
|
||||
],
|
||||
"ParamVal": [
|
||||
20,
|
||||
100,
|
||||
20
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 19,
|
||||
"TaskBrief": "时钟校准",
|
||||
"TaskIndex": 11,
|
||||
"ParamCount": 3,
|
||||
"ParamInfo": [
|
||||
" 1快速0全",
|
||||
"校准周期",
|
||||
"校准时长"
|
||||
],
|
||||
"ParamVal": [
|
||||
0,
|
||||
1000,
|
||||
110
|
||||
],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 24,
|
||||
"TaskBrief": "状态码检测",
|
||||
"TaskIndex": 12,
|
||||
"ParamCount": 2,
|
||||
"ParamInfo": [
|
||||
"比较掩码",
|
||||
"比较位"
|
||||
],
|
||||
"ParamVal": [
|
||||
10,
|
||||
10
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 255,
|
||||
"Min": 0
|
||||
}
|
||||
],
|
||||
"ReturnCount": 1,
|
||||
"ReturnInfo": [
|
||||
"状态值"
|
||||
],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 46,
|
||||
"ResultErrCode": [
|
||||
255
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 10,
|
||||
"TaskBrief": "比对现场值",
|
||||
"TaskIndex": 13,
|
||||
"ParamCount": 4,
|
||||
"ParamInfo": [
|
||||
"编号",
|
||||
"延时",
|
||||
"孔号",
|
||||
"1使/0失反馈采集"
|
||||
],
|
||||
"ParamVal": [
|
||||
20,
|
||||
100,
|
||||
20,
|
||||
1
|
||||
],
|
||||
"TestStandard": [
|
||||
{
|
||||
"Max": 1700,
|
||||
"Min": 800
|
||||
},
|
||||
{
|
||||
"Max": 400,
|
||||
"Min": 150
|
||||
}
|
||||
],
|
||||
"ReturnCount": 2,
|
||||
"ReturnInfo": [
|
||||
"最大反馈电流",
|
||||
"最大反馈时间"
|
||||
],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 255,
|
||||
"ResultErrCode": [
|
||||
43,
|
||||
44,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"RetryCount": 0
|
||||
},
|
||||
{
|
||||
"TaskID": 27,
|
||||
"TaskBrief": "关总线",
|
||||
"TaskIndex": 14,
|
||||
"ParamCount": 0,
|
||||
"ParamInfo": [],
|
||||
"ParamVal": [],
|
||||
"TestStandard": [],
|
||||
"ReturnCount": 0,
|
||||
"ReturnInfo": [],
|
||||
"ErrJumpTo": 255,
|
||||
"ExecuteErrCode": 254,
|
||||
"ResultErrCode": [],
|
||||
"RetryCount": 0
|
||||
}
|
||||
],
|
||||
"MajorErrInfo": [
|
||||
{
|
||||
"Info": "执行成功",
|
||||
"MajorErrCode": 0,
|
||||
"SubErrCode": []
|
||||
},
|
||||
{
|
||||
"Info": "检测器异常",
|
||||
"MajorErrCode": 1,
|
||||
"SubErrCode": [
|
||||
21,
|
||||
23,
|
||||
254
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "主电容异常",
|
||||
"MajorErrCode": 2,
|
||||
"SubErrCode": [
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
42
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "接触异常",
|
||||
"MajorErrCode": 3,
|
||||
"SubErrCode": [
|
||||
27
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "桥丝阻值异常",
|
||||
"MajorErrCode": 4,
|
||||
"SubErrCode": [
|
||||
30,
|
||||
41,
|
||||
42
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "芯片异常",
|
||||
"MajorErrCode": 5,
|
||||
"SubErrCode": [
|
||||
22,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "其他异常",
|
||||
"MajorErrCode": 20,
|
||||
"SubErrCode": [
|
||||
255
|
||||
]
|
||||
}
|
||||
],
|
||||
"SubErrInfo": [
|
||||
{
|
||||
"Info": "预设电压异常",
|
||||
"ErrCode": 21,
|
||||
"ErrFac": [
|
||||
"1.检测小板电压调节失效,存在无法设置的电压"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "上电充能错误",
|
||||
"ErrCode": 22,
|
||||
"ErrFac": [
|
||||
"1.检测器输出电压异常",
|
||||
"2.模块上电容性负载大",
|
||||
"3.模块基本电路异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "电压设置异常",
|
||||
"ErrCode": 23,
|
||||
"ErrFac": [
|
||||
"1.检测小板输出电压异常",
|
||||
"2.外部短路,导致过流保护"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "UID扫描错误",
|
||||
"ErrCode": 24,
|
||||
"ErrFac": [
|
||||
"1.芯片通信异常",
|
||||
"2.芯片内部存储的UID与参考UID不一致"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "标记区验证错误",
|
||||
"ErrCode": 25,
|
||||
"ErrFac": [
|
||||
"1.验证标志位没有置位(检测流程出错",
|
||||
"2.芯片数据被擦写",
|
||||
"3.通信异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "通讯后电流错误",
|
||||
"ErrCode": 26,
|
||||
"ErrFac": [
|
||||
"1.芯片执行指令异常",
|
||||
"2.芯片通信接收功耗异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "基本电流错误",
|
||||
"ErrCode": 27,
|
||||
"ErrFac": [
|
||||
"1.芯片的静态功耗异常",
|
||||
"2.检测器输出电压异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "配置错误",
|
||||
"ErrCode": 28,
|
||||
"ErrFac": [
|
||||
"1.芯片错误",
|
||||
"2.通信异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "验证配置",
|
||||
"ErrCode": 29,
|
||||
"ErrFac": [
|
||||
"1.芯片内部数据与检测数据不一致,数据丢失",
|
||||
"2.芯片通信异常",
|
||||
"3.芯片数据被改写"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "桥丝错误",
|
||||
"ErrCode": 30,
|
||||
"ErrFac": [
|
||||
"1.桥丝开路,或阻值异常",
|
||||
"2.芯片异常,检测不准"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "高压充能错误",
|
||||
"ErrCode": 31,
|
||||
"ErrFac": [
|
||||
"1.电容漏流",
|
||||
"2.电容容值偏低或偏大",
|
||||
"3.芯片充电漏流,充电回路或起爆回路",
|
||||
"4.芯片高压基本电流偏大",
|
||||
"5.芯片异常,充电电流偏小"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "充电电流错误",
|
||||
"ErrCode": 32,
|
||||
"ErrFac": [
|
||||
"1.芯片异常,充电电流符合指标"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "高压充末电流错误",
|
||||
"ErrCode": 33,
|
||||
"ErrFac": [
|
||||
"1.电容漏流",
|
||||
"2.芯片充电回路漏流或起爆回路漏流",
|
||||
"3.芯片高压基本电流偏大"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "低压充电能量错误",
|
||||
"ErrCode": 34,
|
||||
"ErrFac": [
|
||||
"1.电容漏流",
|
||||
"2.电容容值偏低或偏大",
|
||||
"3.芯片充电漏流,充电回路或起爆回路",
|
||||
"4.芯片低压基本电流偏大",
|
||||
"5.芯片异常,充电电流偏小",
|
||||
"6.高压充电后不能放电"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "低压充末电流错误",
|
||||
"ErrCode": 35,
|
||||
"ErrFac": [
|
||||
"1.电容漏流",
|
||||
"2.芯片充电回路漏流或起爆回路漏流",
|
||||
"3.芯片基本功耗偏大"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "写延时错误",
|
||||
"ErrCode": 36,
|
||||
"ErrFac": [
|
||||
"1.芯片设置延时功能异常",
|
||||
"2.通信异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "读延时错误",
|
||||
"ErrCode": 37,
|
||||
"ErrFac": [
|
||||
"1.芯片读延时功能异常",
|
||||
"2.通信异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "芯片程测错误",
|
||||
"ErrCode": 38,
|
||||
"ErrFac": [
|
||||
"1.芯片成测标记错误,非全FFFF",
|
||||
"2.通信异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "时钟校准错误",
|
||||
"ErrCode": 39,
|
||||
"ErrFac": [
|
||||
"1.检测器命令执行异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "写工厂信息错误",
|
||||
"ErrCode": 40,
|
||||
"ErrFac": [
|
||||
"1.OTP数据写入出错",
|
||||
"2.通信异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "模拟起爆错误",
|
||||
"ErrCode": 41,
|
||||
"ErrFac": [
|
||||
"1.发送起爆指令后无应答"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "芯片状态码异常",
|
||||
"ErrCode": 42,
|
||||
"ErrFac": [
|
||||
"1.状态码与设置的掩码不匹配",
|
||||
"2.通讯异常"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "反馈电流错误",
|
||||
"ErrCode": 43,
|
||||
"ErrFac": [
|
||||
"1.芯片异常,反馈电流不达标",
|
||||
"2.检测器异常,采集电路不准"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "反码时长错误",
|
||||
"ErrCode": 44,
|
||||
"ErrFac": [
|
||||
"1.芯片异常,通讯无反码",
|
||||
"2.通讯反码电流低,不能识别"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "复位放电错误",
|
||||
"ErrCode": 45,
|
||||
"ErrFac": [
|
||||
"1.高压充电后降压通讯异常",
|
||||
"2.芯片复位不能正常放电",
|
||||
"3.芯片异常,指令不执行"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "状态标志错误",
|
||||
"ErrCode": 46,
|
||||
"ErrFac": [
|
||||
"1.置位标志命令未执行",
|
||||
"2.置位命令参数错误",
|
||||
"3.电容电压检测失败",
|
||||
"4,芯片异常,状态标志不能置位"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "三码验证错误",
|
||||
"ErrCode": 47,
|
||||
"ErrFac": [
|
||||
"1.扫描获取的UID和写入的UID不一致",
|
||||
"2.密码不一致,验证标志位未置位",
|
||||
"3.芯片状态标志异常,不能置位"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "写管壳码",
|
||||
"ErrCode": 48,
|
||||
"ErrFac": [
|
||||
"1.缓存空间数据验证错误",
|
||||
"2.指令执行错误,未收到应答",
|
||||
"3.芯片功能异常,指令执行失败"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "写密码",
|
||||
"ErrCode": 49,
|
||||
"ErrFac": [
|
||||
"1.缓存空间数据验证错误",
|
||||
"2.指令执行错误,未收到应答",
|
||||
"3.芯片功能异常,指令执行失败"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "写现场值错误",
|
||||
"ErrCode": 50,
|
||||
"ErrFac": [
|
||||
"1.UID不匹配",
|
||||
"2.芯片内部的配置未设置正确",
|
||||
"3.芯片功能异常,通信无反馈"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "检测器执行异常",
|
||||
"ErrCode": 254,
|
||||
"ErrFac": [
|
||||
"广播类命令执行错误"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "返回参数判断",
|
||||
"ErrCode": 255,
|
||||
"ErrFac": []
|
||||
}
|
||||
]
|
||||
}
|
BIN
python/file/EX_Coder_Test_2023-07-6.xlsx
Normal file
BIN
python/file/EX_Coder_Test_2023-07-6.xlsx
Normal file
Binary file not shown.
@@ -14,231 +14,6 @@
|
||||
"TimeOutM": 40,
|
||||
"TimeOutUI": 42,
|
||||
"TaskIDMax": 26,
|
||||
"MajorErrInfo": [
|
||||
{
|
||||
"Info": "执行成功",
|
||||
"MajorErrCode": 0,
|
||||
"SubErrCode": []
|
||||
},
|
||||
{
|
||||
"Info": "检测器异常",
|
||||
"MajorErrCode": 1,
|
||||
"SubErrCode": [
|
||||
21,
|
||||
23,
|
||||
254
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "主电容异常",
|
||||
"MajorErrCode": 2,
|
||||
"SubErrCode": [
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
42
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "接触异常",
|
||||
"MajorErrCode": 3,
|
||||
"SubErrCode": [
|
||||
27
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "桥丝阻值异常",
|
||||
"MajorErrCode": 4,
|
||||
"SubErrCode": [
|
||||
30,
|
||||
41,
|
||||
42
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "芯片异常",
|
||||
"MajorErrCode": 5,
|
||||
"SubErrCode": [
|
||||
22,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "其他异常",
|
||||
"MajorErrCode": 20,
|
||||
"SubErrCode": [
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "通信失败",
|
||||
"MajorErrCode": 208,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "脚本执行失败",
|
||||
"MajorErrCode": 209,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "数据长度与方案不符",
|
||||
"MajorErrCode": 210,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "方案ID不符",
|
||||
"MajorErrCode": 211,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "检测项目不足,无法判定",
|
||||
"MajorErrCode": 212,
|
||||
"SubErrCode": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"Info": "数据不合规",
|
||||
"MajorErrCode": 213,
|
||||
"SubErrCode": [
|
||||
]
|
||||
}
|
||||
],
|
||||
"SubErrInfo": [
|
||||
{
|
||||
"Info": "预设电压异常",
|
||||
"ErrCode": 21
|
||||
},
|
||||
{
|
||||
"Info": "上电充能错误",
|
||||
"ErrCode": 22
|
||||
},
|
||||
{
|
||||
"Info": "电压设置异常",
|
||||
"ErrCode": 23
|
||||
},
|
||||
{
|
||||
"Info": "UID扫描错误",
|
||||
"ErrCode": 24
|
||||
},
|
||||
{
|
||||
"Info": "OTP错误",
|
||||
"ErrCode": 25
|
||||
},
|
||||
{
|
||||
"Info": "通讯电流错误",
|
||||
"ErrCode": 26
|
||||
},
|
||||
{
|
||||
"Info": "基本电流错误",
|
||||
"ErrCode": 27
|
||||
},
|
||||
{
|
||||
"Info": "读取芯片ID错误",
|
||||
"ErrCode": 28
|
||||
},
|
||||
{
|
||||
"Info": "密码验证错误",
|
||||
"ErrCode": 29
|
||||
},
|
||||
{
|
||||
"Info": "DAC比较错误",
|
||||
"ErrCode": 30
|
||||
},
|
||||
{
|
||||
"Info": "高压充能错误",
|
||||
"ErrCode": 31
|
||||
},
|
||||
{
|
||||
"Info": "充电电流错误",
|
||||
"ErrCode": 32
|
||||
},
|
||||
{
|
||||
"Info": "高压充末电流错误",
|
||||
"ErrCode": 33
|
||||
},
|
||||
{
|
||||
"Info": "低压充电能量错误",
|
||||
"ErrCode": 34
|
||||
},
|
||||
{
|
||||
"Info": "低压充末电流错误",
|
||||
"ErrCode": 35
|
||||
},
|
||||
{
|
||||
"Info": "写延时错误",
|
||||
"ErrCode": 36
|
||||
},
|
||||
{
|
||||
"Info": "读延时错误",
|
||||
"ErrCode": 37
|
||||
},
|
||||
{
|
||||
"Info": "芯片程测错误",
|
||||
"ErrCode": 38
|
||||
},
|
||||
{
|
||||
"Info": "时钟校准错误",
|
||||
"ErrCode": 39
|
||||
},
|
||||
{
|
||||
"Info": "写工厂信息错误",
|
||||
"ErrCode": 40
|
||||
},
|
||||
{
|
||||
"Info": "模拟起爆错误",
|
||||
"ErrCode": 41
|
||||
},
|
||||
{
|
||||
"Info": "芯片状态码异常",
|
||||
"ErrCode": 42
|
||||
},
|
||||
{
|
||||
"Info": "通信电流错误",
|
||||
"ErrCode": 43
|
||||
},
|
||||
{
|
||||
"Info": "反码时长错误",
|
||||
"ErrCode": 44
|
||||
},
|
||||
{
|
||||
"Info": "复位放电错误",
|
||||
"ErrCode": 45
|
||||
},
|
||||
{
|
||||
"Info": "检测器执行异常",
|
||||
"ErrCode": 254
|
||||
},
|
||||
{
|
||||
"Info": "返回参数判断",
|
||||
"ErrCode": 255
|
||||
}
|
||||
],
|
||||
"TaskArray": [
|
||||
{
|
||||
"TaskID": 0,
|
||||
|
@@ -22,13 +22,10 @@
|
||||
|
||||
|
||||
|
||||
-- 读取方案配置信息
|
||||
-- print(cfg_name)
|
||||
check_cfg_file=io.open(cfg_name,"r")
|
||||
check_cfg_str=check_cfg_file:read("*a")
|
||||
check_cfg_file:close()
|
||||
json_table = json:decode(check_cfg_str)
|
||||
|
||||
-- 2023.7.5
|
||||
-- 调用者可以设置 check_cfg_str 变量,此时脚本不会使用io函数而直接使用
|
||||
-- 如果 check_cfg_str 为 nil 时自动读取 cfg_name 文件
|
||||
-- 改为调用main函数来运行脚本
|
||||
|
||||
|
||||
|
||||
@@ -273,7 +270,7 @@ function XT_Test_PowerOn(task,err_code)
|
||||
else
|
||||
-- 充能流程正常,返回第一个值是电压,第二个值是充能时间
|
||||
ret_value=find_return(task["TaskIndex"]+1)
|
||||
prints:print_a(ret_value)
|
||||
prints:print_a(ret_value,2)
|
||||
-- 电压无法上升,检测器异常
|
||||
if(ret_value[1]<task["TestStandard"][1]["Min"]) then
|
||||
print("voltage too low",ret_value[1])
|
||||
@@ -463,6 +460,8 @@ function judge_task(task,data)
|
||||
if range~=nil then
|
||||
-- print("judge task")
|
||||
for i=1,len(range),1 do
|
||||
-- prints:print_t(range[i])
|
||||
-- print("data=",data[i])
|
||||
if(data[i]<range[i]["Min"]) or (data[i]>range[i]["Max"]) then
|
||||
-- print("task=",task["TaskBrief"],"out of range:")
|
||||
-- print("err code=",task["ResultErrCode"][i])
|
||||
@@ -481,12 +480,15 @@ function judge_list()
|
||||
local ack=find_ack(i,acks)
|
||||
local task_p=json_table["TaskArray"][i]
|
||||
local ret_value=find_return(i)
|
||||
-- print("taskindex:",task_p["TaskIndex"])
|
||||
local err_code=judge_task(task_p,ret_value)
|
||||
-- print("err_code:")
|
||||
-- prints:print_a(err_code)
|
||||
if ack==false then
|
||||
table.insert(err_code,task_p["ExecuteErrCode"])
|
||||
end
|
||||
if len(err_code)>0 then
|
||||
print("task:",task_p["TaskBrief"],"err_code:")
|
||||
-- print("task:",task_p["TaskBrief"],"err_code:")
|
||||
prints:print_a(err_code)
|
||||
return get_err_code(err_code)
|
||||
end
|
||||
@@ -519,6 +521,14 @@ end
|
||||
|
||||
|
||||
function main()
|
||||
-- 读取方案配置信息
|
||||
-- print(cfg_name)
|
||||
if(check_cfg_str==nil)then
|
||||
check_cfg_file=io.open(cfg_name,"r")
|
||||
check_cfg_str=check_cfg_file:read("*a")
|
||||
check_cfg_file:close()
|
||||
end
|
||||
json_table = json:decode(check_cfg_str)
|
||||
check_erryternum=clac_cfg_errbytenum()
|
||||
local err_str_table={"检测器异常","主电容异常","接触异常","桥丝阻值异常","芯片异常"}
|
||||
local ch_err,ch_code=check_env()
|
||||
@@ -554,7 +564,7 @@ end
|
||||
|
||||
|
||||
-- 先返回错误描述,再返回错误码
|
||||
return main()
|
||||
-- return main()
|
||||
|
||||
|
||||
|
||||
|
@@ -147,6 +147,8 @@ def arr_from_int(num:int):
|
||||
def scheme_get_task_range(j:json):
|
||||
t=bytearray()
|
||||
return_count=j["ReturnCount"]
|
||||
t+=j["TaskID"]
|
||||
t+=j["TaskIndex"]
|
||||
t+=arr_from_int(return_count)
|
||||
t+=arr_from_int(j["ExecuteErrCode"])
|
||||
index=0
|
||||
|
@@ -132,4 +132,8 @@
|
||||
2023.7.3
|
||||
检测错误码
|
||||
解决tcp下升级方案死机的问题,原因是内存没有回收导致的内存不足
|
||||
2023.7.6
|
||||
UID转存储码特征码从*10000改为*100000
|
||||
赋码仪接收上位机的0x81,0x82回复
|
||||
添加错误判断,未完成
|
||||
|
215
source/coder/coder_judge.c
Normal file
215
source/coder/coder_judge.c
Normal file
@@ -0,0 +1,215 @@
|
||||
#include "coder_judge.h"
|
||||
#include "dev_flash.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
// <20><>d<EFBFBD><64><EFBFBD><EFBFBD> a<>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
||||
static void c_insert(uint8_t *a,uint8_t d)
|
||||
{
|
||||
int len=sizeof(uint8_t [6]);
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
if(a[i]==d)
|
||||
return;
|
||||
}
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
if(a[i]==0xff){
|
||||
a[i]=d;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ɾ<><C9BE>a<EFBFBD>е<EFBFBD>ֵd
|
||||
static void c_del(uint8_t *a,uint8_t d)
|
||||
{
|
||||
int len=sizeof(uint8_t [6]);
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
if(a[i]==d){
|
||||
memcpy(&a[i],&a[i+1],len-i-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ɾ<><C9BE>a<EFBFBD>г<EFBFBD>d֮<64><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
static void c_only(uint8_t *a,uint8_t d)
|
||||
{
|
||||
int len=sizeof(uint8_t [6]);
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
if(a[i]==d)
|
||||
{
|
||||
memset(a,0xff,len);
|
||||
a[0]=d;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>û<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ȫ<EFBFBD><C8AB>ɾ<EFBFBD><C9BE>
|
||||
memset(a,0xff,len);
|
||||
}
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC>a
|
||||
static void c_init(uint8_t *a)
|
||||
{
|
||||
int len=sizeof(uint8_t [6]);
|
||||
memset(a,0xff,len);
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>taskid<69>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
const scheme_task_def *find_task_next(int index_now,int taskid)
|
||||
{
|
||||
const scheme_def *s=check_scheme();
|
||||
const scheme_task_def *t;
|
||||
for(int i=index_now;i<s->task_num;i++)
|
||||
{
|
||||
t=&s->task[i];
|
||||
if(t->taskid==taskid)
|
||||
return t;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>index<65>IJ<EFBFBD><C4B2><EFBFBD>
|
||||
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1>index<65><78><EFBFBD><EFBFBD>Χ
|
||||
static int get_range(int index,int *min,int *max)
|
||||
{
|
||||
const scheme_def *s=check_scheme();
|
||||
const scheme_task_def *t;
|
||||
int index_p=0;
|
||||
for(int i=0;i<s->task_num;i++)
|
||||
{
|
||||
t=&s->task[i];
|
||||
for(int j=0;j<t->item_num;j++)
|
||||
{
|
||||
if(index_p==index)
|
||||
{
|
||||
if(min) *min=t->range[j].min;
|
||||
if(max) *max=t->range[j].max;
|
||||
return index_p;
|
||||
}
|
||||
index_p++;
|
||||
}
|
||||
}
|
||||
return index_p;
|
||||
}
|
||||
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1>index<65><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static int get_data(const uint8_t *data,int index)
|
||||
{
|
||||
data+=16;
|
||||
return data[index*2]|(data[index*2+1]<<8);
|
||||
}
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1>index<65><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>1<EFBFBD><31>ʧ<EFBFBD>ܣ<EFBFBD>0<EFBFBD>ɹ<EFBFBD>
|
||||
static int get_ack(const uint8_t *data,int index)
|
||||
{
|
||||
if(data[index/8]&(1<<(index%8)))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣,1
|
||||
//-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣,2
|
||||
//-- <20>Ӵ<EFBFBD><D3B4>쳣,3
|
||||
//-- <20><>˿<EFBFBD><CBBF>ֵ<EFBFBD>쳣,4
|
||||
//-- оƬ<D0BE>쳣,5
|
||||
//-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>7
|
||||
//-- <20><>·<EFBFBD><C2B7>8
|
||||
|
||||
#define TASK_RETURN(task) {\
|
||||
if(task==0) return 6; \
|
||||
else index+=1;\
|
||||
}// <20>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint8_t coder_judge(const uint8_t *data)
|
||||
{
|
||||
int temp,temp2;
|
||||
int index=0;
|
||||
const scheme_task_def *task=0;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
task=find_task_next(index,0);
|
||||
TASK_RETURN(task);
|
||||
{
|
||||
if(get_ack(data,0))
|
||||
{
|
||||
// <20>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><F3A3ACBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// <20>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
task=find_task_next(index,1);
|
||||
TASK_RETURN(task);
|
||||
{
|
||||
temp=get_data(data,0);
|
||||
if(temp<task->range[0].min)
|
||||
{
|
||||
// <20><>ѹ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
return 1;
|
||||
}
|
||||
temp=get_data(data,1);
|
||||
if((temp>39000)||(temp<1)){
|
||||
// <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
task=find_task_next(index,4);
|
||||
TASK_RETURN(task);
|
||||
temp=get_data(data,5);
|
||||
temp2=get_data(data,6);
|
||||
if((temp<10)&&(temp2<20))
|
||||
{
|
||||
// <20>Ӵ<EFBFBD><D3B4>쳣
|
||||
return 3;
|
||||
}
|
||||
else if(((temp>task->range[0].max)&&(temp<1500))||
|
||||
((temp2>task->range[0].max)&&(temp2<1500)))
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
return 7;
|
||||
}else if((temp>1500)&&(temp2>1500))
|
||||
{
|
||||
// <20><>·
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>uid
|
||||
task=find_task_next(index,5);
|
||||
TASK_RETURN(task);
|
||||
if(get_ack(data,task->taskindex))
|
||||
{
|
||||
// оƬ<D0BE><C6AC><EFBFBD><EFBFBD>
|
||||
return 5;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
|
||||
task=find_task_next(index,6);
|
||||
TASK_RETURN(task);
|
||||
temp=get_data(data,7);
|
||||
if((temp<task->range[0].min)||(temp>task->range[0].max))
|
||||
{
|
||||
// <20><>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>
|
||||
return 4;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
16
source/coder/coder_judge.h
Normal file
16
source/coder/coder_judge.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef coder_judge_h__
|
||||
#define coder_judge_h__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
|
||||
|
||||
uint8_t coder_judge(const uint8_t *data);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -129,7 +129,8 @@ int coder_uid_to_save(const char *uid_code,uint8_t *save_code)
|
||||
ymd|=coder_strint_to_byte(&uid_code[8],2);
|
||||
save_code[2]=ymd>>8;
|
||||
save_code[3]=ymd&0xff;
|
||||
feature=uid_code[10]*10000;
|
||||
// 文档 YM-UID设计V1.2 - 2023.xlsx 规定*10000,实际是*100000
|
||||
feature=uid_code[10]*100000;
|
||||
feature+=coder_strint_to_byte(&uid_code[11],3)*100;
|
||||
feature+=coder_strint_to_byte(&uid_code[14],2);
|
||||
save_code[4]=feature>>16;
|
||||
@@ -174,8 +175,8 @@ int coder_save_to_uid(const uint8_t *save_code,char *uid_code)
|
||||
ret|=coder_int_to_strint(ymd>>9,&uid_code[2],2);
|
||||
ret|=coder_int_to_strint((ymd>>5)&0x0f,&uid_code[6],2);
|
||||
ret|=coder_int_to_strint((ymd)&0x1f,&uid_code[8],2);
|
||||
uid_code[10]=feature/10000;
|
||||
ret|=coder_int_to_strint(feature%10000/100,&uid_code[11],3);
|
||||
uid_code[10]=feature/100000;
|
||||
ret|=coder_int_to_strint(feature%100000/100,&uid_code[11],3);
|
||||
ret|=coder_int_to_strint(feature%100,&uid_code[14],2);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -95,6 +95,8 @@ typedef struct{
|
||||
__packed
|
||||
typedef struct
|
||||
{
|
||||
uint32_t taskid;
|
||||
uint32_t taskindex;
|
||||
uint32_t item_num;
|
||||
uint32_t err;
|
||||
scheme_range_def range[16];
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-07-04 09:17:01"
|
||||
#define BUILD_DATE "2023-07-06 19:01:21"
|
||||
#define SOFT_VERSION "0.10"
|
||||
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "coder_lib.h"
|
||||
#include "PSDGenerate.h"
|
||||
#include "mystring.h"
|
||||
#include "coder_judge.h"
|
||||
|
||||
// 这个文件解析跟赋码仪相关的命令
|
||||
|
||||
@@ -93,6 +94,8 @@ static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *e
|
||||
emit tran_send_signal(w->u.p,0x82,arr_temp(a));
|
||||
tran_set_busy(w->u.p,0);
|
||||
g_self.step=0;
|
||||
// 把命令字改为0x82用于接收主机应答
|
||||
w->u.cmd=0x82;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +126,14 @@ static void write_del(ucport_def *u)
|
||||
}
|
||||
|
||||
|
||||
static int write_uid_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
|
||||
{
|
||||
DBG_LOG("recv write_uid end signal.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ucport_def *write_uid(tran_def *t, uint8_t cmd,array_def *data)
|
||||
{
|
||||
if(arr_length(data)<140+4+1){
|
||||
@@ -134,6 +145,7 @@ static ucport_def *write_uid(tran_def *t, uint8_t cmd,array_def *data)
|
||||
u->u.p=t;
|
||||
u->u.del=write_del;
|
||||
u->u.doend=write_uid_end;
|
||||
u->u.dolater=write_uid_dolater;
|
||||
u->addrs_num=arr_get(data,0);
|
||||
memcpy(u->year,arr_data(data)+1,4);
|
||||
DBG_LOG("coder, year=%s",u->year);
|
||||
@@ -329,7 +341,13 @@ static void check_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_s
|
||||
ack_d[3]=(errcode>>8)&0xff;
|
||||
ack_d[4]=(errcode>>16)&0xff;
|
||||
ack_d[5]=(errcode>>24)&0xff;
|
||||
if(ack_d[1]==0) ack_d[1]=ack_d[2];
|
||||
if(ack_d[1]==0){
|
||||
// 先判断主要错误,如果没有主要错误,则填充为子错误
|
||||
ack_d[1]=coder_judge(arr_data(data));
|
||||
if(ack_d[1]==0){
|
||||
ack_d[1]=ack_d[2];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}
|
||||
|
||||
@@ -342,6 +360,8 @@ static void check_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_s
|
||||
arr_appends(a,w->ack,(6)*10);
|
||||
emit tran_send_signal(w->u.p,0x81,arr_temp(a));
|
||||
tran_set_busy(w->u.p,0);
|
||||
// 把命令字改为0x81用于接收主机应答
|
||||
w->u.cmd=0x81;
|
||||
g_self.step=1;
|
||||
}
|
||||
}
|
||||
@@ -372,6 +392,11 @@ static void check_del(ucport_def *u)
|
||||
free(u);
|
||||
}
|
||||
|
||||
static int check_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
|
||||
{
|
||||
DBG_LOG("recv check end signal.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static ucport_def *check(tran_def *t, uint8_t cmd,array_def *data)
|
||||
@@ -384,6 +409,7 @@ static ucport_def *check(tran_def *t, uint8_t cmd,array_def *data)
|
||||
u->u.p=t;
|
||||
u->u.del=check_del;
|
||||
u->u.doend=check_end;
|
||||
u->u.dolater=check_dolater;
|
||||
u->addrs_num=arr_get(data,0);
|
||||
u->type=arr_get(data,0);
|
||||
// 默认失败
|
||||
|
Reference in New Issue
Block a user