完成judge功能,管壳码全0校验
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<TargetName>app</TargetName>
|
<TargetName>app</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||||
<uAC6>0</uAC6>
|
<uAC6>0</uAC6>
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
@@ -185,6 +185,7 @@
|
|||||||
<uocXRam>0</uocXRam>
|
<uocXRam>0</uocXRam>
|
||||||
<RvdsVP>2</RvdsVP>
|
<RvdsVP>2</RvdsVP>
|
||||||
<RvdsMve>0</RvdsMve>
|
<RvdsMve>0</RvdsMve>
|
||||||
|
<RvdsCdeCp>0</RvdsCdeCp>
|
||||||
<hadIRAM2>1</hadIRAM2>
|
<hadIRAM2>1</hadIRAM2>
|
||||||
<hadIROM2>0</hadIROM2>
|
<hadIROM2>0</hadIROM2>
|
||||||
<StupSel>8</StupSel>
|
<StupSel>8</StupSel>
|
||||||
@@ -351,7 +352,7 @@
|
|||||||
<NoWarn>0</NoWarn>
|
<NoWarn>0</NoWarn>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
<uClangAs>0</uClangAs>
|
<ClangAsOpt>4</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -1549,6 +1550,7 @@
|
|||||||
<uocXRam>0</uocXRam>
|
<uocXRam>0</uocXRam>
|
||||||
<RvdsVP>2</RvdsVP>
|
<RvdsVP>2</RvdsVP>
|
||||||
<RvdsMve>0</RvdsMve>
|
<RvdsMve>0</RvdsMve>
|
||||||
|
<RvdsCdeCp>0</RvdsCdeCp>
|
||||||
<hadIRAM2>1</hadIRAM2>
|
<hadIRAM2>1</hadIRAM2>
|
||||||
<hadIROM2>0</hadIROM2>
|
<hadIROM2>0</hadIROM2>
|
||||||
<StupSel>8</StupSel>
|
<StupSel>8</StupSel>
|
||||||
@@ -1715,7 +1717,7 @@
|
|||||||
<NoWarn>0</NoWarn>
|
<NoWarn>0</NoWarn>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
<uClangAs>0</uClangAs>
|
<ClangAsOpt>4</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -2277,7 +2279,7 @@
|
|||||||
<NoWarn>2</NoWarn>
|
<NoWarn>2</NoWarn>
|
||||||
<uSurpInc>2</uSurpInc>
|
<uSurpInc>2</uSurpInc>
|
||||||
<useXO>2</useXO>
|
<useXO>2</useXO>
|
||||||
<uClangAs>2</uClangAs>
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -3201,7 +3203,7 @@
|
|||||||
<NoWarn>2</NoWarn>
|
<NoWarn>2</NoWarn>
|
||||||
<uSurpInc>2</uSurpInc>
|
<uSurpInc>2</uSurpInc>
|
||||||
<useXO>2</useXO>
|
<useXO>2</useXO>
|
||||||
<uClangAs>2</uClangAs>
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -3295,7 +3297,7 @@
|
|||||||
<NoWarn>2</NoWarn>
|
<NoWarn>2</NoWarn>
|
||||||
<uSurpInc>2</uSurpInc>
|
<uSurpInc>2</uSurpInc>
|
||||||
<useXO>2</useXO>
|
<useXO>2</useXO>
|
||||||
<uClangAs>2</uClangAs>
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -4012,7 +4014,7 @@
|
|||||||
<NoWarn>2</NoWarn>
|
<NoWarn>2</NoWarn>
|
||||||
<uSurpInc>2</uSurpInc>
|
<uSurpInc>2</uSurpInc>
|
||||||
<useXO>2</useXO>
|
<useXO>2</useXO>
|
||||||
<uClangAs>2</uClangAs>
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -4166,7 +4168,7 @@
|
|||||||
<NoWarn>2</NoWarn>
|
<NoWarn>2</NoWarn>
|
||||||
<uSurpInc>2</uSurpInc>
|
<uSurpInc>2</uSurpInc>
|
||||||
<useXO>2</useXO>
|
<useXO>2</useXO>
|
||||||
<uClangAs>2</uClangAs>
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
@@ -4245,7 +4247,7 @@
|
|||||||
<NoWarn>2</NoWarn>
|
<NoWarn>2</NoWarn>
|
||||||
<uSurpInc>2</uSurpInc>
|
<uSurpInc>2</uSurpInc>
|
||||||
<useXO>2</useXO>
|
<useXO>2</useXO>
|
||||||
<uClangAs>2</uClangAs>
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
|
@@ -136,4 +136,6 @@
|
|||||||
UID转存储码特征码从*10000改为*100000
|
UID转存储码特征码从*10000改为*100000
|
||||||
赋码仪接收上位机的0x81,0x82回复
|
赋码仪接收上位机的0x81,0x82回复
|
||||||
添加错误判断,未完成
|
添加错误判断,未完成
|
||||||
|
2023.7.6
|
||||||
|
赋码仪添加错误判断,管壳码有0字节则不注码,直接返回失败
|
||||||
|
|
@@ -3,7 +3,7 @@
|
|||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>d<EFBFBD><EFBFBD><EFBFBD><EFBFBD> a<>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
// 把d插入 a中,不允许重复
|
||||||
static void c_insert(uint8_t *a,uint8_t d)
|
static void c_insert(uint8_t *a,uint8_t d)
|
||||||
{
|
{
|
||||||
int len=sizeof(uint8_t [6]);
|
int len=sizeof(uint8_t [6]);
|
||||||
@@ -21,7 +21,7 @@ static void c_insert(uint8_t *a,uint8_t d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ɾ<EFBFBD><EFBFBD>a<EFBFBD>е<EFBFBD>ֵd
|
// 删除a中的值d
|
||||||
static void c_del(uint8_t *a,uint8_t d)
|
static void c_del(uint8_t *a,uint8_t d)
|
||||||
{
|
{
|
||||||
int len=sizeof(uint8_t [6]);
|
int len=sizeof(uint8_t [6]);
|
||||||
@@ -35,7 +35,7 @@ static void c_del(uint8_t *a,uint8_t d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ɾ<EFBFBD><EFBFBD>a<EFBFBD>г<EFBFBD>d֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
// 删除a中除d之外的所有值
|
||||||
static void c_only(uint8_t *a,uint8_t d)
|
static void c_only(uint8_t *a,uint8_t d)
|
||||||
{
|
{
|
||||||
int len=sizeof(uint8_t [6]);
|
int len=sizeof(uint8_t [6]);
|
||||||
@@ -48,11 +48,11 @@ static void c_only(uint8_t *a,uint8_t d)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>
|
// 如果没找到则全部删除
|
||||||
memset(a,0xff,len);
|
memset(a,0xff,len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>a
|
// 初始化a
|
||||||
static void c_init(uint8_t *a)
|
static void c_init(uint8_t *a)
|
||||||
{
|
{
|
||||||
int len=sizeof(uint8_t [6]);
|
int len=sizeof(uint8_t [6]);
|
||||||
@@ -60,8 +60,8 @@ static void c_init(uint8_t *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>taskid<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 根据taskid找到任务
|
||||||
const scheme_task_def *find_task_next(int index_now,int taskid)
|
static const scheme_task_def *find_task_next(int index_now,int taskid)
|
||||||
{
|
{
|
||||||
const scheme_def *s=check_scheme();
|
const scheme_def *s=check_scheme();
|
||||||
const scheme_task_def *t;
|
const scheme_task_def *t;
|
||||||
@@ -74,41 +74,33 @@ const scheme_task_def *find_task_next(int index_now,int taskid)
|
|||||||
return 0;
|
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)
|
|
||||||
|
// 计算在taskindex之前有多少个返回值
|
||||||
|
static int calc_skip_num(int index)
|
||||||
{
|
{
|
||||||
const scheme_def *s=check_scheme();
|
const scheme_def *s=check_scheme();
|
||||||
const scheme_task_def *t;
|
const scheme_task_def *t;
|
||||||
int index_p=0;
|
int num=0;
|
||||||
for(int i=0;i<s->task_num;i++)
|
for(int i=0;i<index;i++)
|
||||||
{
|
{
|
||||||
t=&s->task[i];
|
t=&s->task[i];
|
||||||
for(int j=0;j<t->item_num;j++)
|
num+=t->item_num;
|
||||||
{
|
|
||||||
if(index_p==index)
|
|
||||||
{
|
|
||||||
if(min) *min=t->range[j].min;
|
|
||||||
if(max) *max=t->range[j].max;
|
|
||||||
return index_p;
|
|
||||||
}
|
}
|
||||||
index_p++;
|
return num;
|
||||||
}
|
|
||||||
}
|
|
||||||
return index_p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>index<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 获取第index个检测数据
|
||||||
static int get_data(const uint8_t *data,int index)
|
static int get_data(const uint8_t *data,int index)
|
||||||
{
|
{
|
||||||
data+=16;
|
data+=16;
|
||||||
return data[index*2]|(data[index*2+1]<<8);
|
return data[index*2]|(data[index*2+1]<<8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>index<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>1<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>0<EFBFBD>ɹ<EFBFBD>
|
// 获取第index个任务是否成功1,失败,0成功
|
||||||
static int get_ack(const uint8_t *data,int index)
|
static int get_ack(const uint8_t *data,int index)
|
||||||
{
|
{
|
||||||
if(data[index/8]&(1<<(index%8)))
|
if(data[index/8]&(1<<(index%8)))
|
||||||
@@ -118,18 +110,22 @@ static int get_ack(const uint8_t *data,int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣,1
|
//-- 检测器异常,1
|
||||||
//-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣,2
|
//-- 主电容异常,2
|
||||||
//-- <EFBFBD>Ӵ<EFBFBD><EFBFBD>쳣,3
|
//-- 接触异常,3
|
||||||
//-- <EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD>ֵ<EFBFBD>쳣,4
|
//-- 桥丝阻值异常,4
|
||||||
//-- оƬ<EFBFBD>쳣,5
|
//-- 芯片异常,5
|
||||||
//-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>7
|
//-- 过流,7
|
||||||
//-- <EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>8
|
//-- 短路,8
|
||||||
|
|
||||||
#define TASK_RETURN(task) {\
|
#define TASK_FIND_NEXT(taskid) {\
|
||||||
|
task=find_task_next(index,taskid);\
|
||||||
if(task==0) return 6; \
|
if(task==0) return 6; \
|
||||||
else index+=1;\
|
else index+=1;\
|
||||||
}// <EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
}// 找不到方案
|
||||||
|
|
||||||
|
#define TASK_DATA(index) get_data(data,calc_skip_num(task->taskindex)+(index))
|
||||||
|
|
||||||
|
|
||||||
uint8_t coder_judge(const uint8_t *data)
|
uint8_t coder_judge(const uint8_t *data)
|
||||||
{
|
{
|
||||||
@@ -137,76 +133,86 @@ uint8_t coder_judge(const uint8_t *data)
|
|||||||
int index=0;
|
int index=0;
|
||||||
const scheme_task_def *task=0;
|
const scheme_task_def *task=0;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 开总线
|
||||||
task=find_task_next(index,0);
|
TASK_FIND_NEXT(0);
|
||||||
TASK_RETURN(task);
|
|
||||||
{
|
{
|
||||||
if(get_ack(data,0))
|
if(get_ack(data,0))
|
||||||
{
|
{
|
||||||
// <EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
// 上电错误,检测器异常
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 上电充能
|
||||||
task=find_task_next(index,1);
|
TASK_FIND_NEXT(1);
|
||||||
TASK_RETURN(task);
|
|
||||||
{
|
{
|
||||||
temp=get_data(data,0);
|
temp=TASK_DATA(0);
|
||||||
if(temp<task->range[0].min)
|
if(temp<task->range[0].min)
|
||||||
{
|
{
|
||||||
// <EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
// 电压无法上升,检测器异常
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
temp=get_data(data,1);
|
temp=TASK_DATA(1);
|
||||||
if((temp>39000)||(temp<1)){
|
if((temp>39000)||(temp<1)){
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 充能失败,检测电流
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 检测电流
|
||||||
task=find_task_next(index,4);
|
TASK_FIND_NEXT(4);
|
||||||
TASK_RETURN(task);
|
temp=TASK_DATA(0);
|
||||||
temp=get_data(data,5);
|
temp2=TASK_DATA(1);
|
||||||
temp2=get_data(data,6);
|
if((temp<10)&&(temp2<10))
|
||||||
if((temp<10)&&(temp2<20))
|
|
||||||
{
|
{
|
||||||
// <EFBFBD>Ӵ<EFBFBD><EFBFBD>쳣
|
// 接触异常
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
else if(((temp>task->range[0].max)&&(temp<1500))||
|
else if(((temp>task->range[0].max)&&(temp<1500))||
|
||||||
((temp2>task->range[0].max)&&(temp2<1500)))
|
((temp2>task->range[0].max)&&(temp2<1500)))
|
||||||
{
|
{
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 过流
|
||||||
return 7;
|
return 7;
|
||||||
}else if((temp>1500)&&(temp2>1500))
|
}else if((temp>1500)&&(temp2>1500))
|
||||||
{
|
{
|
||||||
// <EFBFBD><EFBFBD>·
|
// 短路
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>uid
|
// 检测uid
|
||||||
task=find_task_next(index,5);
|
TASK_FIND_NEXT(5);
|
||||||
TASK_RETURN(task);
|
|
||||||
if(get_ack(data,task->taskindex))
|
if(get_ack(data,task->taskindex))
|
||||||
{
|
{
|
||||||
// оƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 芯片错误
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
|
// 检测桥丝
|
||||||
task=find_task_next(index,6);
|
TASK_FIND_NEXT(6);
|
||||||
TASK_RETURN(task);
|
temp=TASK_DATA(0);
|
||||||
temp=get_data(data,7);
|
|
||||||
if((temp<task->range[0].min)||(temp>task->range[0].max))
|
if((temp<task->range[0].min)||(temp>task->range[0].max))
|
||||||
{
|
{
|
||||||
// <EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 桥丝错误
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 检测电容
|
||||||
|
TASK_FIND_NEXT(8);
|
||||||
|
temp=TASK_DATA(0);
|
||||||
|
if((temp>task->range[0].max)||(temp<task->range[0].min))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
temp=TASK_DATA(1);
|
||||||
|
if((temp>task->range[1].max)||(temp<task->range[1].min))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
temp=TASK_DATA(2);
|
||||||
|
if((temp>task->range[2].max)||(temp<task->range[2].min))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,16 @@ static int coder_calc_year(const char *year,const char shell_year,char *uid_year
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 返回1则shell_code有效
|
||||||
|
int check_shell_code(const char *shell_code)
|
||||||
|
{
|
||||||
|
for(int i=0;i<13;i++)
|
||||||
|
{
|
||||||
|
if(shell_code[i]==0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// 管壳码转uid码
|
// 管壳码转uid码
|
||||||
int coder_shell_to_uid(const char *year,const char *shell_code,char *uid_code)
|
int coder_shell_to_uid(const char *year,const char *shell_code,char *uid_code)
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 返回1则shell_code有效
|
||||||
|
int check_shell_code(const char *shell_code);
|
||||||
|
|
||||||
|
|
||||||
// 管壳码转uid码
|
// 管壳码转uid码
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BUILD_DATE "2023-07-06 19:01:21"
|
#define BUILD_DATE "2023-07-06 22:57:16"
|
||||||
#define SOFT_VERSION "0.10"
|
#define SOFT_VERSION "0.10"
|
||||||
|
|
||||||
|
|
||||||
|
@@ -53,26 +53,9 @@ typedef struct{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 注码完成
|
// 上报注码结果
|
||||||
static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_str)
|
static void write_uid_upmit(write_uid_def *w)
|
||||||
{
|
{
|
||||||
write_uid_def *w=(write_uid_def *)u;
|
|
||||||
uint8_t addr=port_get_addr(src);
|
|
||||||
if(addr<=0||addr>10){
|
|
||||||
DBG_WARN("addr err:%d",addr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
addr-=1;
|
|
||||||
|
|
||||||
uint8_t *d=&w->ack[(addr)*39];
|
|
||||||
w->ack_num++;
|
|
||||||
d[0]=addr+slave_addr_off();
|
|
||||||
d[1]=ack;
|
|
||||||
memcpy(&d[2],w->item[addr].shell_code,13);
|
|
||||||
memcpy(&d[2+13],w->item[addr].uid_code,16);
|
|
||||||
memcpy(&d[2+13+16],w->item[addr].password,8);
|
|
||||||
if(w->ack_num>=10)
|
|
||||||
{
|
|
||||||
array_def *a=arr_creat();
|
array_def *a=arr_creat();
|
||||||
arr_append(a,w->addrs_num);
|
arr_append(a,w->addrs_num);
|
||||||
// arr_appends(a,w->ack,390);
|
// arr_appends(a,w->ack,390);
|
||||||
@@ -96,6 +79,31 @@ static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *e
|
|||||||
g_self.step=0;
|
g_self.step=0;
|
||||||
// 把命令字改为0x82用于接收主机应答
|
// 把命令字改为0x82用于接收主机应答
|
||||||
w->u.cmd=0x82;
|
w->u.cmd=0x82;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 注码完成
|
||||||
|
static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_str)
|
||||||
|
{
|
||||||
|
write_uid_def *w=(write_uid_def *)u;
|
||||||
|
uint8_t addr=port_get_addr(src);
|
||||||
|
if(addr<=0||addr>10){
|
||||||
|
DBG_WARN("addr err:%d",addr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addr-=1;
|
||||||
|
|
||||||
|
uint8_t *d=&w->ack[(addr)*39];
|
||||||
|
w->ack_num++;
|
||||||
|
d[0]=addr+slave_addr_off();
|
||||||
|
d[1]=ack;
|
||||||
|
memcpy(&d[2],w->item[addr].shell_code,13);
|
||||||
|
memcpy(&d[2+13],w->item[addr].uid_code,16);
|
||||||
|
memcpy(&d[2+13+16],w->item[addr].password,8);
|
||||||
|
if(w->ack_num>=10)
|
||||||
|
{
|
||||||
|
write_uid_upmit(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +157,11 @@ static ucport_def *write_uid(tran_def *t, uint8_t cmd,array_def *data)
|
|||||||
u->addrs_num=arr_get(data,0);
|
u->addrs_num=arr_get(data,0);
|
||||||
memcpy(u->year,arr_data(data)+1,4);
|
memcpy(u->year,arr_data(data)+1,4);
|
||||||
DBG_LOG("coder, year=%s",u->year);
|
DBG_LOG("coder, year=%s",u->year);
|
||||||
|
|
||||||
// 数据固定140字节,如果不检测某通道,则该通道填充占位符
|
// 数据固定140字节,如果不检测某通道,则该通道填充占位符
|
||||||
uint8_t *d_off=arr_data(data)+4+1;
|
uint8_t *d_off=arr_data(data)+4+1;
|
||||||
uint8_t *d_;
|
uint8_t *d_;
|
||||||
|
tran_set_busy(t,1);
|
||||||
for(int i=0;i<10;i++)
|
for(int i=0;i<10;i++)
|
||||||
{
|
{
|
||||||
memcpy(u->item[i].shell_code,d_off+i*14+1,13);
|
memcpy(u->item[i].shell_code,d_off+i*14+1,13);
|
||||||
@@ -170,26 +180,29 @@ static ucport_def *write_uid(tran_def *t, uint8_t cmd,array_def *data)
|
|||||||
// 生成密码字符串
|
// 生成密码字符串
|
||||||
sprintf(u->item[i].password,"%02X%02X%02X%02X",u->item[i].uid_pw_hex[8],
|
sprintf(u->item[i].password,"%02X%02X%02X%02X",u->item[i].uid_pw_hex[8],
|
||||||
u->item[i].uid_pw_hex[9],u->item[i].uid_pw_hex[10],u->item[i].uid_pw_hex[11]);
|
u->item[i].uid_pw_hex[9],u->item[i].uid_pw_hex[10],u->item[i].uid_pw_hex[11]);
|
||||||
}
|
|
||||||
// 默认失败
|
// 默认失败
|
||||||
for(int i=0;i<10;i++)
|
|
||||||
{
|
|
||||||
u->ack[i*39+0]=i+slave_addr_off();
|
u->ack[i*39+0]=i+slave_addr_off();
|
||||||
u->ack[i*39+1]=1;
|
u->ack[i*39+1]=1;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tran_set_busy(t,1);
|
|
||||||
for(int i=0;i<10;i++)
|
|
||||||
{
|
|
||||||
if(1){
|
if(1){
|
||||||
port_mcu *mcu=tran_get_portm(u->u.p,i);
|
port_mcu *mcu=tran_get_portm(u->u.p,i);
|
||||||
// 这里打开赋码操作
|
// 这里打开赋码操作
|
||||||
if(mcu){
|
if(mcu){
|
||||||
|
if(check_shell_code(u->item[i].shell_code)){
|
||||||
port_start(mcu,code_creat(8,4,u->item[i].uid_pw_hex));
|
port_start(mcu,code_creat(8,4,u->item[i].uid_pw_hex));
|
||||||
|
}else{
|
||||||
|
// 管壳码无效,不注码,此时默认已ack
|
||||||
|
u->ack_num++;
|
||||||
|
if(u->ack_num>=10)
|
||||||
|
{
|
||||||
|
write_uid_upmit(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
array_def *a=arr_creat();
|
array_def *a=arr_creat();
|
||||||
arr_append(a,u->addrs_num);
|
arr_append(a,u->addrs_num);
|
||||||
|
Reference in New Issue
Block a user