|
|
@ -6,30 +6,29 @@ |
|
|
|
#include "../app/app_paraid.h" |
|
|
|
#include "../app/app_task_relay.h" |
|
|
|
|
|
|
|
//0xFF+0xFE+2+20+1+21 `0xFF``0xFE`00``2A``simno,salt
|
|
|
|
#define LEN_GPRS_TCP_PKG_AT_SIGNIN 46 |
|
|
|
#define LEN_GPRS_TCP_DATA_ACK 8 |
|
|
|
|
|
|
|
struct printer_maintenance_global G; |
|
|
|
//TS_PH3_ccmodbus_ack ccmodbus_ack;
|
|
|
|
U8 ccmodbus_len = 0; |
|
|
|
vU8 gprsTcpPkg_Signin[LEN_GPRS_TCP_PKG_AT_SIGNIN] = {0xFF,0xFE,0x0,0x2A}; |
|
|
|
vU8 gprsdataack[LEN_GPRS_TCP_DATA_ACK] = {0xFF,0xFE,0x0,0x4,0x11,0x95,0x8F,0xCD}; |
|
|
|
|
|
|
|
void Lu_register_init() |
|
|
|
{ |
|
|
|
U8 i = 0; |
|
|
|
G.p.slaverId = 0x10; |
|
|
|
G.p.wisdom_car_no = 0x01; |
|
|
|
G.p.wisdom_car_no = 0x91; |
|
|
|
G.p.thrombolytic_ratio = 9; //0.9
|
|
|
|
G.p.bolus_ratio = 9; //0.9
|
|
|
|
G.p.hold_ratio = 1; //0.1
|
|
|
|
G.p.bolus_ratio = 1; //0.9
|
|
|
|
G.p.hold_ratio = 9; //0.1
|
|
|
|
|
|
|
|
G.total_weight = 50000; |
|
|
|
G.thrombolytic_val = G.bolus_val = G.hold_val = 40000; |
|
|
|
G.asga.xaxis = G.asga.yaxis = G.asga.zaxis = 22; |
|
|
|
G.total_weight = 0; |
|
|
|
G.thrombolytic_val = G.bolus_val = G.hold_val = 0; |
|
|
|
G.asga.xaxis = G.asga.yaxis = G.asga.zaxis = 0; |
|
|
|
G.rfid = 0; |
|
|
|
|
|
|
|
for(i=0;i<4;i++) |
|
|
|
{ |
|
|
|
G.weight[i] = 0; |
|
|
|
} |
|
|
|
|
|
|
|
for(i=0;i<MD_SLAVER_INFO_MAX;i++) |
|
|
|
{ |
|
|
|
G.md_slaver_info[i].mask = 0; |
|
|
@ -46,7 +45,7 @@ void Lu_register_init() |
|
|
|
G.md_slaver_info[1].regnum = 0x03; |
|
|
|
G.md_slaver_info[1].mask = 2; |
|
|
|
|
|
|
|
G.md_slaver_info[2].slaver = SLAVER_SHOW01_ID; //é‡�é‡�2ï¼Œæº¶æ “ï¼Œå›¢æ³¨ï¼Œç»´æŒ�
|
|
|
|
G.md_slaver_info[2].slaver = SLAVER_SHOW01_ID; //é‡�é‡�2ï¼Œæº¶æ “ï¼Œå›¢æ³¨ï¼Œç»´æŒ?
|
|
|
|
G.md_slaver_info[2].oper = MODBUS_OPER_WRITE_M; |
|
|
|
G.md_slaver_info[2].reg = 0x02; |
|
|
|
G.md_slaver_info[2].regnum = 0x05; |
|
|
@ -67,35 +66,35 @@ void Lu_register_init() |
|
|
|
G.ccmd_slaver_info[i].mask = 0; |
|
|
|
} |
|
|
|
|
|
|
|
G.ccmd_slaver_info[0].slaver = SLAVER_TCP_SERVER_ID; //�务器 //登陆包,写平车编�
|
|
|
|
G.ccmd_slaver_info[0].slaver = SLAVER_TCP_SERVER_ID; //�务� //登陆包,写平车编�
|
|
|
|
G.ccmd_slaver_info[0].oper = MODBUS_OPER_WRITE_M; |
|
|
|
G.ccmd_slaver_info[0].reg = 0x01; |
|
|
|
G.ccmd_slaver_info[0].regnum = 0x01; |
|
|
|
G.ccmd_slaver_info[0].bytes = G.ccmd_slaver_info[5].regnum * 2; |
|
|
|
G.ccmd_slaver_info[0].bytes = G.ccmd_slaver_info[0].regnum * 2; |
|
|
|
G.ccmd_slaver_info[0].buf = (U8*)&G.p.wisdom_car_no; |
|
|
|
G.ccmd_slaver_info[0].mask = 0; |
|
|
|
|
|
|
|
G.ccmd_slaver_info[1].slaver = SLAVER_TCP_SERVER_ID; //æœ�务器 //心跳包,写心跳寄å˜å™¨
|
|
|
|
G.ccmd_slaver_info[1].slaver = SLAVER_TCP_SERVER_ID; //æœ�务å™? //心跳包,写心跳寄å˜å™¨
|
|
|
|
G.ccmd_slaver_info[1].oper = MODBUS_OPER_WRITE_M; |
|
|
|
G.ccmd_slaver_info[1].reg = 0x02; |
|
|
|
G.ccmd_slaver_info[1].regnum = 0x01; |
|
|
|
G.ccmd_slaver_info[1].bytes = G.ccmd_slaver_info[6].regnum * 2; |
|
|
|
G.ccmd_slaver_info[1].bytes = G.ccmd_slaver_info[1].regnum * 2; |
|
|
|
G.ccmd_slaver_info[1].buf = (U8*)&G.p.reserved1; |
|
|
|
G.ccmd_slaver_info[1].mask = 0; |
|
|
|
|
|
|
|
G.ccmd_slaver_info[2].slaver = SLAVER_TCP_SERVER_ID; //�务器 //�程开始包
|
|
|
|
G.ccmd_slaver_info[2].slaver = SLAVER_TCP_SERVER_ID; //�务� //�程开始包
|
|
|
|
G.ccmd_slaver_info[2].oper = MODBUS_OPER_WRITE_M; |
|
|
|
G.ccmd_slaver_info[2].reg = 0x03; |
|
|
|
G.ccmd_slaver_info[2].regnum = 0x01; |
|
|
|
G.ccmd_slaver_info[2].bytes = G.ccmd_slaver_info[6].regnum * 2; |
|
|
|
G.ccmd_slaver_info[2].bytes = G.ccmd_slaver_info[2].regnum * 2; |
|
|
|
G.ccmd_slaver_info[2].buf = (U8*)&G.flowStart; |
|
|
|
G.ccmd_slaver_info[2].mask = 0; |
|
|
|
|
|
|
|
G.ccmd_slaver_info[3].slaver = SLAVER_TCP_SERVER_ID; //�务器
|
|
|
|
G.ccmd_slaver_info[3].slaver = SLAVER_TCP_SERVER_ID; //�务�
|
|
|
|
G.ccmd_slaver_info[3].oper = MODBUS_OPER_WRITE_M; |
|
|
|
G.ccmd_slaver_info[3].reg = 0x10; |
|
|
|
G.ccmd_slaver_info[3].regnum = 0x11; |
|
|
|
G.ccmd_slaver_info[3].bytes = G.ccmd_slaver_info[4].regnum * 2; |
|
|
|
G.ccmd_slaver_info[3].bytes = G.ccmd_slaver_info[3].regnum * 2; |
|
|
|
G.ccmd_slaver_info[3].buf = (U8*)&G.total_weight; |
|
|
|
G.ccmd_slaver_info[3].mask = 0; |
|
|
|
|
|
|
@ -103,43 +102,52 @@ void Lu_register_init() |
|
|
|
G.flowStart = 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void L3_protocol_handler_uart4_fun(U8 *pPara,U8 from) |
|
|
|
void L3_protocol_handler_uart4_fun(U8 *pPara) |
|
|
|
{ |
|
|
|
from = 0; |
|
|
|
|
|
|
|
if(StrStartsWith(pPara,"OK")) //module ok
|
|
|
|
if(g_at_send_status.module_ok == 0) |
|
|
|
{ |
|
|
|
g_at_send_status.module_ok = 1; |
|
|
|
if(StrStartsWith(pPara,"OK")) //module ok
|
|
|
|
{ |
|
|
|
g_at_send_status.module_ok = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(StrStartsWith(pPara,"+CCID")) //sim ok
|
|
|
|
else if(g_at_send_status.sim_ok == 0) |
|
|
|
{ |
|
|
|
L0_uart0_uc('s'); |
|
|
|
libc_memcpy(G.ccid,pPara+7,20); |
|
|
|
//getPwd(G.ccid, G.ccid_passwd);
|
|
|
|
g_at_send_status.sim_ok = 1; |
|
|
|
if(StrStartsWith(pPara,"+CCID")) //sim ok
|
|
|
|
{ |
|
|
|
L0_uart0_uc('s'); |
|
|
|
libc_memcpy(G.ccid,pPara+7,20); |
|
|
|
g_at_send_status.sim_ok = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(StrStartsWith(pPara,"+CREG: 1,1")) //net ok
|
|
|
|
else if(g_at_send_status.net_ok == 0) |
|
|
|
{ |
|
|
|
L0_uart0_uc('n'); |
|
|
|
g_at_send_status.net_ok = 1; |
|
|
|
if(StrStartsWith(pPara,"+CREG: 1,1")) //net ok
|
|
|
|
{ |
|
|
|
L0_uart0_uc('n'); |
|
|
|
g_at_send_status.net_ok = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(StrStartsWith(pPara,"+CGATT:1")) //gprs ok
|
|
|
|
else if(g_at_send_status.gprs_ok == 0) |
|
|
|
{ |
|
|
|
L0_uart0_uc('g'); |
|
|
|
g_at_send_status.gprs_ok = 1; |
|
|
|
} |
|
|
|
else if(StrStartsWith(pPara,"CONNECT OK") || StrStartsWith(pPara,"STATE:CONNECT OK")) //conn ok
|
|
|
|
{ //ALREAY CONNECT??????????????¡§???????????????????????¡§????????????????????¡§?¡è???????
|
|
|
|
if(g_at_send_status.conn_ok == 0) |
|
|
|
if(StrStartsWith(pPara,"+CGATT:1")) //gprs ok
|
|
|
|
{ |
|
|
|
L0_uart0_uc('g'); |
|
|
|
g_at_send_status.gprs_ok = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(g_at_send_status.conn_ok == 0) |
|
|
|
{ |
|
|
|
if(StrStartsWith(pPara,"ALREAY") || StrStartsWith(pPara,"CONNECT OK") /*|| StrStartsWith(pPara,"STATE:CONNECT OK")*/) //conn ok
|
|
|
|
{ //ALREAY CONNECT??????????????¡§???????????????????????¡§????????????????????¡§?¡è???????
|
|
|
|
|
|
|
|
L0_uart0_uc('c'); |
|
|
|
g_at_send_status.conn_ok = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(StrStartsWith(pPara,"CLOSE") || StrStartsWith(pPara,"STATE:CLOSED")) //conn close //CLOSE OK / CLOSED
|
|
|
|
else if(g_at_send_status.conn_ok == 1) |
|
|
|
{ |
|
|
|
if(g_at_send_status.conn_ok == 1) |
|
|
|
if(StrStartsWith(pPara,"CLOSE") || StrStartsWith(pPara,"STATE:CLOSED")) //conn close //CLOSE OK / CLOSED
|
|
|
|
{ |
|
|
|
L0_uart0_uc('d'); |
|
|
|
g_at_send_status.conn_ok = 0; |
|
|
@ -147,288 +155,3 @@ void L3_protocol_handler_uart4_fun(U8 *pPara,U8 from) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if 0 |
|
|
|
U16 L2_paper_count(U8 index, U32 angle) |
|
|
|
{ |
|
|
|
S32 x1,y1,x2,y2,x,paper; |
|
|
|
|
|
|
|
//y = (x-x1) * (y2-y1) / (x2-x1) + y1
|
|
|
|
x1 = G.paperCalibs[index].angle0; |
|
|
|
y1 = G.paperCalibs[index].num0; |
|
|
|
x2 = G.paperCalibs[index].angle1; |
|
|
|
y2 = G.paperCalibs[index].num1; |
|
|
|
x = angle; |
|
|
|
|
|
|
|
paper = (S16)(1.0 * (x-x1) * (y2-y1) / (x2-x1) + y1); |
|
|
|
|
|
|
|
if(paper > 0x1FF) |
|
|
|
{ |
|
|
|
paper = 0x1FF; |
|
|
|
} |
|
|
|
if(paper < 0) |
|
|
|
{ |
|
|
|
paper = ~paper + 1; |
|
|
|
paper |= 1<<9; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
paper &= ~(1<<9); |
|
|
|
} |
|
|
|
paper &= 0x3FF; |
|
|
|
return paper; |
|
|
|
} |
|
|
|
|
|
|
|
static void resetToIsp() |
|
|
|
{ |
|
|
|
if(s_nos_tick.t_1s < G.lastResetToISPCmdTimeInSeconds) |
|
|
|
{ |
|
|
|
//isp
|
|
|
|
IAP_CONTR = 0x60; |
|
|
|
//disable wdt
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
G.lastResetToISPCmdTimeInSeconds = s_nos_tick.t_1s + 2; //2s(1s-2s)
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
U8 L2_constructor_ccmodbus_ack(TS_PH3_ccmodbus_ack *pccmodbus, U8 addr, U8 oper, U8 *buf, U8 len) |
|
|
|
{ |
|
|
|
pccmodbus->filter1 = 0xFF; |
|
|
|
pccmodbus->filter2 = 0xFE; |
|
|
|
pccmodbus->num0 = (len + 4) >> 8 & 0xFF; |
|
|
|
pccmodbus->num1 = (len + 4) >> 0 & 0xFF; |
|
|
|
pccmodbus->addr = addr; |
|
|
|
pccmodbus->oper = oper; |
|
|
|
byte_copy_uc((U8*)&pccmodbus->buf, buf, len); |
|
|
|
crc16(pccmodbus->crc, &pccmodbus->addr, len + 2); |
|
|
|
pccmodbus->buf[len] = pccmodbus->crc[1]; |
|
|
|
pccmodbus->buf[len+1] = pccmodbus->crc[0]; |
|
|
|
return len + 6 + 2; |
|
|
|
} |
|
|
|
|
|
|
|
int L2_ph3_common_send(U8 dst, void *buf, U8 len) |
|
|
|
{ |
|
|
|
switch(dst) |
|
|
|
{ |
|
|
|
case ADDR_UPPER: |
|
|
|
L0_uart0_sendArray(buf,len); |
|
|
|
break; |
|
|
|
case ADDR_SERVER: |
|
|
|
L3_gm35_send(buf, len); |
|
|
|
L0_uart0_uc('S'); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_uart_report(void) |
|
|
|
{ |
|
|
|
TS_Printer_Report report_ack; |
|
|
|
|
|
|
|
byte_copy_uc(&report_ack.papers[0],&G.papers[0],3); |
|
|
|
byte_copy_uc(&report_ack.papers[1],&G.papers[1],3); |
|
|
|
byte_copy_uc(&report_ack.boardstatus,&G.boardstatus,3); |
|
|
|
report_ack.ir = 0; |
|
|
|
|
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_REPORT, (U8 *)&report_ack, sizeof(report_ack)); |
|
|
|
L2_ph3_common_send(ADDR_UPPER,(U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_gprs_send_signin_pkg(void) |
|
|
|
{ |
|
|
|
libc_memcpy(gprsTcpPkg_Signin+4,G.ccid,20); |
|
|
|
gprsTcpPkg_Signin[24] = ','; |
|
|
|
libc_memcpy(gprsTcpPkg_Signin+25,G.ccid_passwd,21); |
|
|
|
L2_ph3_common_send(ADDR_SERVER,(U8 *)&gprsTcpPkg_Signin,LEN_GPRS_TCP_PKG_AT_SIGNIN); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_gprs_send_ack_pkg(void) |
|
|
|
{ |
|
|
|
L2_ph3_common_send(ADDR_SERVER,(U8 *)&gprsdataack,LEN_GPRS_TCP_DATA_ACK); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_gprs_send_heart_pkg(void) |
|
|
|
{ |
|
|
|
TS_gprs_heart gprs_heart; |
|
|
|
gprs_heart.version = APP_VERSION_HEX; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_SERVER, OPER_GPRS_HEART, (U8 *)&gprs_heart, sizeof(gprs_heart)); |
|
|
|
L2_ph3_common_send(ADDR_SERVER,(U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_gprs_send_report_pkg(void) |
|
|
|
{ |
|
|
|
TS_Printer_Report report_ack; |
|
|
|
|
|
|
|
byte_copy_uc(&report_ack.papers[0],&G.papers[0],3); |
|
|
|
byte_copy_uc(&report_ack.papers[1],&G.papers[1],3); |
|
|
|
byte_copy_uc(&report_ack.boardstatus,&G.boardstatus,3); |
|
|
|
report_ack.ir = 0; |
|
|
|
|
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_SERVER, OPER_GPRS_REPORT, (U8 *)&report_ack, sizeof(report_ack)); |
|
|
|
L2_ph3_common_send(ADDR_SERVER,(U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_angle_setid(U8 *buf) |
|
|
|
{ |
|
|
|
TS_Angle_SetId *ts_angle_setid = (TS_Angle_SetId*)buf; |
|
|
|
TS_PH1A_DAT ph1a; |
|
|
|
ph1a.filter = D_HETU_FXA; |
|
|
|
ph1a.id = SLAVER_ID_N; |
|
|
|
ph1a.oper = OPER_ANGLE_SET_ID; |
|
|
|
ph1a.xaxis[0] = ts_angle_setid->id; |
|
|
|
ph1a.xaxis[1] = ts_angle_setid->id; |
|
|
|
ph1a.yaxis[0] = ts_angle_setid->id; |
|
|
|
ph1a.yaxis[1] = ts_angle_setid->id; |
|
|
|
ph1a.zaxis[0] = ts_angle_setid->id; |
|
|
|
ph1a.zaxis[1] = ts_angle_setid->id; |
|
|
|
L0_uart2_sendArray(&ph1a,sizeof(TS_PH1A_DAT)); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_angle_setid_ack(U8 id) |
|
|
|
{ |
|
|
|
TS_Angle_SetId ts_setid_ack; |
|
|
|
ts_setid_ack.id = id; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_SET_485_ID, (U8 *)&ts_setid_ack, sizeof(ts_setid_ack)); |
|
|
|
L0_uart0_sendArray((U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_paper_count(U8 *buf) |
|
|
|
{ |
|
|
|
TS_Paper_Count_Ack paper_count_ack; |
|
|
|
TS_Paper_Count *ts_paper = (TS_Paper_Count*)buf; |
|
|
|
U16 num = 0; |
|
|
|
|
|
|
|
if(ts_paper->no >= PAPER_BOX_NUM) |
|
|
|
{ |
|
|
|
L0_uart0_uc('x'); |
|
|
|
return; |
|
|
|
} |
|
|
|
num = L2_paper_count(ts_paper->no,G.currentSensorVal[ts_paper->no]); |
|
|
|
paper_count_ack.no = ts_paper->no; |
|
|
|
paper_count_ack.num[0] = num >> 8 & 0xFF; |
|
|
|
paper_count_ack.num[1] = num >> 0 & 0xFF; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_PAPER_COUNT, (U8 *)&paper_count_ack, sizeof(paper_count_ack)); |
|
|
|
L0_uart0_sendArray((U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_calib_read(U8 *buf) |
|
|
|
{ |
|
|
|
TS_Paper_Upper_calib_ack upper_calib_ack; |
|
|
|
TS_Paper_Upper_Calib_Read *ts_calib = (TS_Paper_Upper_Calib_Read*)buf; |
|
|
|
|
|
|
|
if(ts_calib->no >= PAPER_BOX_NUM) |
|
|
|
{ |
|
|
|
L0_uart0_uc('x'); |
|
|
|
return; |
|
|
|
} |
|
|
|
upper_calib_ack.num0 = G.paperCalibs[ts_calib->no].num0; |
|
|
|
upper_calib_ack.angle0 = G.paperCalibs[ts_calib->no].angle0; |
|
|
|
upper_calib_ack.num1 = G.paperCalibs[ts_calib->no].num1; |
|
|
|
upper_calib_ack.angle1 = G.paperCalibs[ts_calib->no].angle1; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_CALIB_READ, (U8 *)&upper_calib_ack, sizeof(upper_calib_ack)); |
|
|
|
L0_uart0_sendArray((U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_calib(U8 *buf) |
|
|
|
{ |
|
|
|
TS_Paper_Upper_calib_ack upper_calib_ack; |
|
|
|
TS_Paper_Upper_Calib *ts_calib = (TS_Paper_Upper_Calib*)buf; |
|
|
|
if(ts_calib->no >= PAPER_BOX_NUM || ts_calib->point >= 2) |
|
|
|
{ |
|
|
|
L0_uart0_uc('x'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
switch(ts_calib->point) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
{ |
|
|
|
G.paperCalibs[ts_calib->no].num0 = (U16)(ts_calib->paperNum0) << 8 | ts_calib->paperNum1; |
|
|
|
G.paperCalibs[ts_calib->no].angle0 = G.currentSensorVal[ts_calib->no]; |
|
|
|
break; |
|
|
|
} |
|
|
|
case 1: |
|
|
|
{ |
|
|
|
G.paperCalibs[ts_calib->no].num1 = (U16)(ts_calib->paperNum0) << 8 | ts_calib->paperNum1; |
|
|
|
G.paperCalibs[ts_calib->no].angle1 = G.currentSensorVal[ts_calib->no]; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
L3_flash_write_page0(); //??Flash
|
|
|
|
|
|
|
|
upper_calib_ack.num0 = G.paperCalibs[ts_calib->no].num0; |
|
|
|
upper_calib_ack.angle0 = G.paperCalibs[ts_calib->no].angle0; |
|
|
|
upper_calib_ack.num1 = G.paperCalibs[ts_calib->no].num1; |
|
|
|
upper_calib_ack.angle1 = G.paperCalibs[ts_calib->no].angle1; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_CALIB, (U8 *)&upper_calib_ack, sizeof(upper_calib_ack)); |
|
|
|
L0_uart0_sendArray((U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_calib_enter(void) |
|
|
|
{ |
|
|
|
G.runmode = MODE_PAPER_CALIB; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_CALIB_MODE, NULL, 0 ); |
|
|
|
L0_uart0_sendArray((U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
|
|
|
|
void L2_do_calib_leave(void) |
|
|
|
{ |
|
|
|
G.runmode = MODE_RUN; |
|
|
|
ccmodbus_len = L2_constructor_ccmodbus_ack(&ccmodbus_ack, ADDR_UPPER, OPER_CALIB_LEAVE, NULL, 0 ); |
|
|
|
L0_uart0_sendArray((U8 *)&ccmodbus_ack,ccmodbus_len); |
|
|
|
} |
|
|
|
void L3_protocol_handler_uart0_fun(TS_PH3_ccmodbus *p,U8 from) //0?????¡§??????????????¡§a9
|
|
|
|
{ |
|
|
|
switch(p->oper) |
|
|
|
{ |
|
|
|
case OPER_CALIB_MODE: |
|
|
|
L2_do_calib_enter(); |
|
|
|
break; |
|
|
|
case OPER_CALIB_LEAVE: |
|
|
|
L2_do_calib_leave(); |
|
|
|
break; |
|
|
|
case OPER_CALIB: |
|
|
|
L2_do_calib(p->buf); |
|
|
|
break; |
|
|
|
case OPER_CALIB_READ: |
|
|
|
L2_do_calib_read(p->buf); |
|
|
|
break; |
|
|
|
case OPER_PAPER_COUNT: |
|
|
|
L2_do_paper_count(p->buf); |
|
|
|
break; |
|
|
|
case OPER_SET_485_ID: |
|
|
|
L2_do_angle_setid(p->buf); |
|
|
|
break; |
|
|
|
case OPER_RELAY: |
|
|
|
L2_do_relay(p->buf); |
|
|
|
if(from == 1) |
|
|
|
{ |
|
|
|
L0_uart0_uc('R'); |
|
|
|
L0_uart0_uchex(p->buf[0]); |
|
|
|
L0_uart0_uchex(p->buf[1]); |
|
|
|
g_at_send_status.ack_flag = 1; //???¨¦???????????
|
|
|
|
} |
|
|
|
break; |
|
|
|
case OPER_ISP: //ResetToISP???????¡§??????¡ì???
|
|
|
|
L0_uart0_uc('P'); |
|
|
|
resetToIsp(); |
|
|
|
break; |
|
|
|
case 0x00: //????¡¦?
|
|
|
|
L0_uart0_uc('H'); |
|
|
|
break; |
|
|
|
case 0x99: //?¡ã?????¡§????
|
|
|
|
G.runmode = p->buf[1] & 0x0F; |
|
|
|
Lc_print_buf("Version: %s\r\n",APP_VERSION); |
|
|
|
Lc_delay_ms(700);// 2000--7s
|
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
#endif |