Browse Source

认证包ok

master
liyating 4 years ago
parent
commit
19f5e541ee
  1. BIN
      si4/ps5ws.si4project/soft_ps5ws.sip_sym
  2. 27
      source/app/app_config.c
  3. 4
      source/app/app_config.h
  4. 16
      source/app/app_task_tcp_control.c
  5. 16
      source/app/main.c
  6. 80
      source/app/task_pen_head.c
  7. 14
      source/app/task_pen_head.h
  8. 2
      source/clib/clib.c
  9. 2
      source/clib/clib.h
  10. 1
      source/ctask/tick.h
  11. 3
      source/tpc/ccmodbus.c

BIN
si4/ps5ws.si4project/soft_ps5ws.sip_sym

Binary file not shown.

27
source/app/app_config.c

@ -28,7 +28,7 @@ void L3_param_init(void)
Lc_strcpy(G.ap_pwd,"ccsens123"); Lc_strcpy(G.ap_pwd,"ccsens123");
wr_buf.wIndex = wr_buf.rIndex = 0; wr_buf.wIndex = wr_buf.rIndex = 0;
wr_buf.maxsize = POINT_LEN; wr_buf.maxsize = sizeof(wr_buf.buf)/sizeof(PenPoint);
for(i=0;i<wr_buf.maxsize;i++) for(i=0;i<wr_buf.maxsize;i++)
{ {
wr_buf.buf[i].time = wr_buf.buf[i].x_axis = wr_buf.buf[i].y_axis = 0; wr_buf.buf[i].time = wr_buf.buf[i].x_axis = wr_buf.buf[i].y_axis = 0;
@ -131,16 +131,15 @@ void L3_reg_reset(void)
G.ccmd_slaver_info[2].oper = MODBUS_OPER_WRITE_M; G.ccmd_slaver_info[2].oper = MODBUS_OPER_WRITE_M;
G.ccmd_slaver_info[2].reg = 0x20; G.ccmd_slaver_info[2].reg = 0x20;
G.ccmd_slaver_info[2].regnum = 0x03;//基础数量,程序每次应动态添加点数 G.ccmd_slaver_info[2].regnum = 0x03;//基础数量,程序每次应动态添加点数
G.ccmd_slaver_info[2].bytes = G.ccmd_slaver_info[2].regnum * 2; G.ccmd_slaver_info[2].bytes = 0;
G.ccmd_slaver_info[2].buf = (U8*)&R.pack_order; G.ccmd_slaver_info[2].buf = (U8*)&R.pack_order;
G.ccmd_slaver_info[2].mask = 0; G.ccmd_slaver_info[2].mask = 0;
G.ccmd_slaver_info[2].extra_num =0; G.ccmd_slaver_info[2].extra_num = 0;
G.modbusstmp = 0; G.modbusstmp = 0;
G.authed = 0; G.authed = 0;
G.flowStarted = 0;
G.flowStartVal = 1; G.flowStartVal = 1;
G.pen_up = 0;
} }
@ -158,7 +157,9 @@ void L3_reg_init(void)
void Lc_buf_full(WR_Buf *p) void Lc_buf_full(WR_Buf *p)
{ {
if((p->rIndex+1)%(p->maxsize) == p->wIndex) if((p->rIndex+1)%(p->maxsize) == p->wIndex)
{
p->full = 1; p->full = 1;
}
} }
U16 Lc_write_cyc_buf(PenPoint *wbuf ,WR_Buf *wp ,U16 wlen) 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; wp->readdr = (wp->wIndex + wlen) % wp->maxsize;
if(wp->readdr > wp->wIndex || wp->readdr == 0) 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 else
{ {
wp->relen = wlen - wp->readdr; 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[wp->wIndex], (U8 *)wbuf, wp->relen*sizeof(PenPoint));
Lc_buf_copy_uc((U8 *)&wp->buf[0], (U8 *)(wbuf+wp->relen), wp->readdr); Lc_buf_copy_uc((U8 *)&wp->buf[0], (U8 *)(wbuf+wp->relen), wp->readdr*sizeof(PenPoint));
} }
wp->wIndex = wp->readdr; wp->wIndex = wp->readdr;
return sizeof(wbuf); return wlen;
} }
else else
{ {
@ -194,16 +195,16 @@ U16 Lc_read_cyc_buf(PenPoint *rbuf ,WR_Buf *rp ,U16 rlen)
rp->readdr = (rp->rIndex + rlen) % rp->maxsize; rp->readdr = (rp->rIndex + rlen) % rp->maxsize;
if(rp->readdr < rp->wIndex || rp->readdr == 0) 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 else
{ {
rp->relen = rlen - rp->readdr; rp->relen = rlen - rp->readdr;
Lc_buf_copy_uc((U8 *)rbuf,(U8 *) &rp->buf[rp->rIndex], rp->relen); 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); Lc_buf_copy_uc((U8 *)(rbuf+rp->relen), (U8 *)&rp->buf[0], rp->readdr*sizeof(PenPoint));
} }
rp->rIndex = rp->readdr; rp->rIndex = rp->readdr;
return sizeof(rbuf); return rlen;
} }
else else
{ {

4
source/app/app_config.h

@ -39,7 +39,7 @@ typedef struct global_register
U16 spee_order;//语音序号 U16 spee_order;//语音序号
U32 oid3_order;//序号通知(oid3普通码) U32 oid3_order;//序号通知(oid3普通码)
char null[25]; U16 null[25];
U16 pack_order;//包序号 U16 pack_order;//包序号
U16 frame_order;//帧序号 U16 frame_order;//帧序号
@ -85,8 +85,8 @@ typedef struct global_param
vU32 modbusstmp; vU32 modbusstmp;
U16 authed; U16 authed;
U16 flowStarted;
U16 flowStartVal; U16 flowStartVal;
U16 datapack;
U8 mcu_id[7]; U8 mcu_id[7];
U8 pen_up; U8 pen_up;

16
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) if(s->conn_ok_pool != s_task_gm35_flow.conn_ok)
{ {
G.authed = 0; 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); L2_task_go(D_task_tcp_control_02);
TTSS_Task_step(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一次发送数据包 //3s一次发送数据包
if(s_nos_tick.t_1s - ts_tcp_control.tcp_send_stmp >= 3) 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"); //L0_uart0_sendstr("111");
//发送认证包 //发送认证包
G.ccmd_slaver_info[0].mask = 1; 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; 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) else if(s_nos_tick.t_1s - ts_tcp_control.tcp_send_stmp >= 60)
{ {
G.ccmd_slaver_info[1].mask = 1; 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; 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) TTSS_Task_step(D_task_tcp_control_03)
if(wr_buf.full == 1) 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; G.ccmd_slaver_info[2].mask = 1;
L2_task_go(D_task_tcp_control_01); L2_task_go(D_task_tcp_control_01);
} }
#endif
TTSS_Task_end(); TTSS_Task_end();
} }

