diff --git a/applications/cfg.ini b/applications/cfg.ini index 226f4fd..8493fdf 100644 --- a/applications/cfg.ini +++ b/applications/cfg.ini @@ -1,5 +1,5 @@ [config] -# V1.81 +# V1.82 #发送间隔(M),以零点为基准时刻 sendInterval=60 # 最大文件大小,超过此大小则进入发送流程 @@ -11,14 +11,14 @@ maxTTWaitTime=4 # TT最大重试次数 maxTTRetryCnt=3 # TT最低信号值 -minTTsinal=5 +minTTsinal=3 # TT状态检测周期数 minTTPeriCnt=2 compressType=1 # 加密方式,0-不加密 encrytType=1 # 开窗时间(UTC+8),持续时间(H)。以【,】为分隔符 -openWindowTime=1,2,7,8 +openWindowTime=1,0,2,0,7,0,8,0 #超时时间(M),主动开机上报数据情况下最后一次通信后开始计时,超时后关闭TT timeout=5 # 工作模式,1-TT,2-BD diff --git a/applications/core.c b/applications/core.c index 44e4e58..eab307b 100644 --- a/applications/core.c +++ b/applications/core.c @@ -311,9 +311,14 @@ static void chkAndSendFile_thread_entry() } else if (rst == -RT_ETIMEOUT)//超时则重试 { - LOG_W("第%d次尝试中TT准备失败。", var + 1); - rt_thread_mdelay(1000); - if ((var+1) == scfg.maxTTRetryCnt) { + if ((var+1) < scfg.maxTTRetryCnt) + { + LOG_W("第%d次尝试中TT准备失败,重试。", var + 1); + deInitTT(); + rt_thread_mdelay(1000); + initTT(); + } + else { LOG_E("TT准备失败"); } } @@ -378,10 +383,10 @@ void resetTM() void d_getRemain() { LOG_D("=%d=",rt_tick_from_millisecond(10*60*1000)); - rt_tick_t *arg1,*arg2; - arg1=rt_timer_control(tmrToPNTT, RT_TIMER_CTRL_GET_TIME, (void*)arg1); - arg2=rt_timer_control(tmrToPNTT, RT_TIMER_CTRL_GET_REMAIN_TIME, (void*)arg2); - LOG_D("tm=%d-%d",&arg1,&arg2); + rt_tick_t arg1,arg2; + arg1=rt_timer_control(tmrToPNTT, RT_TIMER_CTRL_GET_TIME, (void*)&arg1); + arg2=rt_timer_control(tmrToPNTT, RT_TIMER_CTRL_GET_REMAIN_TIME, (void*)&arg2); + LOG_D("tm=%d-%d",arg1,arg2); } /* 定时器超时函数 */ @@ -430,6 +435,7 @@ void initTT_thread_entry() LOG_D("TCP is ready."); tcpRecMQ(); //开启tcp接收线程 recTT(); + repGetTT(); // chkAndSendFile(); } } diff --git a/applications/func/func.c b/applications/func/func.c index cdeb16a..935e394 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -239,14 +239,14 @@ void selfTest() LOG_I("FUNC = selftest"); rt_uint8_t rst[100]={0x5A, 0xA5, ADDR_ANJI, ADDR_TT, _CMD_SELF_TEST>>8, _CMD_SELF_TEST & 0xff}; int p = 6; - rt_uint8_t sysSta=1,xh=0,jh=0,commSpeed=0; + rt_uint8_t sysSta=1,commSpeed=0; //长度 rst[p++]=0x00; rst[p++]=0x09; rst[p++] = sysSta; - rst[p++] = xh;//xh,jh - rst[p++] = jh; + rst[p++] = getXh();//xh,jh + rst[p++] = isTTjh(); rst[p++] = commSpeed; rst[p++] = getPowerLevel(); @@ -943,7 +943,7 @@ void parse3SData(uint8_t *din, size_t count) void chkACK(uint8_t *msg, size_t size) { - rt_uint8_t ackgood[] = { 0x88, 0xAA, 0xBB, 0x88, 0x41, 0x43, 0x4B }; //前四字节=帧头、后三字节=ACK + rt_uint8_t ackgood[] = { 0x88, 0xAA, 0xBB, 0x88, 0x41, 0x43, 0x4B }; //前四字节=帧头、后三字节=ACK if (rt_memcmp(msg, ackgood, 4) == 0 && rt_memcmp(msg + size - 3, ackgood + 4, 3) == 0) { LOG_I("data is ACK."); @@ -969,10 +969,10 @@ void parseTTData(uint8_t *din, size_t len) * | 0x88,0xAA,0xBB,0x88 | 0x00,0x01 | 0x00,0x00 | 0x70,0x21 | 0x00,0xAA | 0x00 | 0x27,0x22,0x22,0x22 | | * +---------------------+-----------+-----------+-----------+-----------+---------+---------------------+------------+ */ - uint8_t head[]={0x88,0xAA,0xBB,0x88, 0x00,0x01, 0x00,0x00, 0x70,0x21, 0x00,0xaa, 0x00, 0x27,0x22,0x22,0x22 }; + uint8_t head[]={0x88,0xAA,0xBB,0x88, 0xFF,0xFF, 0x00,0x00, 0x70,0x21, 0x00,0xaa, 0x00, 0x27,0x22,0x22,0x22 }; //fstart[4] fnum[2]  bak[2]  ftype[2]  fdlen[2]  fcrc[1] ftccid[4] uint8_t index[10]; - size_t n=isInByte(din, len, head, 10, index); + size_t n=isInByte(din, len, head, 4, index);//仅判断帧头,因ACK不一样 uint8_t ndin[200]; if (!n) { LOG_W("TTData中无匹配帧"); diff --git a/applications/getinfo.c b/applications/getinfo.c index 21401a0..4002d93 100644 --- a/applications/getinfo.c +++ b/applications/getinfo.c @@ -192,15 +192,13 @@ static void rulecheck(void) } else { okCnt = 0; - LOG_W("不符合。"); +// LOG_W("不符合。"); return; } if (okCnt >= scfg.minTTPeriCnt) { //TT具备发送条件 -// TTisReady(); TTIsReady(); - LOG_I("符合规则,TT具备发送状态。"); -// updateSta(); +// LOG_I("符合规则,TT具备发送状态。"); okCnt = scfg.minTTPeriCnt -1; } // if (okCnt > minTTPeriCnt) { @@ -392,17 +390,25 @@ MSH_CMD_EXPORT(getTT, 获取天通信息,支持参数。 "getTT 3 1" means try */ int isTTon(void) { +#ifndef RELAY return !rt_pin_read(TT_EN); +#else + return rt_pin_read(TT_EN); +#endif } /** * 判断TT是否激活 * @return 1-已激活,0-未激活 */ -int isTTjh(void) +uint8_t isTTjh(void) { return atoi(TTinfo->jh); } +uint8_t getXh(void) +{ + return (uint8_t)atoi(TTinfo->xh); +} void repGetTT_thread_entry(void* parameter) { diff --git a/applications/led_blink_sample.c b/applications/led_blink_sample.c index 483b6c5..b0cd6ab 100644 --- a/applications/led_blink_sample.c +++ b/applications/led_blink_sample.c @@ -37,13 +37,15 @@ static void led_entry(void *parameter) while (1) { /* 拉低PIN脚 */ - rt_pin_write(pin_num, PIN_LOW); + rt_pin_write(LED_HEART, PIN_LOW); + rt_pin_write(LED_HEART_DEBUG, PIN_HIGH); /* 延时1ms,省电 */ - rt_thread_mdelay(1);//去掉延时,共用print替换 + rt_thread_mdelay(10); //去掉延时,共用print替换 // rt_kprintf("Heartbeat.\n"); /* 拉高PIN脚 */ - rt_pin_write(pin_num, PIN_HIGH); + rt_pin_write(LED_HEART, PIN_HIGH); + rt_pin_write(LED_HEART_DEBUG, PIN_LOW); rt_thread_mdelay(1000); } } @@ -66,8 +68,8 @@ int led_sample(int argc, char *argv[]) tid = rt_thread_create("led", led_entry, RT_NULL, - 512, - RT_THREAD_PRIORITY_MAX / 3, + 256, + 30, 20); if (tid != RT_NULL) { @@ -83,5 +85,5 @@ int led_sample(int argc, char *argv[]) /* 导出到 msh 命令列表中 */ //MSH_CMD_EXPORT(led_sample, led sample); /* 导出到自动初始化 */ -//INIT_COMPONENT_EXPORT(led_sample); +INIT_COMPONENT_EXPORT(led_sample); diff --git a/applications/main.c b/applications/main.c index ef7f3be..5367a12 100644 --- a/applications/main.c +++ b/applications/main.c @@ -39,7 +39,7 @@ int main(void) rt_pin_mode(ETH_RESET_PIN, PIN_MODE_OUTPUT); rt_pin_mode(TT_EN, PIN_MODE_OUTPUT); - rt_pin_write(TT_EN, PIN_HIGH); + rt_pin_write(TT_EN, PIN_LOW); // rt_pin_attach_irq(TT_EN, PIN_IRQ_MODE_FALLING, pwTT_irq_callback, RT_NULL); // 下降沿触发 // rt_pin_irq_enable(TT_EN, PIN_IRQ_ENABLE); // 使能中断 diff --git a/applications/ttmsg/ttmsg.c b/applications/ttmsg/ttmsg.c index a236687..55a60bd 100644 --- a/applications/ttmsg/ttmsg.c +++ b/applications/ttmsg/ttmsg.c @@ -359,7 +359,11 @@ void pwTT_thread_entry(void *parameter) } else { +#ifndef RELAY flag = !(rt_bool_t) atoi(parameter); +#else + flag = (rt_bool_t) atoi(parameter); +#endif } rt_pin_write(TT_EN, flag);// @@ -373,7 +377,7 @@ void pwTT_thread_entry(void *parameter) // } - +#ifndef RELAY if (rt_pin_read(TT_EN))//检查设置后状态 { LOG_I("set TT %s", "OFF");//高电平关断 @@ -384,7 +388,9 @@ void pwTT_thread_entry(void *parameter) // add_val("swCnt");//更新统计值 LOG_I("set TT %s", "ON");//低电平开启 } - +#else + LOG_I("set TT %s", rt_pin_read(TT_EN)?"ON":"OFF"); +#endif } static int swTT(int argc, char **argv) @@ -439,7 +445,7 @@ void recTT_thread_entry() break; } LOG_I("%d Bytes received from TT",msg.size); - LOG_HEX("TTrec", 16, msg.data, msg.size); + LOG_HEX("TTrec", 27, msg.data, msg.size); //此处调用处理函数 // LOG_D("try to parse data."); resetTM(); diff --git a/applications/usrcfg.h b/applications/usrcfg.h index 4863fff..ac76b89 100644 --- a/applications/usrcfg.h +++ b/applications/usrcfg.h @@ -52,6 +52,6 @@ typedef struct #define ROOT_PATH_LOG "/sd/log/" #define ROOT_PATH_DATA "/sd/rxdata/" - +#define RELAY #endif /* APPLICATIONS_USRCFG_H_ */