添加错误代码
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
|
||||
import lupa
|
||||
from lupa import LuaRuntime
|
||||
|
||||
|
||||
class save:
|
||||
@@ -40,5 +41,17 @@ class save:
|
||||
if __name__ == "__main__":
|
||||
sa=save()
|
||||
print(sa.hex2bit(bytes([0xab,0xcd])))
|
||||
|
||||
lua = LuaRuntime(unpack_returned_tuples=True)
|
||||
save_json=lua.eval("function(a) json=a end")
|
||||
with open("file/json.lua",encoding="utf-8") as f:
|
||||
save_json(lua.execute(f.read()))
|
||||
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()))
|
||||
lua.execute("cfg_name=\"file/checker_ye_cfg.json\"\n")
|
||||
lua.execute("check_data={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}\n")
|
||||
with open("file/judge.lua",encoding="utf-8") as f:
|
||||
lua.execute(f.read())
|
||||
# lua_func = lua.eval('function(a, b) return a+b end')
|
||||
# print(lua_func(1,2))
|
||||
|
||||
|
@@ -173,5 +173,5 @@ class port:
|
||||
if __name__ == "__main__":
|
||||
p=port()
|
||||
# 批检仪测试
|
||||
p.open("utcp",0)
|
||||
p.open("com5",115200)
|
||||
p.checker_test(5)
|
||||
|
1869
python/file/json.lua
Normal file
1869
python/file/json.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,13 @@ PLAN_ID=15
|
||||
-- "方案ID不符",211
|
||||
-- "检测项目不足,无法判定",212
|
||||
-- "数据不合规",213
|
||||
|
||||
|
||||
-- 2023.5.11
|
||||
-- 修改脚本适配 雷管厂电解电容来料检测
|
||||
-- 2023.5.12
|
||||
-- 大于启停的时间从检测器异常改为芯片异常
|
||||
-- 2023.5.19
|
||||
-- 扫描uid,超出最大返回时间范围则显示芯片异常
|
||||
-- 添加起爆充能失败的判断,此时返回芯片异常
|
||||
|
||||
|
||||
|
||||
@@ -262,7 +267,7 @@ function JQ_Test_PowerPrapare(task,err_code)
|
||||
return nil
|
||||
else
|
||||
-- 上电正常,排除检测器异常
|
||||
del(err_code,1)
|
||||
-- del(err_code,1)
|
||||
print("检测上电充能")
|
||||
-- 下一步是上电充能
|
||||
return find_index(task["TaskIndex"]+2,1)
|
||||
@@ -300,8 +305,8 @@ function JQ_Test_PowerOn(task,err_code)
|
||||
print("检测电流")
|
||||
return find_index(task["TaskIndex"]+2,3)
|
||||
end
|
||||
---- 排除接触异常
|
||||
--del(err_code,3)
|
||||
---- 排除检测板异常
|
||||
del(err_code,1)
|
||||
print("检测芯片UID")
|
||||
-- 下一步检测芯片
|
||||
return find_index(task["TaskIndex"]+2,4)
|
||||
@@ -319,6 +324,13 @@ function JQ_Test_ScanUID(task,err_code)
|
||||
only(err_code,5)
|
||||
return nil
|
||||
else
|
||||
ret_value=find_return(task["TaskIndex"]+1)
|
||||
-- 最大反馈时间在范围之外,芯片异常
|
||||
if(ret_value[2]<task["TestStandard"][2]["Min"]) or (ret_value[2]>task["TestStandard"][2]["Max"]) then
|
||||
only(err_code,5)
|
||||
return nil
|
||||
end
|
||||
|
||||
print("检测电流")
|
||||
return find_index(task["TaskIndex"]+2,3)
|
||||
--print("读取芯片代码")
|
||||
@@ -416,12 +428,36 @@ function JQ_Test_BaseCurHigh(task,err_code)
|
||||
del(err_code,3)
|
||||
print("检测桥丝和电容")
|
||||
-- 下一步检测桥丝和电容
|
||||
return find_index(task["TaskIndex"]+2,12)
|
||||
return find_index(task["TaskIndex"]+2,11)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 检测充能,失败则电容异常
|
||||
function JQ_Test_ChgEnergy(task,err_code)
|
||||
if(find_ack(task["TaskIndex"]+1,mid(check_data,1,8))==false)then
|
||||
only(err_code,2)
|
||||
return nil
|
||||
else
|
||||
ret_value=find_return(task["TaskIndex"]+1)
|
||||
if((ret_value[1]>task["TestStandard"][1]["Max"]) or (ret_value[1]<task["TestStandard"][1]["Min"])) then
|
||||
only(err_code,2)
|
||||
return nil
|
||||
end
|
||||
if((ret_value[2]>task["TestStandard"][2]["Max"]) or (ret_value[2]<task["TestStandard"][2]["Min"])) then
|
||||
only(err_code,2)
|
||||
return nil
|
||||
end
|
||||
-- 排除电容异常
|
||||
del(err_code,2)
|
||||
print("检测桥丝")
|
||||
-- 下一步检测桥丝
|
||||
return find_index(task["TaskIndex"]+2,12)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 检测电容电压,返回下一个检测任务,nil停止检测
|
||||
function JQ_Test_CheckDAC(task,err_code)
|
||||
@@ -442,24 +478,39 @@ function JQ_Test_CheckDAC(task,err_code)
|
||||
only(err_code,4)
|
||||
return nil
|
||||
else
|
||||
-- 排除桥丝异常
|
||||
ret_value=find_return(task["TaskIndex"]+1)
|
||||
if((ret_value[1]>task["TestStandard"][1]["Max"]) or (ret_value[1]<task["TestStandard"][1]["Min"])) then
|
||||
only(err_code,4)
|
||||
return nil
|
||||
end
|
||||
-- 排除电容异常
|
||||
del(err_code,4)
|
||||
print("检测电容")
|
||||
return find_index(task["TaskIndex"]+2,12)
|
||||
-- 下一步检测起爆
|
||||
return find_index(task["TaskIndex"]+2,20)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 检测电容电压,返回下一个检测任务,nil停止检测
|
||||
function JQ_Test_CheckDAC2(task,err_code)
|
||||
-- 起爆充能
|
||||
function JQ_Test_BoomEnergy(task,err_code)
|
||||
if(find_ack(task["TaskIndex"]+1,mid(check_data,1,8))==false)then
|
||||
-- 检测电压失败则主电容异常
|
||||
-- 检测电压失败则桥丝或主电容异常
|
||||
print("task failed.task_index=",task["TaskIndex"])
|
||||
only(err_code,2)
|
||||
-- 这里判断上电充能值,如果偏大则桥丝异常,偏小则电容异常
|
||||
-- 充能流程正常,返回第一个值是电压,第二个值是充能时间
|
||||
-- local task_p=find_index(1,1)
|
||||
-- ret_value=find_return(task_p["TaskIndex"]+1)
|
||||
-- if(ret_value[2]>39999) then
|
||||
-- only(err_code,4)
|
||||
-- return nil
|
||||
-- else
|
||||
-- only(err_code,2)
|
||||
-- return nil
|
||||
-- end
|
||||
only(err_code,5)
|
||||
return nil
|
||||
else
|
||||
-- 排除电容异常
|
||||
del(err_code,2)
|
||||
-- 排除芯片异常,密码错误会导致起爆失败
|
||||
del(err_code,5)
|
||||
print("检测完毕")
|
||||
return nil
|
||||
@@ -469,6 +520,8 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- 定义占位函数,不应该调用
|
||||
function JQ_Test_Empty(task,err_code)
|
||||
print("err function call,task index=",task["TaskIndex"])
|
||||
@@ -479,18 +532,29 @@ end
|
||||
|
||||
-- 这个数组根据方案检测顺序确定
|
||||
tasks_judge_fun={
|
||||
JQ_Test_PowerPrapare,
|
||||
JQ_Test_PowerOn,
|
||||
JQ_Test_ScanUID,
|
||||
JQ_Test_BaseCurLow,
|
||||
JQ_Test_ReadChipID,
|
||||
JQ_Test_Empty,
|
||||
JQ_Test_BaseCurHigh,
|
||||
JQ_Test_Empty,
|
||||
JQ_Test_CheckDAC,
|
||||
JQ_Test_Empty,
|
||||
JQ_Test_Empty,
|
||||
JQ_Test_CheckDAC2
|
||||
JQ_Test_PowerPrapare,--0
|
||||
JQ_Test_PowerOn,--1
|
||||
JQ_Test_ScanUID,--2
|
||||
JQ_Test_BaseCurLow,--3
|
||||
JQ_Test_ReadChipID,--4
|
||||
JQ_Test_Empty,--5
|
||||
JQ_Test_Empty,--6
|
||||
JQ_Test_Empty,--7
|
||||
JQ_Test_BaseCurHigh,--8
|
||||
JQ_Test_Empty,--9
|
||||
JQ_Test_Empty,--10
|
||||
JQ_Test_Empty,--11
|
||||
JQ_Test_Empty,--12
|
||||
JQ_Test_Empty,--13
|
||||
JQ_Test_Empty,--14
|
||||
JQ_Test_Empty,--15
|
||||
JQ_Test_Empty,--16
|
||||
JQ_Test_ChgEnergy,--17 充能统计
|
||||
JQ_Test_Empty,--18
|
||||
JQ_Test_CheckDAC,--19
|
||||
JQ_Test_Empty,--20
|
||||
JQ_Test_Empty,--21
|
||||
JQ_Test_BoomEnergy,--22
|
||||
}
|
||||
|
||||
|
||||
|
84
python/file/prints.lua
Normal file
84
python/file/prints.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
|
||||
|
||||
module = {}
|
||||
|
||||
function module:print_t ( t )
|
||||
local print_r_cache={}
|
||||
local function sub_print_r(t,indent)
|
||||
if (print_r_cache[tostring(t)]) then
|
||||
print(indent.."*"..tostring(t))
|
||||
else
|
||||
print_r_cache[tostring(t)]=true
|
||||
if (type(t)=="table") then
|
||||
for pos,val in pairs(t) do
|
||||
if (type(val)=="table") then
|
||||
print(indent.."["..pos.."] => "..tostring(t).." {")
|
||||
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
|
||||
print(indent..string.rep(" ",string.len(pos)+6).."}")
|
||||
elseif (type(val)=="string") then
|
||||
print(indent.."["..pos..'] => "'..val..'"')
|
||||
else
|
||||
print(indent.."["..pos.."] => "..tostring(val))
|
||||
end
|
||||
end
|
||||
else
|
||||
print(indent..tostring(t))
|
||||
end
|
||||
end
|
||||
end
|
||||
if (type(t)=="table") then
|
||||
print(tostring(t).." {")
|
||||
sub_print_r(t," ")
|
||||
print("}")
|
||||
else
|
||||
sub_print_r(t," ")
|
||||
end
|
||||
print()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function byte_to_hex(byte,size)
|
||||
local str_table="0123456789ABCDEF"
|
||||
local str_ret=""
|
||||
if(size==2) then
|
||||
str_ret=string.char(
|
||||
string.byte( str_table,((byte>>12)&0xf)+1),
|
||||
string.byte( str_table,((byte>>8)&0xf)+1),
|
||||
string.byte( str_table,((byte>>4)&0xf)+1),
|
||||
string.byte(str_table,(byte&0xf)+1))
|
||||
else
|
||||
str_ret=string.char(string.byte(str_table,(byte%256)//16+1),string.byte(str_table,(byte%256)%16+1))
|
||||
end
|
||||
return str_ret
|
||||
end
|
||||
|
||||
-- function byte_to_num(byte)
|
||||
-- local str_ret=""
|
||||
-- while true do
|
||||
|
||||
|
||||
-- 打印数组
|
||||
function module:print_a ( a,size ,fmt)
|
||||
local str=""
|
||||
if(a==nil) then return end
|
||||
if(size==nil) then size=1 end
|
||||
for pos,val in pairs(a) do
|
||||
str=str..byte_to_hex(val,size)..", "
|
||||
end
|
||||
print(str)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function module:__tostring()
|
||||
return "print table package"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return module
|
@@ -147,13 +147,23 @@ def arr_from_int(num:int):
|
||||
def scheme_get_task_range(j:json):
|
||||
t=bytearray()
|
||||
return_count=j["ReturnCount"]
|
||||
t+=arr_from_int(return_count)
|
||||
t+=arr_from_int(j["ExecuteErrCode"])
|
||||
index=0
|
||||
for i in j["TestStandard"]:
|
||||
t+=arr_from_int(i["Max"])
|
||||
t+=arr_from_int(i["Min"])
|
||||
n=return_count-len(j["TestStandard"])
|
||||
if (index<len(j["ResultErrCode"])):
|
||||
t+=arr_from_int(j["ResultErrCode"][index])
|
||||
else:
|
||||
t+=arr_from_int(0)
|
||||
index+=1
|
||||
# 不足16的部分填充为16
|
||||
n=16-len(j["TestStandard"])
|
||||
for i in range(n):
|
||||
t+=arr_from_int(65535)
|
||||
t+=arr_from_int(0)
|
||||
t+=arr_from_int(0)
|
||||
return t
|
||||
|
||||
# 根据方案生成主板用的字节数据
|
||||
@@ -161,11 +171,9 @@ def scheme_to_host(j:json):
|
||||
t=bytearray()
|
||||
t+=arr_from_int(j["PlanID"])
|
||||
t+=arr_from_int(j["TimeOutM"])
|
||||
b=bytearray()
|
||||
t+=arr_from_int(len(j["TaskArray"]))
|
||||
for i in j["TaskArray"]:
|
||||
b+=scheme_get_task_range(i)
|
||||
t+=arr_from_int(len(b)//8)
|
||||
t+=b
|
||||
t+=scheme_get_task_range(i)
|
||||
return t
|
||||
|
||||
|
||||
@@ -433,8 +441,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=0x31
|
||||
print(u.encode(bytearray()).hex(' '))
|
||||
u.cmd=0x01
|
||||
print(u.encode(bytearray([0x0a,0x00])).hex(' '))
|
||||
# with open("file/EX三码绑定测试2023-06-26.json","rb") as f:
|
||||
# json_obj=json.loads(f.read())
|
||||
# d=scheme_to_byte(json_obj)
|
||||
# # print("len=",len(d),d.hex(","))
|
||||
# d+=scheme_to_host(json_obj)
|
||||
|
||||
|
||||
# 开始检测
|
||||
|
@@ -5,6 +5,7 @@
|
||||
typedef struct{
|
||||
uint32_t max;
|
||||
uint32_t min;
|
||||
uint32_t err;
|
||||
}item_def;
|
||||
|
||||
|
||||
@@ -12,7 +13,8 @@ typedef struct{
|
||||
typedef struct
|
||||
{
|
||||
uint32_t item_num;
|
||||
item_def data[0];
|
||||
uint32_t err;
|
||||
item_def data[16];
|
||||
}task_def;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user