16
source/app/main.c

@ -101,7 +101,9 @@ void L0_main_init(void)
//w600任务初始化 //w600任务初始化
L3_task_gm35_flow_init(W600_ST); 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轮询任务初始化 //tcp轮询任务初始化
L3_task_tcp_init(); L3_task_tcp_init();
L3_task_tcp_control_init(); L3_task_tcp_control_init();
@ -128,12 +130,12 @@ void main(void)
} }
//WIFI //WIFI
L3_uart2_exp_protocol(&s_uart2_at); //L3_uart2_exp_protocol(&s_uart2_at);
L2_task_gm35_flow_handle(&s_task_gm35_flow); //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); //L3_task_reglisten_handle(&s_task_reglisten);
@ -145,10 +147,10 @@ void main(void)
//L3_task_modbus_handler2(&s_uart2_rec); //L3_task_modbus_handler2(&s_uart2_rec);
//tcp发送 //tcp发送
L3_task_tcp_handle(&ts_tcp); //L3_task_tcp_handle(&ts_tcp);
//tcp master->slaver发送逻辑控制 //tcp master->slaver发送逻辑控制
L3_task_tcp_control_handle(&ts_tcp_control); //L3_task_tcp_control_handle(&ts_tcp_control);
} }
} }
//end main //end main

