You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
4.8 KiB
166 lines
4.8 KiB
#include "app_common.h"
|
|
#include "../clib/md5.h"
|
|
#include "../msp/uart0.h"
|
|
#include "../msp/uart2.h"
|
|
#include "../app/app_task_gm35.h"
|
|
#include "../app/app_paraid.h"
|
|
#include "../app/app_task_relay.h"
|
|
|
|
|
|
struct printer_maintenance_global G;
|
|
U8 ccmodbus_len = 0;
|
|
|
|
void Lu_register_init()
|
|
{
|
|
U8 i = 0;
|
|
G.p.slaverId = 0x10;
|
|
G.p.wisdom_car_no = 0x91;
|
|
G.p.thrombolytic_ratio = 9; //0.9
|
|
G.p.bolus_ratio = 1; //0.9
|
|
G.p.hold_ratio = 9; //0.1
|
|
|
|
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;
|
|
}
|
|
G.md_slaver_info[0].slaver = SLAVER_DW20_ID;
|
|
G.md_slaver_info[0].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[0].reg = 0x02;
|
|
G.md_slaver_info[0].regnum = 0x02;
|
|
G.md_slaver_info[0].mask = 2; //0->æ— æ•ˆ 1:暂时有效 2->永久有效
|
|
|
|
G.md_slaver_info[1].slaver = SLAVER_ASGA03_ID; //倾角XYZ
|
|
G.md_slaver_info[1].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[1].reg = 0x04;
|
|
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].oper = MODBUS_OPER_WRITE_M;
|
|
G.md_slaver_info[2].reg = 0x02;
|
|
G.md_slaver_info[2].regnum = 0x05;
|
|
G.md_slaver_info[2].bytes = G.md_slaver_info[2].regnum * 2;
|
|
G.md_slaver_info[2].buf = (U8*)&G.total_weight;
|
|
G.md_slaver_info[2].mask = 0;
|
|
|
|
G.md_slaver_info[3].slaver = SLAVER_SHOW01_ID; //RFID
|
|
G.md_slaver_info[3].oper = MODBUS_OPER_WRITE_M;
|
|
G.md_slaver_info[3].reg = 0x07;
|
|
G.md_slaver_info[3].regnum = 0x01;
|
|
G.md_slaver_info[3].bytes = G.md_slaver_info[3].regnum * 2;
|
|
G.md_slaver_info[3].buf = (U8*)&G.rfid;
|
|
G.md_slaver_info[3].mask = 0;
|
|
|
|
G.md_slaver_info[4].slaver = SLAVER_SHOW01_ID; //显示�按键
|
|
G.md_slaver_info[4].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[4].reg = 0x08;
|
|
G.md_slaver_info[4].regnum = 0x01;
|
|
G.md_slaver_info[4].mask = 2;
|
|
|
|
for(i=0;i<CCMD_SLAVER_INFO_MAX;i++)
|
|
{
|
|
G.ccmd_slaver_info[i].mask = 0;
|
|
}
|
|
|
|
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[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].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[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].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[2].regnum * 2;
|
|
G.ccmd_slaver_info[2].buf = (U8*)&G.flowStarted;
|
|
G.ccmd_slaver_info[2].mask = 0;
|
|
|
|
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[3].regnum * 2;
|
|
G.ccmd_slaver_info[3].buf = (U8*)&G.total_weight;
|
|
G.ccmd_slaver_info[3].mask = 0;
|
|
|
|
G.modbusstmp = 0;
|
|
G.authed = 0;
|
|
G.flowStarted = 0;
|
|
|
|
G._keyled = G._rfid = 0;
|
|
}
|
|
|
|
void L3_protocol_handler_uart4_fun(U8 *pPara)
|
|
{
|
|
if(g_at_send_status.module_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"OK")) //module ok
|
|
{
|
|
g_at_send_status.module_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.sim_ok == 0)
|
|
{
|
|
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(g_at_send_status.net_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CREG: 1,1")) //net ok
|
|
{
|
|
L0_uart0_uc('n');
|
|
g_at_send_status.net_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.gprs_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(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;
|
|
g_at_send_status.tcp_close_stmp = s_nos_tick.t_1s;
|
|
}
|
|
}
|
|
}
|