更新cfg.c 及 updateSysCfg()

This commit is contained in:
CSSC-WORK\murmur 2023-08-03 11:04:50 +08:00
parent 114c8ee82c
commit 685e260d23
5 changed files with 102 additions and 11 deletions

View File

@ -363,7 +363,7 @@ void initTT_thread_entry()
if (!tmrToPNTT) {
tmrToPNTT = rt_timer_create("TTtimeout", timeoutFunc,
RT_NULL, rt_tick_from_millisecond(scfg.timeout*60*1000),
RT_TIMER_FLAG_ONE_SHOT);//RT_TIMER_FLAG_SOFT_TIMER
RT_TIMER_FLAG_ONE_SHOT);//|RT_TIMER_FLAG_SOFT_TIMER);
// rt_timer_start(tmrToPNTT);
}
if (!isTTon()) {

View File

@ -77,14 +77,42 @@ INIT_APP_EXPORT(iniUFMsg);
* @param v
* @return
*/
int set_cfg(const char *k, const char*v)
int set_cfg(const char *k, long v)
{
setLock();
if (rt_strcmp(v,"NULL") == 0) {//delete key
v = NULL;
}
// int rst = ini_puts("config",k,v,LJW_CFG_FILE_NAME);
int rst = ini_putl("config", k, v, LJW_CFG_FILE_NAME);
if (rst == 1) {
LOG_I("set value success.");
//以下消息队列通知各线程更新参数
rt_sem_release(cfgUpdate);
}
else {
LOG_E("set value fault.");
}
clearLock();
return rst;
}
int set_cfgs(const char *k, const char * v)
{
setLock();
if (rt_strcmp(v,"NULL") == 0) {//delete key
v = NULL;
}
int rst = ini_puts("config",k,v,LJW_CFG_FILE_NAME);
// int rst = ini_putl("config", k, v, LJW_CFG_FILE_NAME);
if (rst == 1) {
LOG_I("set value success.");
@ -122,6 +150,27 @@ int get_cfg(const char *k)
return rst;
}
int get_cfgs(const char *k)
{
setLock();
char buf[MAX_KEY_LEN];
int rst = ini_gets("config",k,"000000",buf,MAX_KEY_LEN,LJW_CFG_FILE_NAME);
if(strcmp(buf, "000000") == 0) {
// // 采用默认值
// int rst = ini_getl("config", k, -1, LJW_CFG_FILE_NAME);
// if (rst == -1) {
LOG_W("no such KEY:%s",k);
clearLock();
return -RT_ERROR;
}
else {
// LOG_I("%s = %s",k,buf);
// LOG_I("%s = %d",k,rst);
}
clearLock();
return rst;
}
static void get_cfg_all(void)
{
char buf[MAX_KEY_LEN];
@ -350,6 +399,7 @@ void addToList_thread_entry(void *parameter)
if (rt_mq_recv(&upfilelist, &msg, sizeof(msg), RT_WAITING_FOREVER) == RT_EOK) {
LOG_D("get %s",msg.fname);
setFileToSend(msg.fname,msg.index);
fileIsReady();
}
}
}

View File

@ -35,7 +35,8 @@
//}FILE_INFO;
int get_cfg(const char *k);
int set_cfg(const char *k, const char*v);
//int set_cfg(const char *k, const char*v);
int set_cfg(const char *k, long v);
int add_val(const char *k);
long get_val(const char *k);
int set_val(const char *k, long v);

View File

@ -434,10 +434,48 @@ int reportDepth(uint8_t *din,size_t len)
void updateSysCfg(uint8_t *cfg, size_t len)
{
LOG_I("FUNC = update SYSCFG");
// SYS_CFG ts;
SYS_CFG ts;
memcpy(&scfg,cfg,len);
// LOG_D("--%d",ts.maxSizePerFile);
// LOG_D("--%d",scfg.maxSizePerFile);
// LOG_HEX("--",16,scfg.openWindowTime,8);
// return;
// scfg = (SYS_CFG)tmp;
/**
*
uint8_t sendInterval;
uint8_t maxTTWaitTime;
uint8_t maxTTRetryCnt;
uint8_t minTTPeriCnt;
uint8_t minTTsinal;
uint8_t minActiveTime;
uint8_t maxActiveTime;
uint8_t timeout;
uint8_t openWindowTime[8];
uint16_t maxSizePerFile;
uint8_t commMode;
uint8_t selfDesSW;
uint8_t locAlert;
uint8_t locReportInterval;
*/
set_cfg("sendInterval",scfg.sendInterval);
set_cfg("maxTTWaitTime",scfg.maxTTWaitTime);
set_cfg("maxTTRetryCnt",scfg.maxTTRetryCnt);
set_cfg("minTTPeriCnt",scfg.minTTPeriCnt);
set_cfg("minTTsinal",scfg.minTTsinal);
set_cfg("minActiveTime",scfg.minActiveTime);
set_cfg("maxActiveTime",scfg.maxActiveTime);
set_cfg("timeout",scfg.timeout);
char tmpstr[20];
bytes2str(scfg.openWindowTime, 8, 10, ",", tmpstr);
set_cfgs("openWindowTime",tmpstr);
set_cfg("maxSizePerFile", scfg.maxSizePerFile);
set_cfg("commMode",scfg.commMode);
set_cfg("selfDesSW",scfg.selfDesSW);
set_cfg("locAlert",scfg.locAlert);
set_cfg("locReportInterval",scfg.locReportInterval);
}
/**
*
@ -445,9 +483,11 @@ void updateSysCfg(uint8_t *cfg, size_t len)
void reportSysCfg()
{
LOG_I("FUNC = report SYSCFG");
// scfg.commMode=0xab;
// scfg.timeout=0x37;
// scfg.maxSizePerFile=2046;
// scfg.commMode=1;
// scfg.timeout=5;
// scfg.maxSizePerFile=1024;
// uint8_t w[]={0x01,2,3,4,5,6,7,8};
// memcpy(scfg.openWindowTime,w,8);
uint8_t size = sizeof(scfg);
uint8_t rst[200] = { 0x5A, 0xA5, ADDR_ANJI, ADDR_TT, _CFG_UPDATE_CFG >> 8, _CFG_UPDATE_CFG & 0xff };
@ -461,11 +501,11 @@ void reportSysCfg()
rst[++p] = 0xED;
size = p+1;
upSend(rst, size);
// upSend(rst, size);
// LOG_HEX("scfg",16,&scfg,size);
LOG_HEX("cfg",16,rst,p+1);
// updateSysCfg(rst, p+1);;
// updateSysCfg(rst+8, rst[7]);
}
//3.2.8定时自报位置信息

View File

@ -37,7 +37,7 @@ typedef struct
uint8_t minActiveTime;
uint8_t maxActiveTime;
uint8_t timeout;
uint8_t openWindowTime[4];
uint8_t openWindowTime[8];
uint16_t maxSizePerFile;
uint8_t commMode;
uint8_t selfDesSW;