diff --git a/keilp/cc_as_stc02_gsm_main.uvproj b/keilp/cc_as_stc02_gsm_main.uvproj
index ad5c857..0faaf8a 100644
--- a/keilp/cc_as_stc02_gsm_main.uvproj
+++ b/keilp/cc_as_stc02_gsm_main.uvproj
@@ -421,6 +421,11 @@
1
..\source\app\app_task_wdt.c
+
+ app_task_rfid.c
+ 1
+ ..\source\app\app_task_rfid.c
+
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym
index 511b6f6..aad6a62 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym differ
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xc b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xc
index 4d5fded..47610cd 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xc and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xc differ
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xf b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xf
index 4bd335a..07582ce 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xf and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xf differ
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm
index 20f8fa1..6acd883 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm differ
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xr b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xr
index 77ab5cc..96c3678 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xr and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xr differ
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.siproj b/si4/soft_gsm_main.si4project/soft_gsm_main.siproj
index 46296b3..ef516e1 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.siproj and b/si4/soft_gsm_main.si4project/soft_gsm_main.siproj differ
diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.siwork b/si4/soft_gsm_main.si4project/soft_gsm_main.siwork
index aef5b98..5638189 100644
Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.siwork and b/si4/soft_gsm_main.si4project/soft_gsm_main.siwork differ
diff --git a/source/app/app_common.c b/source/app/app_common.c
index 3551c66..a327c0f 100644
--- a/source/app/app_common.c
+++ b/source/app/app_common.c
@@ -6,7 +6,6 @@
#include "../app/app_paraid.h"
#include "../app/app_task_relay.h"
-
struct printer_maintenance_global G;
U8 ccmodbus_len = 0;
@@ -69,6 +68,12 @@ void L2_register_init()
G.md_slaver_info[4].regnum = 0x01;
G.md_slaver_info[4].mask = 2;
+ G.md_slaver_info[5].slaver = SLAVER_ASGA03_UPDOWN_ID; //升降倾角
+ G.md_slaver_info[5].oper = MODBUS_OPER_READ;
+ G.md_slaver_info[5].reg = 0x04;
+ G.md_slaver_info[5].regnum = 0x03;
+ G.md_slaver_info[5].mask = 2;
+
for(i=0;ioper)
+ {
+ case OPER_SET_DEBUG:
+ G.debug = ccmodbus->buf[0];
+ break;
+ }
}
void L3_protocol_handler_uart4_fun(U8 *pPara)
diff --git a/source/app/app_common.h b/source/app/app_common.h
index 9028e72..9455aca 100644
--- a/source/app/app_common.h
+++ b/source/app/app_common.h
@@ -60,6 +60,8 @@ enum CCMODBUS_OPER
OPER_GPRS_HEART = 0x00,
// OPER_GPRS_ACK = 0x95,
OPER_GPRS_REPORT = 0x97,
+
+ OPER_SET_DEBUG = 0x01,
};
enum TS_485_OPER
@@ -90,13 +92,17 @@ typedef struct printer_paper_calib
/**
* Register Memory Map
- */
+ */
+#define SLAVER_RFID 0x00 //RFID发送过来的数据
+#define SLAVER_COM0 0x01 //COM0发送过来的数据
+
#define SLAVER_DW20_ID 0x11
-#define SLAVER_ASGA03_ID 0x12
+#define SLAVER_ASGA03_ID 0x12 //称重内部倾角传感
#define SLAVER_SHOW01_ID 0x13
#define SLAVER_TCP_SERVER_ID 0x14
+#define SLAVER_ASGA03_UPDOWN_ID 0x15 //升降位置倾角传感
-#define MD_SLAVER_INFO_MAX 5
+#define MD_SLAVER_INFO_MAX 6
#define CCMD_SLAVER_INFO_MAX 4
//需要持久化的参数,不能超过72字节,否则会导致eeprom溢出
@@ -145,7 +151,10 @@ typedef struct printer_maintenance_global
U8 _rfid;
S32 pi_weight;
S32 total_weight;
+
+ CCAsGaInfo asga_02;
U8 reset;
+ U8 debug;
}PMGlobal;
//寄存器内存基地址
@@ -159,6 +168,7 @@ typedef struct printer_maintenance_global
extern struct printer_maintenance_global G;
extern void L2_register_init(void);
extern void L3_protocol_handler_uart4_fun(U8 *pPara);
+extern void L3_protocol_handler_uart0_fun(TS_PH3_ccmodbus *ccmodbus);
extern void L2_do_board_reset(void);
extern void L2_do_gm35_reset(void);
diff --git a/source/app/app_drv.c b/source/app/app_drv.c
index e01ba03..0a5d002 100644
--- a/source/app/app_drv.c
+++ b/source/app/app_drv.c
@@ -70,23 +70,39 @@ void L3_UARTcom4_exp_protocol(TS_Handle_0d0a *p)
}
}
+//FF FE 05 00 00 28 FC CC 从FF开始校验
+int L3_checkCrc16(TS_PH3_ccmodbus *ccmodbus)
+{
+ U8 crc[2];
+ crc16(crc,&ccmodbus->filter1,ccmodbus->num + 3 - 2);
+ if(crc[0] == ccmodbus->buf[ccmodbus->num-2-2] && crc[1] == ccmodbus->buf[ccmodbus->num-2-1])
+ {
+ return 1;
+ }
+ return 0;
+}
+
void L3_UARTcom0_exp_protocol(TS_Handle_PH3 *p)
{
if (1 == p->ok)
{
- #if 0
- TS_PH3_ccmodbus ccmodbus;
- byte_copy_uc((U8*)&ccmodbus,(U8*)&p->ts_ccmodbus,p->ts_ccmodbus.num + 3);
- if(ccmodbus.buf[0] != G._rfid) //rfid发生改变
- {
- G.rfid = G._rfid = ccmodbus.buf[0];
+ if(L3_checkCrc16(&p->ts_ccmodbus))
+ {
+ switch(p->ts_ccmodbus.slaver)
+ {
+ case SLAVER_RFID:
+ L0_uart0_uc('r');
+ L0_uart0_uchex(p->ts_ccmodbus.buf[0]);
+ if(p->ts_ccmodbus.buf[0] != G._rfid) //rfid发生改变
+ {
+ G.rfid = G._rfid = p->ts_ccmodbus.buf[0];
+ }
+ break;
+ case SLAVER_COM0:
+ L3_protocol_handler_uart0_fun(&p->ts_ccmodbus);
+ break;
+ }
}
- #else
- if(p->ts_ccmodbus.buf[0] != G._rfid) //rfid发生改变
- {
- G.rfid = G._rfid = p->ts_ccmodbus.buf[0];
- }
- #endif
p->ok = 0;
}
}
@@ -95,20 +111,17 @@ void L3_UARTcom0_exp_protocol(TS_Handle_PH3 *p)
void L3_UARTcom3_exp_protocol(TS_Handle_PH3 *p)
{
if (1 == p->ok)
- {
- #if 0
- TS_PH3_ccmodbus ccmodbus;
- byte_copy_uc((U8*)&ccmodbus,(U8*)&p->ts_ccmodbus,p->ts_ccmodbus.num + 3);
- if(ccmodbus.buf[0] != G._rfid) //rfid发生改变
+ {
+ if(L3_checkCrc16(&p->ts_ccmodbus))
{
- G.rfid = G._rfid = ccmodbus.buf[0];
+ L0_uart0_uc('r');
+ L0_uart0_uchex(p->ts_ccmodbus.buf[0]);
+
+ if(p->ts_ccmodbus.buf[0] != G._rfid) //rfid发生改变
+ {
+ G.rfid = G._rfid = p->ts_ccmodbus.buf[0];
+ }
}
- #else
- if(p->ts_ccmodbus.buf[0] != G._rfid) //rfid发生改变
- {
- G.rfid = G._rfid = p->ts_ccmodbus.buf[0];
- }
- #endif
p->ok = 0;
}
}
diff --git a/source/app/app_task_485.c b/source/app/app_task_485.c
index a403fa0..c50e8ca 100644
--- a/source/app/app_task_485.c
+++ b/source/app/app_task_485.c
@@ -62,7 +62,7 @@ void L3_task_485_handle(TS_485 *s)
G.md_slaver_info[s->slaverIndex].mask = 0;
}
- //TODO 这里可以根据modbus协议让代码通用,
+ //TODO 这里可以根据modbus协议让代码通用
if(s->pAckPkg->oper == MODBUS_OPER_READ)
{
if(s->pAckPkg->salver == G.md_slaver_info[0].slaver)
@@ -105,6 +105,12 @@ void L3_task_485_handle(TS_485 *s)
}
}
}
+ else if(s->pAckPkg->salver == G.md_slaver_info[5].slaver)
+ {
+ G.asga_02.xaxis = (U16)(s->pAckPkg->buf[1]) << 8 | (U16)(s->pAckPkg->buf[2]);
+ G.asga_02.yaxis = (U16)(s->pAckPkg->buf[3]) << 8 | (U16)(s->pAckPkg->buf[4]);
+ G.asga_02.zaxis = (U16)(s->pAckPkg->buf[5]) << 8 | (U16)(s->pAckPkg->buf[6]);
+ }
}
}
}
diff --git a/source/app/app_task_gm35.c b/source/app/app_task_gm35.c
index 0b37d73..c3c96dd 100644
--- a/source/app/app_task_gm35.c
+++ b/source/app/app_task_gm35.c
@@ -44,7 +44,10 @@ U8 * _cipsend_hex(U8 len)
void L3_gm35_send_str(U8 *str)
{
L0_uart4_sendstr(str);
- L0_uart0_sendstr(str);
+ if(G.debug)
+ {
+ L0_uart0_sendstr(str);
+ }
}
//将数据放入gm35待发送缓冲区
@@ -52,7 +55,20 @@ void L3_gm35_send_data(U8 *buf , U8 len)
{
L3_gm35_send_str(_cipsend_hex(len));
L0_uart4_sendArray(buf,len);
- L0_uart0_sendArray(buf,len);
+ if(G.debug)
+ {
+ L0_uart0_sendArray(buf,len);
+ }
+}
+
+void L3_gm35_rcv_data(U8* buf,U8 num)
+{
+ if(G.debug)
+ {
+ L0_uart0_sendstr("ATRCV=");
+ L0_uart0_uchex(num);
+ L0_uart0_sendArray(buf,num);
+ }
}
//------------------------------------------------------ gm35 tasks --------------------------------
@@ -138,6 +154,7 @@ void L2_task_gm35_daemon_handle(struct _s_task_gm35_gprs_ *s)
P55 = 1; //灯灭
if(s_nos_tick.t_1s - g_at_send_status.tcp_close_stmp > TCP_MAX_DISCONN)
{
+ L0_uart0_uc('>');
if(++g_at_send_status.gm35_reboot_times >= TCP_MAX_GM35_REBOOT_TIMES)
{
L2_do_board_reset();
diff --git a/source/app/app_task_gm35.h b/source/app/app_task_gm35.h
index 1502c63..17de300 100644
--- a/source/app/app_task_gm35.h
+++ b/source/app/app_task_gm35.h
@@ -85,6 +85,7 @@ extern struct _s_task_gm35_gprs_ s_task_connect_gprs;
extern void L3_task_gm35_core_init(void);
extern void L3_task_gm35_core_handle(void);
extern void L3_gm35_send_data(U8 *buf , U8 len);
+extern void L3_gm35_rcv_data(U8* buf,U8 num);
#endif
diff --git a/source/app/app_task_rfid.c b/source/app/app_task_rfid.c
new file mode 100644
index 0000000..f31693e
--- /dev/null
+++ b/source/app/app_task_rfid.c
@@ -0,0 +1,43 @@
+#include "app_task_rfid.h"
+#include "../msp/uart0.h"
+#include "../msp/uart3.h"
+
+#define MODBUS_SLAVER_RETRY_MAX_TIME 3
+
+TS_rfid ts_rfid;
+
+void L3_task_rfid_init(void)
+{
+ L1_task_init(&ts_rfid.task);
+ L3_task_s_go(ts_rfid,D_task_init);
+}
+
+U8 rfid_start_pkg[] = {0xBB,0x00,0x27,0x00,0x03,0x22,0xFF,0xFF,0x4A,0x7E};
+U8 rfid_stop_pkg[] = {0xBB,0x00,0x28,0x00,0x00,0x28,0x7E};
+
+void L1_enable_rfid()
+{
+ L0_uart0_sendArray(rfid_start_pkg,10);
+ L0_uart3_sendArray(rfid_start_pkg,10);
+}
+
+void L1_disable_rfid()
+{
+ L0_uart0_sendArray(rfid_stop_pkg,7);
+ L0_uart3_sendArray(rfid_stop_pkg,7);
+}
+
+#define D_task_rfid_send 0x51
+void L3_task_rfid_handle(TS_rfid *s)
+{
+ TTSS_Task_init();
+ L2_task_go(D_task_rfid_send);
+
+ TTSS_Task_step(D_task_rfid_send)
+ L1_enable_rfid();
+ L2_task_go_Tdelay(D_task_rfid_send, D_Tdelay_10s);
+
+ TTSS_Task_end();
+}
+
+
diff --git a/source/app/app_task_rfid.h b/source/app/app_task_rfid.h
new file mode 100644
index 0000000..43586b3
--- /dev/null
+++ b/source/app/app_task_rfid.h
@@ -0,0 +1,17 @@
+#ifndef APP_TASK_RFID
+#define APP_TASK_RFID
+
+#include "../ctask/task.h"
+#include "app_common.h"
+
+typedef struct
+{
+ TS_task task;
+}TS_rfid;
+
+extern TS_rfid ts_rfid;
+
+extern void L3_task_rfid_init();
+extern void L3_task_rfid_handle(TS_rfid *s);
+
+#endif
diff --git a/source/app/app_task_tcp.c b/source/app/app_task_tcp.c
index d751bb5..9a31f01 100644
--- a/source/app/app_task_tcp.c
+++ b/source/app/app_task_tcp.c
@@ -59,10 +59,7 @@ void L3_task_tcp_handle(TS_tcp *s)
g_at_send_status.tcp_last_recv_stmp = s_nos_tick.t_1s;
s->pAckPkg = (TS_PH3_ccmodbus*)(s_uart4_tcp_rec.sp);
- L0_uart0_sendstr("ATRCV=");
- L0_uart0_uchex(s->pAckPkg->num + 3);
- L0_uart0_sendArray((U8*)s->pAckPkg,s->pAckPkg->num + 3);
-
+ L3_gm35_rcv_data((U8*)s->pAckPkg,s->pAckPkg->num + 3);
if(s->pAckPkg->slaver == G.ccmd_slaver_info[s->slaverIndex].slaver)
{
s->ackFlag = 1;
diff --git a/source/app/app_task_wdt.c b/source/app/app_task_wdt.c
index 981d0d6..b2e6b5e 100644
--- a/source/app/app_task_wdt.c
+++ b/source/app/app_task_wdt.c
@@ -9,6 +9,7 @@ void L3_task_wdt_init(void)
{
L1_task_init(&s_task_wdt.task);
L3_task_s_go(s_task_wdt,D_task_init);
+ L0_wdt_init();
}
#define TTSS_TASK_WDT_STP_01 0x1
diff --git a/source/app/main.c b/source/app/main.c
index f7eef89..c7c2687 100644
--- a/source/app/main.c
+++ b/source/app/main.c
@@ -93,12 +93,14 @@ void L0_main_init(void)
L3_task_wdt_init(); //看门狗任务初始化
#endif
+ L3_task_wdt_init();
L2_gm35_init();
L3_task_gm35_core_init();
L3_task_485_init(); //485轮询任务初始化
L3_task_485_control_init();
L3_task_tcp_init(); //485轮询任务初始化
L3_task_tcp_control_init();
+ L3_task_rfid_init();//rfid任务初始化
}
//===============================================
@@ -140,6 +142,7 @@ void main(void)
L3_task_wdt_handle(&s_task_wdt);
//串口0,3 RFID接收
+ L3_task_rfid_handle(&ts_rfid);
L3_UARTcom0_exp_protocol(&s_uart0_rec);
L3_UARTcom3_exp_protocol(&s_uart3_rec);
diff --git a/source/app/main.h b/source/app/main.h
index 40d2e58..0c6bb0f 100644
--- a/source/app/main.h
+++ b/source/app/main.h
@@ -83,6 +83,7 @@
#include "../app/app_task_tcp.h"
#include "../app/app_task_tcp_control.h"
#include "../app/app_task_relay.h"
+#include "../app/app_task_rfid.h"
#include "../app/app_common.h"
#include "../app/app_paraid.h"
diff --git a/source/msp/UART3.c b/source/msp/UART3.c
index 02af1d6..fa2c46e 100644
--- a/source/msp/UART3.c
+++ b/source/msp/UART3.c
@@ -67,20 +67,21 @@ struct _s_uart3_send_buf_ s_uart3_send_depot;
void L0_uart3_init(void) //57600
{
-#if 0
- S3CON = 0x10; //8位数据,可变波特率
- S3CON &= 0xBF; //串口3选择定时器2为波特率发生器
- AUXR |= 0x04; //定时器2时钟为Fosc,即1T
- T2L = 0xD0; //设定定时初值
- T2H = 0xFF; //设定定时初值
- AUXR |= 0x10; //启动定时器
-#endif
+#if 0 //57600
S3CON = 0x10; //8位数据,可变波特率
S3CON |= 0x40; //串口3选择定时器3为波特率发生器
T4T3M |= 0x02; //定时器3时钟为Fosc,即1T
T3L = 0xD0; //设定定时初值
T3H = 0xFF; //设定定时初值
T4T3M |= 0x08; //启动定时器3
+#else //115200
+ S3CON = 0x10; //8位数据,可变波特率
+ S3CON |= 0x40; //串口3选择定时器3为波特率发生器
+ T4T3M |= 0x02; //定时器3时钟为Fosc,即1T
+ T3L = 0xE8; //设定定时初值
+ T3H = 0xFF; //设定定时初值
+ T4T3M |= 0x08; //启动定时器3
+#endif
D_uart3_ES_INT_OPEN(); //打开串口中断
}
diff --git a/source/tpc/tpc_ccmodbus.c b/source/tpc/tpc_ccmodbus.c
index a120f14..887fc7c 100644
--- a/source/tpc/tpc_ccmodbus.c
+++ b/source/tpc/tpc_ccmodbus.c
@@ -146,8 +146,9 @@ void L1_s2b_PH3(TS_Handle_PH3 *p)// reentrant
}
if(p->num >= p->max)
{
- crc16(p->crc,&p->ts_ccmodbus.slaver,p->ts_ccmodbus.num - 2);
- if(/*p->crc[0] == p->ts_ccmodbus.crc[1] && p->crc[1] == p->ts_ccmodbus.crc[0]*/ 1)
+ //crc16(p->crc,&p->ts_ccmodbus.slaver,p->ts_ccmodbus.num - 2);
+ //if(p->crc[0] == p->sp[p->num-1] && p->crc[1] == p->sp[p->num])
+ if(1)
{
if (p->ok != 1)
{