diff --git a/checker_gen1.uvprojx b/checker_gen1.uvprojx
index d15258b..8190772 100644
--- a/checker_gen1.uvprojx
+++ b/checker_gen1.uvprojx
@@ -10,7 +10,7 @@
app
0x4
ARM-ADS
- 5060750::V5.06 update 6 (build 750)::ARMCC
+ 5060960::V5.06 update 7 (build 960)::.\ARMCC
0
@@ -185,6 +185,7 @@
0
2
0
+ 0
1
0
8
@@ -351,7 +352,7 @@
0
0
0
- 0
+ 4
@@ -1549,6 +1550,7 @@
0
2
0
+ 0
1
0
8
@@ -1715,7 +1717,7 @@
0
0
0
- 0
+ 4
@@ -2277,7 +2279,7 @@
2
2
2
- 2
+ 0
@@ -3201,7 +3203,7 @@
2
2
2
- 2
+ 0
@@ -3295,7 +3297,7 @@
2
2
2
- 2
+ 0
@@ -4012,7 +4014,7 @@
2
2
2
- 2
+ 0
@@ -4166,7 +4168,7 @@
2
2
2
- 2
+ 0
@@ -4245,7 +4247,7 @@
2
2
2
- 2
+ 0
diff --git a/source/ReadMe.txt b/source/ReadMe.txt
index 4aa4ab6..96d5797 100644
--- a/source/ReadMe.txt
+++ b/source/ReadMe.txt
@@ -136,4 +136,6 @@
UID转存储码特征码从*10000改为*100000
赋码仪接收上位机的0x81,0x82回复
添加错误判断,未完成
+2023.7.6
+ 赋码仪添加错误判断,管壳码有0字节则不注码,直接返回失败
\ No newline at end of file
diff --git a/source/coder/coder_judge.c b/source/coder/coder_judge.c
index f18701c..d7ccaf2 100644
--- a/source/coder/coder_judge.c
+++ b/source/coder/coder_judge.c
@@ -3,7 +3,7 @@
#include "string.h"
-// d aУظ
+// 把d插入 a中,不允许重复
static void c_insert(uint8_t *a,uint8_t d)
{
int len=sizeof(uint8_t [6]);
@@ -21,7 +21,7 @@ static void c_insert(uint8_t *a,uint8_t d)
}
}
-// ɾaеֵd
+// 删除a中的值d
static void c_del(uint8_t *a,uint8_t d)
{
int len=sizeof(uint8_t [6]);
@@ -35,7 +35,7 @@ static void c_del(uint8_t *a,uint8_t d)
}
-// ɾaгdֵ֮
+// 删除a中除d之外的所有值
static void c_only(uint8_t *a,uint8_t d)
{
int len=sizeof(uint8_t [6]);
@@ -48,11 +48,11 @@ static void c_only(uint8_t *a,uint8_t d)
return;
}
}
- // ûҵȫɾ
+ // 如果没找到则全部删除
memset(a,0xff,len);
}
-// ʼa
+// 初始化a
static void c_init(uint8_t *a)
{
int len=sizeof(uint8_t [6]);
@@ -60,8 +60,8 @@ static void c_init(uint8_t *a)
}
-// taskidҵ
-const scheme_task_def *find_task_next(int index_now,int taskid)
+// 根据taskid找到任务
+static const scheme_task_def *find_task_next(int index_now,int taskid)
{
const scheme_def *s=check_scheme();
const scheme_task_def *t;
@@ -74,41 +74,33 @@ const scheme_task_def *find_task_next(int index_now,int taskid)
return 0;
}
-// ȡindexIJ
-// ȡindexΧ
-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_task_def *t;
- int index_p=0;
- for(int i=0;itask_num;i++)
+ int num=0;
+ for(int i=0;itask[i];
- for(int j=0;jitem_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++;
- }
+ num+=t->item_num;
}
- return index_p;
+ return num;
}
-// ȡindex
+// 获取第index个检测数据
static int get_data(const uint8_t *data,int index)
{
data+=16;
return data[index*2]|(data[index*2+1]<<8);
}
-// ȡindexǷɹ1ʧܣ0ɹ
+// 获取第index个任务是否成功1,失败,0成功
static int get_ack(const uint8_t *data,int index)
{
if(data[index/8]&(1<<(index%8)))
@@ -118,18 +110,22 @@ static int get_ack(const uint8_t *data,int index)
}
-//-- 쳣,1
-//-- 쳣,2
-//-- Ӵ쳣,3
-//-- ˿ֵ쳣,4
-//-- оƬ쳣,5
-//-- 7
-//-- ·8
+//-- 检测器异常,1
+//-- 主电容异常,2
+//-- 接触异常,3
+//-- 桥丝阻值异常,4
+//-- 芯片异常,5
+//-- 过流,7
+//-- 短路,8
-#define TASK_RETURN(task) {\
+#define TASK_FIND_NEXT(taskid) {\
+ task=find_task_next(index,taskid);\
if(task==0) return 6; \
else index+=1;\
-}// Ҳ
+}// 找不到方案
+
+#define TASK_DATA(index) get_data(data,calc_skip_num(task->taskindex)+(index))
+
uint8_t coder_judge(const uint8_t *data)
{
@@ -137,76 +133,86 @@ uint8_t coder_judge(const uint8_t *data)
int index=0;
const scheme_task_def *task=0;
- //
- task=find_task_next(index,0);
- TASK_RETURN(task);
+ // 开总线
+ TASK_FIND_NEXT(0);
{
if(get_ack(data,0))
{
- // ϵ쳣
+ // 上电错误,检测器异常
return 1;
}
}
- // ϵ
- task=find_task_next(index,1);
- TASK_RETURN(task);
+ // 上电充能
+ TASK_FIND_NEXT(1);
{
- temp=get_data(data,0);
+ temp=TASK_DATA(0);
if(temprange[0].min)
{
- // ѹ쳣
+ // 电压无法上升,检测器异常
return 1;
}
- temp=get_data(data,1);
+ temp=TASK_DATA(1);
if((temp>39000)||(temp<1)){
- // ʧܣ
+ // 充能失败,检测电流
}
}
- //
- task=find_task_next(index,4);
- TASK_RETURN(task);
- temp=get_data(data,5);
- temp2=get_data(data,6);
- if((temp<10)&&(temp2<20))
+ // 检测电流
+ TASK_FIND_NEXT(4);
+ temp=TASK_DATA(0);
+ temp2=TASK_DATA(1);
+ if((temp<10)&&(temp2<10))
{
- // Ӵ쳣
+ // 接触异常
return 3;
}
else if(((temp>task->range[0].max)&&(temp<1500))||
((temp2>task->range[0].max)&&(temp2<1500)))
{
- //
+ // 过流
return 7;
}else if((temp>1500)&&(temp2>1500))
{
- // ·
+ // 短路
return 8;
}
- // uid
- task=find_task_next(index,5);
- TASK_RETURN(task);
+ // 检测uid
+ TASK_FIND_NEXT(5);
if(get_ack(data,task->taskindex))
{
- // оƬ
+ // 芯片错误
return 5;
}
- // ˿
- task=find_task_next(index,6);
- TASK_RETURN(task);
- temp=get_data(data,7);
+ // 检测桥丝
+ TASK_FIND_NEXT(6);
+ temp=TASK_DATA(0);
if((temprange[0].min)||(temp>task->range[0].max))
{
- // ˿
+ // 桥丝错误
return 4;
}
- //
-
+ // 检测电容
+ TASK_FIND_NEXT(8);
+ temp=TASK_DATA(0);
+ if((temp>task->range[0].max)||(temprange[0].min))
+ {
+ return 2;
+ }
+ temp=TASK_DATA(1);
+ if((temp>task->range[1].max)||(temprange[1].min))
+ {
+ return 2;
+ }
+ temp=TASK_DATA(2);
+ if((temp>task->range[2].max)||(temprange[2].min))
+ {
+ return 2;
+ }
return 0;
}
diff --git a/source/coder/coder_lib.c b/source/coder/coder_lib.c
index b4d1f1f..bd94e51 100644
--- a/source/coder/coder_lib.c
+++ b/source/coder/coder_lib.c
@@ -79,7 +79,16 @@ static int coder_calc_year(const char *year,const char shell_year,char *uid_year
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码
int coder_shell_to_uid(const char *year,const char *shell_code,char *uid_code)
diff --git a/source/coder/coder_lib.h b/source/coder/coder_lib.h
index 4dcabb5..2b5e37a 100644
--- a/source/coder/coder_lib.h
+++ b/source/coder/coder_lib.h
@@ -8,6 +8,8 @@
+// 返回1则shell_code有效
+int check_shell_code(const char *shell_code);
// 管壳码转uid码
diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h
index aa788c4..0431ae6 100644
--- a/source/main/compiler_info.h
+++ b/source/main/compiler_info.h
@@ -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"
diff --git a/source/task/tran_for_coder2.c b/source/task/tran_for_coder2.c
index c6de619..3e2a839 100644
--- a/source/task/tran_for_coder2.c
+++ b/source/task/tran_for_coder2.c
@@ -53,6 +53,36 @@ typedef struct{
+// 上报注码结果
+static void write_uid_upmit(write_uid_def *w)
+{
+ array_def *a=arr_creat();
+ arr_append(a,w->addrs_num);
+ // arr_appends(a,w->ack,390);
+ for(int i=0;i<10;i++)
+ {
+ uint8_t *d=&w->ack[i*39];
+ if(sys_param()->coder_ret_mode)
+ {
+ // 完整模式
+ arr_appends(a,d,39);
+ }
+ else{
+ // 精简模式
+ arr_appends(a,d,2);
+ d+=2+13+16;
+ arr_appends(a,d,8);
+ }
+ }
+ 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;
+}
+
+
+
// 注码完成
static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_str)
{
@@ -73,29 +103,7 @@ static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *e
memcpy(&d[2+13+16],w->item[addr].password,8);
if(w->ack_num>=10)
{
- array_def *a=arr_creat();
- arr_append(a,w->addrs_num);
- // arr_appends(a,w->ack,390);
- for(int i=0;i<10;i++)
- {
- uint8_t *d=&w->ack[i*39];
- if(sys_param()->coder_ret_mode)
- {
- // 完整模式
- arr_appends(a,d,39);
- }
- else{
- // 精简模式
- arr_appends(a,d,2);
- d+=2+13+16;
- arr_appends(a,d,8);
- }
- }
- 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;
+ 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);
memcpy(u->year,arr_data(data)+1,4);
DBG_LOG("coder, year=%s",u->year);
+
// 数据固定140字节,如果不检测某通道,则该通道填充占位符
uint8_t *d_off=arr_data(data)+4+1;
uint8_t *d_;
+ tran_set_busy(t,1);
for(int i=0;i<10;i++)
{
memcpy(u->item[i].shell_code,d_off+i*14+1,13);
@@ -170,27 +180,30 @@ 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],
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+1]=1;
- }
-
-
- tran_set_busy(t,1);
- for(int i=0;i<10;i++)
- {
if(1){
port_mcu *mcu=tran_get_portm(u->u.p,i);
// 这里打开赋码操作
if(mcu){
- port_start(mcu,code_creat(8,4,u->item[i].uid_pw_hex));
+ if(check_shell_code(u->item[i].shell_code)){
+ 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();
arr_append(a,u->addrs_num);
if(g_self.step==1){