Improve:Ipc config module.

This commit is contained in:
Fancy code 2024-05-23 21:36:40 +08:00
parent 8c5eee015d
commit 9c371dfe19
8 changed files with 159 additions and 83 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.5)
unset(CLANG_TIDY_EXE CACHE)
set(CMAKE_SOURCE_DIR_IPCSDK "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING INTERNAL)

View File

@ -18,15 +18,12 @@ set(CMAKE_SYSTEM_PROCESSOR arm)
# Version of the system
set(CMAKE_SYSTEM_VERSION 1)
add_definitions(-Wall -O2 -Os)
add_definitions(-Wno-unused-local-typedefs)
add_definitions(-Wstrict-aliasing -Wwrite-strings)
set(TOOLCHAIN_NAME arm-linux-gnueabihf)
set(TARGET_PLATFORM "linux")
set(SUBMODULE_PATH_OF_IPC_SDK "")
set(PLATFORM_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

View File

@ -10,6 +10,10 @@
2. 本库使用结构体保存数据,可拓展不使用第三方开源库,直接保存结构体数据即可;在资源受限时,可动/静态取消第三方开源库;
3. 配置文件明文显示,可加密;
### 1.2.1. 快启加载配置文件
  快启的项目当中,可能文件系统并未及时挂载,需要确认文件系统挂载成功之后再去加载配置文件。**因此,为保证应用程序逻辑的严谨性,应用程序在读取数据时,应对出参的变量赋值一个无效的初始值,获取配置参数后,==如果还是默认值代表获取配置参数失败==。**
## 1.3. 数据丢失还原机制
  针对可能发生的数据丢失/损坏,提供数据还原机制。

View File

@ -15,7 +15,7 @@
#include "IpcConfigImpl.h"
#include "ILog.h"
#include <string.h>
#include <unistd.h>
#define CHECK_MAP(map) (map.size() == 1 ? true : false)
const char *CONFIG_WIFI_SSID = "wifi_ssid";
const char *CONFIG_WIFI_SSID_DEFAULT = "Hunting 2024";
@ -30,69 +30,9 @@ const char *CONFIG_PIR_DELAYED = "pir_delayed";
const char *CONFIG_STORAGE_LOOP = "storage_loop";
const char *CONFIG_INFRARED_POWER = "infrared_power";
const char *CONFIG_PIR_SENSITIVITY = "pir_sensitivity";
IpcConfigImpl::IpcConfigImpl()
IpcConfigImpl::IpcConfigImpl() : mThreadRuning(false), mCfgChanged(CONFIG_HAS_NOT_CHANGED), mCfg(nullptr)
{
mCfgChanged = CONFIG_HAS_NOT_CHANGED;
memset(&mAllData, 0, sizeof(Config_s));
{
std::map<std::string, StringConfigPack> config;
StringConfigPack pack = {WIFI_SSID_BUFF_SIZE, mAllData.mWifiSsid};
config.insert(std::make_pair(CONFIG_WIFI_SSID, pack));
mCfgMapStringV2.insert(std::make_pair(IpcConfigKey::WIFI_SSID, config));
}
{
std::map<std::string, StringConfigPack> config;
StringConfigPack pack = {WIFI_PASSWORD_BUFF_SIZE, mAllData.mWifiPassword};
config.insert(std::make_pair(CONFIG_WIFI_PASSWORD, pack));
mCfgMapStringV2.insert(std::make_pair(IpcConfigKey::WIFI_PASSWORD, config));
}
{
std::map<std::string, char *> config;
config.insert(std::make_pair(CONFIG_WORK_MODE, &mAllData.mWorkMode));
mCfgMapCharV2.insert(std::make_pair(IpcConfigKey::WORK_MODE, config));
}
{
std::map<std::string, char *> config;
config.insert(std::make_pair(CONFIG_INFRARED_POWER, &mAllData.mInfraredPower));
mCfgMapCharV2.insert(std::make_pair(IpcConfigKey::INFRARED_POWER, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_CONTINUE_SHOT, &mAllData.mContinuousShot));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::CONTINUOUS_SHOT, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_BURST_PHOTO_INTERVAL, &mAllData.mBurstPhotoInterval));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::BURST_PHOTO_INTERVAL, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_IMAGE_SIZE, &mAllData.mImageSize));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::IMGAE_SIZE, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_VIDEO_SIZE, &mAllData.mVideoLength));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::VIDEO_LENGTH, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_PIR_DELAYED, &mAllData.mPirDelayed));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::PIR_DELAYED, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_PIR_SENSITIVITY, &mAllData.mPirSensitivity));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::PIR_SENSITIVITY, config));
}
{
std::map<std::string, bool *> config;
config.insert(std::make_pair(CONFIG_STORAGE_LOOP, &mAllData.mStorageLoopSwitch));
mCfgMapBoolV2.insert(std::make_pair(IpcConfigKey::STORAGE_LOOP_SWITCH, config));
}
// std::map<std::string, std::reference_wrapper<int>> innerMapWorkMode;
// innerMapWorkMode.insert(std::make_pair("work_mode", std::reference_wrapper<int>(mAllData.mWorkMode)));
// mCfgMapInt.insert(std::make_pair(IpcConfigKey::WORK_MODE, innerMapWorkMode));
@ -175,17 +115,28 @@ IpcConfigImpl::IpcConfigImpl()
}
const StatusCode IpcConfigImpl::Init(void)
{
memset(&mAllData, 0, sizeof(Config_s));
mCfg = OpenConfigFile(IPC_CONFIG_FILE_PATH);
if (nullptr == mCfg) {
LogError("Open config file failed.\n");
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
ReadAllConfigParameters();
// memset(&mAllData, 0, sizeof(Config_s));
// InitConfigMap();
// mCfg = OpenConfigFile(IPC_CONFIG_FILE_PATH);
// if (nullptr == mCfg) {
// LogError("Open config file failed.\n");
// return CreateStatusCode(STATUS_CODE_NOT_OK);
// }
// ReadAllConfigParameters();
auto readingConfig = [](std::shared_ptr<IpcConfigImpl> impl) {
impl->ReadingConfigThread();
};
std::shared_ptr<IpcConfigImpl> impl = shared_from_this();
mInitThread = std::thread(readingConfig, impl);
return CreateStatusCode(STATUS_CODE_OK);
}
const StatusCode IpcConfigImpl::UnInit(void)
{
mThreadRuning = false;
if (mInitThread.joinable()) {
mInitThread.join();
}
std::lock_guard<std::mutex> locker(mMutex);
if (CONFIG_HAS_CHANGED == mCfgChanged) {
LogInfo("Save config files.\n");
ConfigSaveFile(mCfg);
@ -195,11 +146,13 @@ const StatusCode IpcConfigImpl::UnInit(void)
}
const StatusCode IpcConfigImpl::ConfigFileSave(void)
{
std::lock_guard<std::mutex> locker(mMutex);
return ConfigSaveFile(mCfg);
}
const int IpcConfigImpl::GetInt(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, int *>>::iterator iter;
iter = mCfgMapIntV2.find(key);
if (iter != mCfgMapIntV2.end() && CHECK_MAP(iter->second)) {
@ -211,6 +164,7 @@ const int IpcConfigImpl::GetInt(const IpcConfigKey &key)
}
void IpcConfigImpl::SetInt(const IpcConfigKey &key, const int &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, int *>>::iterator iter;
iter = mCfgMapIntV2.find(key);
if (iter != mCfgMapIntV2.end() && CHECK_MAP(iter->second)) {
@ -224,6 +178,7 @@ void IpcConfigImpl::SetInt(const IpcConfigKey &key, const int &value)
}
const short IpcConfigImpl::GetShort(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<short>>>::iterator iter;
iter = mCfgMapShort.find(key);
if (iter != mCfgMapShort.end() && CHECK_MAP(iter->second)) {
@ -235,6 +190,7 @@ const short IpcConfigImpl::GetShort(const IpcConfigKey &key)
}
void IpcConfigImpl::SetShort(const IpcConfigKey &key, const short &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<short>>>::iterator iter;
iter = mCfgMapShort.find(key);
if (iter != mCfgMapShort.end() && CHECK_MAP(iter->second)) {
@ -249,6 +205,7 @@ void IpcConfigImpl::SetShort(const IpcConfigKey &key, const short &value)
}
const long IpcConfigImpl::GetLong(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long>>>::iterator iter;
iter = mCfgMapLong.find(key);
if (iter != mCfgMapLong.end() && CHECK_MAP(iter->second)) {
@ -260,6 +217,7 @@ const long IpcConfigImpl::GetLong(const IpcConfigKey &key)
}
void IpcConfigImpl::SetLong(const IpcConfigKey &key, const long &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long>>>::iterator iter;
iter = mCfgMapLong.find(key);
if (iter != mCfgMapLong.end() && CHECK_MAP(iter->second)) {
@ -274,6 +232,7 @@ void IpcConfigImpl::SetLong(const IpcConfigKey &key, const long &value)
}
const long long IpcConfigImpl::GetLLong(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long long>>>::iterator iter;
iter = mCfgMapLLong.find(key);
if (iter != mCfgMapLLong.end() && CHECK_MAP(iter->second)) {
@ -285,6 +244,7 @@ const long long IpcConfigImpl::GetLLong(const IpcConfigKey &key)
}
void IpcConfigImpl::SetLLong(const IpcConfigKey &key, const long long &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long long>>>::iterator iter;
iter = mCfgMapLLong.find(key);
if (iter != mCfgMapLLong.end() && CHECK_MAP(iter->second)) {
@ -299,6 +259,7 @@ void IpcConfigImpl::SetLLong(const IpcConfigKey &key, const long long &value)
}
const char IpcConfigImpl::GetChar(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, char *>>::iterator iter;
iter = mCfgMapCharV2.find(key);
if (iter != mCfgMapCharV2.end() && CHECK_MAP(iter->second)) {
@ -310,6 +271,7 @@ const char IpcConfigImpl::GetChar(const IpcConfigKey &key)
}
void IpcConfigImpl::SetChar(const IpcConfigKey &key, const char &character)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, char *>>::iterator iter;
iter = mCfgMapCharV2.find(key);
if (iter != mCfgMapCharV2.end() && CHECK_MAP(iter->second)) {
@ -324,6 +286,7 @@ void IpcConfigImpl::SetChar(const IpcConfigKey &key, const char &character)
}
const float IpcConfigImpl::GetFloat(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<float>>>::iterator iter;
iter = mCfgMapFloat.find(key);
if (iter != mCfgMapFloat.end() && CHECK_MAP(iter->second)) {
@ -335,6 +298,7 @@ const float IpcConfigImpl::GetFloat(const IpcConfigKey &key)
}
void IpcConfigImpl::SetFloat(const IpcConfigKey &key, const float &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<float>>>::iterator iter;
iter = mCfgMapFloat.find(key);
if (iter != mCfgMapFloat.end() && CHECK_MAP(iter->second)) {
@ -349,6 +313,7 @@ void IpcConfigImpl::SetFloat(const IpcConfigKey &key, const float &value)
}
const double IpcConfigImpl::GetDouble(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<double>>>::iterator iter;
iter = mCfgMapDouble.find(key);
if (iter != mCfgMapDouble.end() && CHECK_MAP(iter->second)) {
@ -360,6 +325,7 @@ const double IpcConfigImpl::GetDouble(const IpcConfigKey &key)
}
void IpcConfigImpl::SetDouble(const IpcConfigKey &key, const double &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<double>>>::iterator iter;
iter = mCfgMapDouble.find(key);
if (iter != mCfgMapDouble.end() && CHECK_MAP(iter->second)) {
@ -374,6 +340,7 @@ void IpcConfigImpl::SetDouble(const IpcConfigKey &key, const double &value)
}
const long double IpcConfigImpl::GetLongDouble(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::reference_wrapper<long double>>::iterator iter;
iter = mCfgMapLongDouble.find(key);
if (iter != mCfgMapLongDouble.end()) {
@ -385,6 +352,7 @@ const long double IpcConfigImpl::GetLongDouble(const IpcConfigKey &key)
}
void IpcConfigImpl::SetLongDouble(const IpcConfigKey &key, const long double &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::reference_wrapper<long double>>::iterator iter;
iter = mCfgMapLongDouble.find(key);
if (iter != mCfgMapLongDouble.end()) {
@ -397,6 +365,7 @@ void IpcConfigImpl::SetLongDouble(const IpcConfigKey &key, const long double &va
}
const bool IpcConfigImpl::GetBool(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, bool *>>::iterator iter;
iter = mCfgMapBoolV2.find(key);
if (iter != mCfgMapBoolV2.end() && CHECK_MAP(iter->second)) {
@ -408,6 +377,7 @@ const bool IpcConfigImpl::GetBool(const IpcConfigKey &key)
}
void IpcConfigImpl::SetBool(const IpcConfigKey &key, const bool &value)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, bool *>>::iterator iter;
iter = mCfgMapBoolV2.find(key);
if (iter != mCfgMapBoolV2.end() && CHECK_MAP(iter->second)) {
@ -421,6 +391,7 @@ void IpcConfigImpl::SetBool(const IpcConfigKey &key, const bool &value)
}
const std::string IpcConfigImpl::GetString(const IpcConfigKey &key)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, StringConfigPack>>::iterator iter;
iter = mCfgMapStringV2.find(key);
if (iter != mCfgMapStringV2.end() && CHECK_MAP(iter->second)) {
@ -433,6 +404,7 @@ const std::string IpcConfigImpl::GetString(const IpcConfigKey &key)
}
void IpcConfigImpl::SetString(const IpcConfigKey &key, const std::string &string)
{
std::lock_guard<std::mutex> locker(mMutex);
std::map<IpcConfigKey, std::map<std::string, StringConfigPack>>::iterator iter;
iter = mCfgMapStringV2.find(key);
if (iter != mCfgMapStringV2.end() && CHECK_MAP(iter->second)) {
@ -478,6 +450,99 @@ void IpcConfigImpl::SetLevel(const IpcConfigKey &key, const ConfigLevel &value)
char config = static_cast<char>(value);
SetChar(key, config);
}
void IpcConfigImpl::ReadingConfigThread(void)
{
constexpr int DIR_PATH_LENGTH = 32;
char dirPath[DIR_PATH_LENGTH] = {0};
strncpy(dirPath, IPC_CONFIG_FILE_PATH, DIR_PATH_LENGTH - 1);
char *lastSlash = strrchr(dirPath, '/');
if (lastSlash == NULL) {
strcpy(dirPath, ".");
}
else {
*lastSlash = '\0';
}
mThreadRuning = true;
LogInfo("Reading config thread is running.dirPath = %s\n", dirPath);
while (mThreadRuning) {
constexpr int FIEL_EXIST = 0;
if (FIEL_EXIST == access(dirPath, F_OK)) {
memset(&mAllData, 0, sizeof(Config_s));
mCfg = OpenConfigFile(IPC_CONFIG_FILE_PATH);
if (nullptr == mCfg) {
LogError("Open config file failed.\n");
return;
}
std::lock_guard<std::mutex> locker(mMutex);
InitConfigMap();
ReadAllConfigParameters();
LogInfo("Read config file success.\n");
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
mThreadRuning = false;
}
void IpcConfigImpl::InitConfigMap(void)
{
{
std::map<std::string, StringConfigPack> config;
StringConfigPack pack = {WIFI_SSID_BUFF_SIZE, mAllData.mWifiSsid};
config.insert(std::make_pair(CONFIG_WIFI_SSID, pack));
mCfgMapStringV2.insert(std::make_pair(IpcConfigKey::WIFI_SSID, config));
}
{
std::map<std::string, StringConfigPack> config;
StringConfigPack pack = {WIFI_PASSWORD_BUFF_SIZE, mAllData.mWifiPassword};
config.insert(std::make_pair(CONFIG_WIFI_PASSWORD, pack));
mCfgMapStringV2.insert(std::make_pair(IpcConfigKey::WIFI_PASSWORD, config));
}
{
std::map<std::string, char *> config;
config.insert(std::make_pair(CONFIG_WORK_MODE, &mAllData.mWorkMode));
mCfgMapCharV2.insert(std::make_pair(IpcConfigKey::WORK_MODE, config));
}
{
std::map<std::string, char *> config;
config.insert(std::make_pair(CONFIG_INFRARED_POWER, &mAllData.mInfraredPower));
mCfgMapCharV2.insert(std::make_pair(IpcConfigKey::INFRARED_POWER, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_CONTINUE_SHOT, &mAllData.mContinuousShot));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::CONTINUOUS_SHOT, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_BURST_PHOTO_INTERVAL, &mAllData.mBurstPhotoInterval));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::BURST_PHOTO_INTERVAL, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_IMAGE_SIZE, &mAllData.mImageSize));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::IMGAE_SIZE, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_VIDEO_SIZE, &mAllData.mVideoLength));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::VIDEO_LENGTH, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_PIR_DELAYED, &mAllData.mPirDelayed));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::PIR_DELAYED, config));
}
{
std::map<std::string, int *> config;
config.insert(std::make_pair(CONFIG_PIR_SENSITIVITY, &mAllData.mPirSensitivity));
mCfgMapIntV2.insert(std::make_pair(IpcConfigKey::PIR_SENSITIVITY, config));
}
{
std::map<std::string, bool *> config;
config.insert(std::make_pair(CONFIG_STORAGE_LOOP, &mAllData.mStorageLoopSwitch));
mCfgMapBoolV2.insert(std::make_pair(IpcConfigKey::STORAGE_LOOP_SWITCH, config));
}
}
void IpcConfigImpl::ReadAllConfigParameters(void)
{
{

View File

@ -19,6 +19,8 @@
#include "StatusCode.h"
#include <map>
#include <memory>
#include <mutex>
#include <thread>
constexpr bool CONFIG_HAS_CHANGED = true;
constexpr bool CONFIG_HAS_NOT_CHANGED = false;
constexpr unsigned int WIFI_SSID_BUFF_SIZE = 64;
@ -71,7 +73,7 @@ public:
MapInt() = default;
~MapInt() = default;
};
class IpcConfigImpl : public IIpcConfig
class IpcConfigImpl : public IIpcConfig, public std::enable_shared_from_this<IpcConfigImpl>
{
public:
IpcConfigImpl();
@ -107,11 +109,16 @@ public:
void SetLevel(const IpcConfigKey &key, const ConfigLevel &value) override;
private:
void ReadingConfigThread(void);
void InitConfigMap(void);
void ReadAllConfigParameters(void);
private:
std::mutex mMutex;
bool mThreadRuning = false;
std::thread mInitThread;
bool mCfgChanged;
void *mCfg;
void *mCfg = nullptr;
Config_s mAllData;
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<int>>> mCfgMapInt;
std::map<IpcConfigKey, std::map<std::string, int *>> mCfgMapIntV2;

View File

@ -15,6 +15,7 @@ TEST(IpcConfigDemo, Demo)
CreateIpcConfigModule();
ILogInit(LOG_INSTANCE_TYPE_END);
IIpcConfig::GetInstance()->Init();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
const int workMode = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::WORK_MODE);
LogInfo("Get workMode = %d\n", workMode);
@ -109,6 +110,7 @@ TEST(IpcConfigDemo, Demo)
IIpcConfig::GetInstance()->ConfigFileSave();
IIpcConfig::GetInstance()->UnInit();
ILogUnInit();
DestroyIpcConfigModule();
DestroyLogModule();
}
class IpcConfigTest : public testing::Test
@ -122,8 +124,8 @@ public:
}
static void SetUpTestCase()
{
ILogInit(LOG_INSTANCE_TYPE_END);
CreateLogModule();
ILogInit(LOG_INSTANCE_TYPE_END);
}
static void TearDownTestCase()
{
@ -134,6 +136,7 @@ public:
{
CreateIpcConfigModule();
IIpcConfig::GetInstance()->Init();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
virtual void TearDown()
{

View File

@ -3,9 +3,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -22,7 +22,8 @@ static void ILogInitCallBack(ILog *object, const enum LogInstance log)
static void ILogFree(ILog *object)
{
}
static int ILogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format, ...)
static int ILogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format,
...)
{
return 0;
}
@ -43,8 +44,7 @@ ILog *GetLogIntance(void)
}
void NewILog(ILog **object)
{
if (!object || !(*object))
{
if (!object || !(*object)) {
return;
}
memcpy(*object, &default_log, sizeof(ILog));
@ -52,6 +52,6 @@ void NewILog(ILog **object)
}
void ResetLogImpl(ILog *impl)
{
log_instance->free(log_instance);
// log_instance->free(log_instance);
log_instance = impl;
}

View File

@ -155,8 +155,8 @@ private:
private:
std::mutex mMutex;
sem_t mSem;
std::thread mDataHandleThread;
bool mThreadRuning;
std::thread mDataHandleThread;
std::list<SingleMcuPacket> mMcuDataList;
};
#endif