diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_sym b/si4/ps5ws.si4project/soft_ps5ws.sip_sym index b5284a5..bd5b0ed 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_sym and b/si4/ps5ws.si4project/soft_ps5ws.sip_sym differ diff --git a/source/app/app_config.c b/source/app/app_config.c index 9d74fbc..b7c64be 100644 --- a/source/app/app_config.c +++ b/source/app/app_config.c @@ -28,7 +28,7 @@ void L3_param_init(void) Lc_strcpy(G.ap_pwd,"ccsens123"); wr_buf.wIndex = wr_buf.rIndex = 0; - wr_buf.maxsize = POINT_LEN; + wr_buf.maxsize = sizeof(wr_buf.buf)/sizeof(PenPoint); for(i=0;irIndex+1)%(p->maxsize) == p->wIndex) + { p->full = 1; + } } U16 Lc_write_cyc_buf(PenPoint *wbuf ,WR_Buf *wp ,U16 wlen) { @@ -168,16 +169,16 @@ U16 Lc_write_cyc_buf(PenPoint *wbuf ,WR_Buf *wp ,U16 wlen) wp->readdr = (wp->wIndex + wlen) % wp->maxsize; if(wp->readdr > wp->wIndex || wp->readdr == 0) { - Lc_buf_copy_uc((U8 *)&wp->buf[wp->wIndex], (U8 *)wbuf, wlen); + Lc_buf_copy_uc((U8 *)&wp->buf[wp->wIndex], (U8 *)wbuf, wlen*sizeof(PenPoint)); } else { wp->relen = wlen - wp->readdr; - Lc_buf_copy_uc((U8 *)&wp->buf[wp->wIndex], (U8 *)wbuf, wp->relen); - Lc_buf_copy_uc((U8 *)&wp->buf[0], (U8 *)(wbuf+wp->relen), wp->readdr); + Lc_buf_copy_uc((U8 *)&wp->buf[wp->wIndex], (U8 *)wbuf, wp->relen*sizeof(PenPoint)); + Lc_buf_copy_uc((U8 *)&wp->buf[0], (U8 *)(wbuf+wp->relen), wp->readdr*sizeof(PenPoint)); } wp->wIndex = wp->readdr; - return sizeof(wbuf); + return wlen; } else { @@ -194,16 +195,16 @@ U16 Lc_read_cyc_buf(PenPoint *rbuf ,WR_Buf *rp ,U16 rlen) rp->readdr = (rp->rIndex + rlen) % rp->maxsize; if(rp->readdr < rp->wIndex || rp->readdr == 0) { - Lc_buf_copy_uc((U8 *)rbuf, (U8 *)&rp->buf[rp->rIndex],rlen); + Lc_buf_copy_uc((U8 *)rbuf, (U8 *)&rp->buf[rp->rIndex],rlen*sizeof(PenPoint)); } else { rp->relen = rlen - rp->readdr; - Lc_buf_copy_uc((U8 *)rbuf,(U8 *) &rp->buf[rp->rIndex], rp->relen); - Lc_buf_copy_uc((U8 *)(rbuf+rp->relen), (U8 *)&rp->buf[0], rp->readdr); + Lc_buf_copy_uc((U8 *)rbuf,(U8 *) &rp->buf[rp->rIndex], rp->relen*sizeof(PenPoint)); + Lc_buf_copy_uc((U8 *)(rbuf+rp->relen), (U8 *)&rp->buf[0], rp->readdr*sizeof(PenPoint)); } rp->rIndex = rp->readdr; - return sizeof(rbuf); + return rlen; } else { diff --git a/source/app/app_config.h b/source/app/app_config.h index d0a91a8..beb6e7a 100644 --- a/source/app/app_config.h +++ b/source/app/app_config.h @@ -39,7 +39,7 @@ typedef struct global_register U16 spee_order;//语音序号 U32 oid3_order;//序号通知(oid3普通码) - char null[25]; + U16 null[25]; U16 pack_order;//包序号 U16 frame_order;//帧序号 @@ -85,8 +85,8 @@ typedef struct global_param vU32 modbusstmp; U16 authed; - U16 flowStarted; U16 flowStartVal; + U16 datapack; U8 mcu_id[7]; U8 pen_up; diff --git a/source/app/app_task_tcp.c b/source/app/app_task_tcp.c index fbdd8ae..9e8c5db 100644 --- a/source/app/app_task_tcp.c +++ b/source/app/app_task_tcp.c @@ -97,7 +97,7 @@ void L3_task_tcp_handle(TS_tcp *s) break; } } - + L2_task_go(D_task_tcp_switch_next_slaver); } else if(s_nos_tick.t_1s - s->sendStamp >= 5) //重发 @@ -116,7 +116,7 @@ void L3_task_tcp_handle(TS_tcp *s) TTSS_Task_step(D_task_tcp_switch_next_slaver) //切换下一个 if(++ s->slaverIndex >= CCMD_SLAVER_INFO_MAX) - { + { s->slaverIndex = 0; } L2_task_go(D_task_tcp_constructor_modbus_pkg); diff --git a/source/app/app_task_tcp_control.c b/source/app/app_task_tcp_control.c index d2003eb..59437ba 100644 --- a/source/app/app_task_tcp_control.c +++ b/source/app/app_task_tcp_control.c @@ -27,7 +27,7 @@ void L3_task_tcp_control_handle(TS_tcp_control *s)//判定是否抬笔/缓冲区 if(s->conn_ok_pool != s_task_gm35_flow.conn_ok) { G.authed = 0; - s->conn_ok_pool =s_task_gm35_flow.conn_ok; + s->conn_ok_pool =s_task_gm35_flow.conn_ok; //s->conn_ok_pool=1 } L2_task_go(D_task_tcp_control_02); TTSS_Task_step(D_task_tcp_control_02)//是否发认证包 @@ -36,28 +36,27 @@ void L3_task_tcp_control_handle(TS_tcp_control *s)//判定是否抬笔/缓冲区 //3s一次发送数据包 if(s_nos_tick.t_1s - ts_tcp_control.tcp_send_stmp >= 3) { - if(!G.authed) + if(!G.authed)//authed == 0 { //L0_uart0_sendstr("111"); //发送认证包 G.ccmd_slaver_info[0].mask = 1; - L2_task_go(D_task_tcp_control_01); } - else + else //authed == 1 { - L2_task_go(D_task_tcp_control_03); + G.ccmd_slaver_info[2].mask = 1; } ts_tcp_control.tcp_send_stmp = s_nos_tick.t_1s; } else if(s_nos_tick.t_1s - ts_tcp_control.tcp_send_stmp >= 60) { G.ccmd_slaver_info[1].mask = 1; - L2_task_go(D_task_tcp_control_01); ts_tcp_control.tcp_send_stmp = s_nos_tick.t_1s; } + } - - + L2_task_go(D_task_tcp_control_01); + #if 0 TTSS_Task_step(D_task_tcp_control_03) if(wr_buf.full == 1) { @@ -72,6 +71,7 @@ void L3_task_tcp_control_handle(TS_tcp_control *s)//判定是否抬笔/缓冲区 G.ccmd_slaver_info[2].mask = 1; L2_task_go(D_task_tcp_control_01); } + #endif TTSS_Task_end(); } diff --git a/source/app/main.c b/source/app/main.c index 62a6eba..ff8cd22 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -101,7 +101,9 @@ void L0_main_init(void) //w600任务初始化 L3_task_gm35_flow_init(W600_ST); //笔头任务初始化 - L3_task_pen_head_init(); + L3_task_pen_head_write_init(); + L3_task_pen_head_read_init(); + //tcp轮询任务初始化 L3_task_tcp_init(); L3_task_tcp_control_init(); @@ -128,12 +130,12 @@ void main(void) } //WIFI - L3_uart2_exp_protocol(&s_uart2_at); - L2_task_gm35_flow_handle(&s_task_gm35_flow); + //L3_uart2_exp_protocol(&s_uart2_at); + //L2_task_gm35_flow_handle(&s_task_gm35_flow); //笔头数据采集 - L3_task_pen_head_handle(&s_task_pen_head); - + L3_task_pen_head_write_handle(&s_task_pen_write); + L3_task_pen_head_read_handle(&s_task_pen_read); //寄存器值监控 //L3_task_reglisten_handle(&s_task_reglisten); @@ -145,10 +147,10 @@ void main(void) //L3_task_modbus_handler2(&s_uart2_rec); //tcp发送 - L3_task_tcp_handle(&ts_tcp); + //L3_task_tcp_handle(&ts_tcp); //tcp master->slaver发送逻辑控制 - L3_task_tcp_control_handle(&ts_tcp_control); + //L3_task_tcp_control_handle(&ts_tcp_control); } } //end main diff --git a/source/app/task_pen_head.c b/source/app/task_pen_head.c index 1f0aa4e..b4a287c 100644 --- a/source/app/task_pen_head.c +++ b/source/app/task_pen_head.c @@ -1,35 +1,95 @@ #include "task_pen_head.h" +#include "../msp/uart0.h" +struct _s_task_pen_head_ s_task_pen_write; +struct _s_task_pen_head_ s_task_pen_read; -struct _s_task_pen_head_ s_task_pen_head; -void L3_task_pen_head_init() +void L3_task_pen_head_write_init(void) { - L1_task_init(&s_task_pen_head.task); - L3_task_s_go(s_task_pen_head,D_task_init); + L1_task_init(&s_task_pen_write.task); + L3_task_s_go(s_task_pen_write,D_task_init); + s_task_pen_write.full = 0; } -#define TTSS_TASK_HEAD_DATA_WRITE 0x01 +void L3_task_pen_head_read_init(void) +{ + L1_task_init(&s_task_pen_read.task); + L3_task_s_go(s_task_pen_read,D_task_init); +} + +#define TTSS_TASK_HEAD_DATA_WRITE 0x01 +#define TTSS_TASK_HEAD_DATA 0x02 U8 i = 0; -void L3_task_pen_head_handle(struct _s_task_pen_head_ *s) +U8 j ; +void L3_task_pen_head_write_handle(struct _s_task_pen_head_ *s) { TTSS_Task_init() L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_WRITE,0); TTSS_Task_step(TTSS_TASK_HEAD_DATA_WRITE) + s->point.x_axis = i; + s->point.y_axis = i; + s->point.time = D_sys_now; + i++; + L0_uart2_ushex(s->point.x_axis); + if(Lc_write_cyc_buf(&s->point,&wr_buf,1) == 0) { - s->point.x_axis = i; - s->point.y_axis = i; - s->point.time = D_sys_now; - i++; - Lc_write_cyc_buf(&s->point,&wr_buf,1); - Lc_buf_full(&wr_buf); + s->full = 1; } - L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_WRITE,D_Tdelay_20ms); + + #if 0 + for(j = 0;jslaver = slaverId; pmodbus->oper = MODBUS_OPER_WRITE_M; pmodbus->buf[0] = reg >> 8 & 0xFF; @@ -177,7 +177,6 @@ void L1_s2b_PH3(TS_Handle_PH3 *p)// reentrant { if ((p->cashe[1] == p->head_0)&&(p->cashe[0] == p->head_1)) { - LED1 ^= 1; p->head = 1; p->max = D_s_PH3_ccmodbus_max - 1; p->sp = (unsigned char *)&(p->ts_ccmodbus);