80
source/app/task_pen_head.c

@ -1,35 +1,95 @@
#include "task_pen_head.h" #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); L1_task_init(&s_task_pen_write.task);
L3_task_s_go(s_task_pen_head,D_task_init); L3_task_s_go(s_task_pen_write,D_task_init);
s_task_pen_write.full = 0;
} }
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_WRITE 0x01
#define TTSS_TASK_HEAD_DATA 0x02
U8 i = 0; 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() TTSS_Task_init()
L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_WRITE,0); L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_WRITE,0);
TTSS_Task_step(TTSS_TASK_HEAD_DATA_WRITE) TTSS_Task_step(TTSS_TASK_HEAD_DATA_WRITE)
{
s->point.x_axis = i; s->point.x_axis = i;
s->point.y_axis = i; s->point.y_axis = i;
s->point.time = D_sys_now; s->point.time = D_sys_now;
i++; i++;
Lc_write_cyc_buf(&s->point,&wr_buf,1); L0_uart2_ushex(s->point.x_axis);
Lc_buf_full(&wr_buf); if(Lc_write_cyc_buf(&s->point,&wr_buf,1) == 0)
{
s->full = 1;
}
#if 0
for(j = 0;j<POINT_LEN*2;j++)
{
L0_uart0_ushex(wr_buf.buf[j].x_axis);
L0_uart0_uc(' ');
L0_uart0_ushex(wr_buf.buf[j].y_axis);
L0_uart0_uc(' ');
L0_uart0_ulhex(wr_buf.buf[j].time);
L0_uart0_0d0a();
}
L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA,D_Tdelay_100ms);
U16 k = Lc_read_cyc_buf(R.points,&wr_buf, POINT_LEN);
for(j = 0;j<k;j++)
{
L0_uart0_ushex(R.points[j].x_axis);
L0_uart0_uc(' ');
L0_uart0_ushex(R.points[j].y_axis);
L0_uart0_uc(' ');
L0_uart0_ulhex(R.points[j].time);
L0_uart0_0d0a();
}//Lc_buf_full(&wr_buf);
} }
L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_WRITE,D_Tdelay_20ms); #endif
L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_WRITE,D_Tdelay_100ms);
TTSS_Task_end(); TTSS_Task_end();
} }
#define TTSS_TASK_HEAD_DATA_READ 0x21
void L3_task_pen_head_read_handle(struct _s_task_pen_head_ *s)
{
TTSS_Task_init()
L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_READ,0);
TTSS_Task_step(TTSS_TASK_HEAD_DATA_READ)
if(s_task_pen_write.full)
{
s_task_pen_write.full = 0;
Lc_read_cyc_buf(R.points,&wr_buf, 10);
//G.ccmd_slaver_info[2].extra_num = sizeof(R.points)/2;
for(j = 0;j<10;j++)
{
L0_uart0_ushex(R.points[j].x_axis);
L0_uart0_uc(' ');
L0_uart0_ushex(R.points[j].y_axis);
L0_uart0_uc(' ');
L0_uart0_ulhex(R.points[j].time);
L0_uart0_0d0a();
}
}
L2_task_go_Tdelay(TTSS_TASK_HEAD_DATA_READ,D_Tdelay_50ms);
TTSS_Task_end();
}

14
source/app/task_pen_head.h

