更新继电器逻辑,继电器不去反
更新TT帧头数据 rulecheck屏蔽部分log避免刷屏 添加led显示
This commit is contained in:
parent
e9fca0787a
commit
afaf81a3fc
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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中无匹配帧");
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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); // 使能中断
|
||||
|
||||
|
@ -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();
|
||||
|
@ -52,6 +52,6 @@ typedef struct
|
||||
#define ROOT_PATH_LOG "/sd/log/"
|
||||
#define ROOT_PATH_DATA "/sd/rxdata/"
|
||||
|
||||
|
||||
#define RELAY
|
||||
|
||||
#endif /* APPLICATIONS_USRCFG_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user