@ -7,16 +7,22 @@
#include "../tpc/at0d0a.h" #include "../tpc/at0d0a.h"
#include "../tpc/ccmodbus.h" #include "../tpc/ccmodbus.h"
#include "../app/app_config.h" #include "../app/app_config.h"
struct _s_task_pen_head_ struct _s_task_pen_head_
{ {
TS_task task; TS_task task;
vU32 last_write_time; vU32 last_write_time;
vU32 now_write_time; vU32 now_write_time;
vU32 time_lag; vU32 time_lag;
vU8 full;
vU8 null;
PenPoint point; PenPoint point;
}; };
extern struct _s_task_pen_head_ s_task_pen_head; extern struct _s_task_pen_head_ s_task_pen_write;
extern void L3_task_pen_head_init(); extern struct _s_task_pen_head_ s_task_pen_read;
extern void L3_task_pen_head_handle(struct _s_task_pen_head_ *s); extern void L3_task_pen_head_write_init();
extern void L3_task_pen_head_read_init();
extern void L3_task_pen_head_write_handle(struct _s_task_pen_head_ *s);
extern void L3_task_pen_head_read_handle(struct _s_task_pen_head_ *s);
#endif #endif

2
source/clib/clib.c

@ -88,7 +88,7 @@ void Lc_delay_ms(vU16 i)
} }
} }
void Lc_buf_copy_uc(U8 *dst,U8 *src,U8 len) void Lc_buf_copy_uc(U8 *dst,U8 *src,U16 len)
{ {
while(len--) while(len--)
{ {

2
source/clib/clib.h

@ -112,7 +112,7 @@ extern int Lc_strlen(char *str);
extern U32 Lc_vU32_avg(U32 *d, U8 n); extern U32 Lc_vU32_avg(U32 *d, U8 n);
extern U32 Lc_vS32_media(U32 *d, U8 n); extern U32 Lc_vS32_media(U32 *d, U8 n);
extern int Lc_memset(U8 *buf,U8 c,U16 len); extern int Lc_memset(U8 *buf,U8 c,U16 len);
extern void Lc_buf_copy_uc(U8 *dst,U8 *src,U8 len); extern void Lc_buf_copy_uc(U8 *dst,U8 *src,U16 len);
extern U8 Lc_strStartsWith(U8 *s1,U8 *s2); extern U8 Lc_strStartsWith(U8 *s1,U8 *s2);

1
source/ctask/tick.h

@ -46,6 +46,7 @@ extern struct _s_nos_tick_ s_nos_tick;
#define D_Tdelay_5ms ((5-1) / JIFFIES + 1) #define D_Tdelay_5ms ((5-1) / JIFFIES + 1)
#define D_Tdelay_10ms ((10-1) / JIFFIES + 1) #define D_Tdelay_10ms ((10-1) / JIFFIES + 1)
#define D_Tdelay_20ms ((20-1) / JIFFIES + 1) #define D_Tdelay_20ms ((20-1) / JIFFIES + 1)
#define D_Tdelay_50ms ((50-1) / JIFFIES + 1)
#define D_Tdelay_100ms ((100-1) / JIFFIES + 1) #define D_Tdelay_100ms ((100-1) / JIFFIES + 1)
#define D_Tdelay_200ms ((200-1) / JIFFIES+ 1) #define D_Tdelay_200ms ((200-1) / JIFFIES+ 1)

3
source/tpc/ccmodbus.c

@ -69,7 +69,7 @@ U8 L3_pack_ccmodbus_10(TS_PH3_ccmodbus *pmodbus ,U8 slaverId, U16 reg, U16 num,
{ {
U8 bufsize = 5,i = 0; U8 bufsize = 5,i = 0;
num += extra_num; num += extra_num;
bytes = num*2; bytes = num * 2;
pmodbus->slaver = slaverId; pmodbus->slaver = slaverId;
pmodbus->oper = MODBUS_OPER_WRITE_M; pmodbus->oper = MODBUS_OPER_WRITE_M;
pmodbus->buf[0] = reg >> 8 & 0xFF; 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)) if ((p->cashe[1] == p->head_0)&&(p->cashe[0] == p->head_1))
{ {
LED1 ^= 1;
p->head = 1; p->head = 1;
p->max = D_s_PH3_ccmodbus_max - 1; p->max = D_s_PH3_ccmodbus_max - 1;
p->sp = (unsigned char *)&(p->ts_ccmodbus); p->sp = (unsigned char *)&(p->ts_ccmodbus);

Loading…
Cancel
Save