mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Merge branch 'master-develop' of gitee.com:shenzhen-jiuyilian/ipc into master-develop
This commit is contained in:
commit
1783d9849f
|
@ -27,7 +27,7 @@ llvm-twine-local,\
|
||||||
misc-confusable-identifiers,\
|
misc-confusable-identifiers,\
|
||||||
misc-definitions-in-headers,\
|
misc-definitions-in-headers,\
|
||||||
misc-header-include-cycle,\
|
misc-header-include-cycle,\
|
||||||
-misc-include-cleaner,\
|
misc-include-cleaner,\
|
||||||
misc-misleading-bidirectional,\
|
misc-misleading-bidirectional,\
|
||||||
misc-misleading-identifier,\
|
misc-misleading-identifier,\
|
||||||
misc-misplaced-const,\
|
misc-misplaced-const,\
|
||||||
|
@ -55,7 +55,7 @@ set(CLANG_FORMAT_FILE "LLVM ${CMAKE_SOURCE_DIR_IPCSDK}/tools/clang-format/.clang
|
||||||
if(${LINUX_TEST} MATCHES "true")
|
if(${LINUX_TEST} MATCHES "true")
|
||||||
set(CLANG_TIDY_SUPPORT "true")
|
set(CLANG_TIDY_SUPPORT "true")
|
||||||
set(CLANG_FORMAT_SUPPORT "true")
|
set(CLANG_FORMAT_SUPPORT "true")
|
||||||
set(COMPILE_IMPROVE_SUPPORT "false") # 开启后每次编译可能会很慢
|
set(COMPILE_IMPROVE_SUPPORT "true") # 开启后每次编译可能会很慢
|
||||||
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
||||||
endif()
|
endif()
|
||||||
# ------------ build clang-tools end ------------ #
|
# ------------ build clang-tools end ------------ #
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "ConfigBase.h"
|
#include "ConfigBase.h"
|
||||||
#include "IConfigBase.h"
|
#include "IConfigBase.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include <memory>
|
||||||
|
#include <stdlib.h>
|
||||||
static bool ObjectCheck(void *object)
|
static bool ObjectCheck(void *object)
|
||||||
{
|
{
|
||||||
if (nullptr == object) {
|
if (nullptr == object) {
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "ConfigBaseCode.h"
|
#include "ConfigBaseCode.h"
|
||||||
|
#include "ConfigBase.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static const char *ConfigCodeString[CONFIG_CODE_END - STATUS_CODE_END + 1] = {"CONFIG_CODE_PARAM_NOT_EXIST",
|
static const char *ConfigCodeString[CONFIG_CODE_END - STATUS_CODE_END + 1] = {"CONFIG_CODE_PARAM_NOT_EXIST",
|
||||||
"CONFIG_CODE_END"};
|
"CONFIG_CODE_END"};
|
||||||
|
|
|
@ -13,10 +13,16 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "ConfigBaseImpl.h"
|
#include "ConfigBaseImpl.h"
|
||||||
|
#include "ConfigBase.h"
|
||||||
#include "ConfigBaseCode.h"
|
#include "ConfigBaseCode.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include <libconfig.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
constexpr int INVALID_RESULT = -1;
|
constexpr int INVALID_RESULT = -1;
|
||||||
|
@ -38,7 +44,8 @@ bool ConfigBaseImpl::OpenConfigFile(void)
|
||||||
if (FIEL_EXIST == access(mFileName.c_str(), F_OK)) {
|
if (FIEL_EXIST == access(mFileName.c_str(), F_OK)) {
|
||||||
if (!config_read_file(&mCfg, mFileName.c_str())) {
|
if (!config_read_file(&mCfg, mFileName.c_str())) {
|
||||||
LogError("Read file failed[%s].\n", mFileName.c_str());
|
LogError("Read file failed[%s].\n", mFileName.c_str());
|
||||||
fprintf(stderr, "%s:%d - %s\n", config_error_file(&mCfg), config_error_line(&mCfg), config_error_text(&mCfg));
|
fprintf(
|
||||||
|
stderr, "%s:%d - %s\n", config_error_file(&mCfg), config_error_line(&mCfg), config_error_text(&mCfg));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
#include "IConfigBase.h"
|
#include "IConfigBase.h"
|
||||||
#include "ConfigBaseImpl.h"
|
#include "ConfigBaseImpl.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdlib.h>
|
||||||
bool IConfigBase::OpenConfigFile(void)
|
bool IConfigBase::OpenConfigFile(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
*/
|
*/
|
||||||
#include "KeyControl.h"
|
#include "KeyControl.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
constexpr long int KEY_PRESSING = 0;
|
constexpr long int KEY_PRESSING = 0;
|
||||||
constexpr unsigned int NOT_A_HOLD_KEY_ACTION = 0;
|
constexpr unsigned int NOT_A_HOLD_KEY_ACTION = 0;
|
||||||
KeyControl::KeyControl()
|
KeyControl::KeyControl()
|
||||||
|
@ -30,14 +32,17 @@ bool KeyControl::IsKeyPressing(void)
|
||||||
}
|
}
|
||||||
const std::string VKeyControl::GetKeyName(void)
|
const std::string VKeyControl::GetKeyName(void)
|
||||||
{
|
{
|
||||||
|
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n");
|
||||||
return "undefine";
|
return "undefine";
|
||||||
}
|
}
|
||||||
unsigned int VKeyControl::GetStatusCheckPeriodMs(void)
|
unsigned int VKeyControl::GetStatusCheckPeriodMs(void)
|
||||||
{
|
{
|
||||||
|
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void VKeyControl::KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs)
|
void VKeyControl::KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs)
|
||||||
{
|
{
|
||||||
|
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n");
|
||||||
}
|
}
|
||||||
void KeyControl::Init(void)
|
void KeyControl::Init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
*/
|
*/
|
||||||
#include "LedControl.h"
|
#include "LedControl.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
StatusCode VSingleControl::GetLedState(LedState &state)
|
StatusCode VSingleControl::GetLedState(LedState &state)
|
||||||
{
|
{
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
|
|
@ -13,21 +13,21 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "ILog.h"
|
||||||
#include "ILogCpp.h"
|
#include "ILogCpp.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <stdlib.h>
|
||||||
#include <memory>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static void LogFree(ILog *object)
|
static void LogFree(ILog *object)
|
||||||
{
|
{
|
||||||
printf("log instance free.\n");
|
printf("log instance free.\n");
|
||||||
if (object)
|
if (object) {
|
||||||
{
|
|
||||||
free(object);
|
free(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static int LogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format, ...)
|
static int LogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// LogTypeToString(type);
|
// LogTypeToString(type);
|
||||||
|
@ -40,8 +40,7 @@ static int LogPrintf(ILog *object, const char *function, const int line, const e
|
||||||
va_start(vargs, format);
|
va_start(vargs, format);
|
||||||
int len = vsnprintf(buff + headLen, SEND_TRACE_BUFF_SIZE - headLen, format, vargs);
|
int len = vsnprintf(buff + headLen, SEND_TRACE_BUFF_SIZE - headLen, format, vargs);
|
||||||
va_end(vargs);
|
va_end(vargs);
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
case LOG_TYPE_INFORMATION:
|
case LOG_TYPE_INFORMATION:
|
||||||
ILogCpp::GetInstance()->InFo(buff);
|
ILogCpp::GetInstance()->InFo(buff);
|
||||||
break;
|
break;
|
||||||
|
@ -75,16 +74,13 @@ static void LogImplInit(Log *log)
|
||||||
}
|
}
|
||||||
void NewLog(Log **log)
|
void NewLog(Log **log)
|
||||||
{
|
{
|
||||||
if (!log)
|
if (!log) {
|
||||||
{
|
|
||||||
printf("STATUS_CODE_INVALID_PARAMENTER\n");
|
printf("STATUS_CODE_INVALID_PARAMENTER\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(*log))
|
if (!(*log)) {
|
||||||
{
|
|
||||||
*log = (Log *)malloc(sizeof(Log));
|
*log = (Log *)malloc(sizeof(Log));
|
||||||
if (*log)
|
if (*log) {
|
||||||
{
|
|
||||||
printf("NewLog succeed.\n");
|
printf("NewLog succeed.\n");
|
||||||
NewILog((ILog **)log);
|
NewILog((ILog **)log);
|
||||||
LogImplInit(*log);
|
LogImplInit(*log);
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
*/
|
*/
|
||||||
#include "ISharedData.h"
|
#include "ISharedData.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "SharedData.h"
|
||||||
#include "SharedDataImpl.h" // TODO: 互相包含,需要修改
|
#include "SharedDataImpl.h" // TODO: 互相包含,需要修改
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include <memory>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
void ISharedData::MakeSharedMemory(const unsigned int readableSize, const unsigned int writableSize)
|
void ISharedData::MakeSharedMemory(const unsigned int readableSize, const unsigned int writableSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "SharedData.h"
|
#include "SharedData.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include "ISharedData.h"
|
#include "ISharedData.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include <memory>
|
||||||
|
#include <stdlib.h>
|
||||||
static bool ObjectCheck(void *object)
|
static bool ObjectCheck(void *object)
|
||||||
{
|
{
|
||||||
if (nullptr == object) {
|
if (nullptr == object) {
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
*/
|
*/
|
||||||
#include "SharedDataCode.h"
|
#include "SharedDataCode.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "SharedData.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static const char *StatusCodeString[SHARED_DATA_CODE_END - STATUS_CODE_END + 1] = {
|
static const char *StatusCodeString[SHARED_DATA_CODE_END - STATUS_CODE_END + 1] = {
|
||||||
"SHARED_DATA_CODE_INIT_FAILED", "SHARED_DATA_CODE_WRONG_PEER_PARAMETERS", "SHARED_DATA_CODE_END"};
|
"SHARED_DATA_CODE_INIT_FAILED", "SHARED_DATA_CODE_WRONG_PEER_PARAMETERS", "SHARED_DATA_CODE_END"};
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
*/
|
*/
|
||||||
#include "SharedDataImpl.h"
|
#include "SharedDataImpl.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "SharedData.h"
|
||||||
#include "SharedDataCode.h"
|
#include "SharedDataCode.h"
|
||||||
|
#include "SharedMemory.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
static const char *SHARED_DATA_NAME = "shared_data";
|
|
||||||
constexpr short THERE_TWO_USER_DATA_HEADER = 2;
|
constexpr short THERE_TWO_USER_DATA_HEADER = 2;
|
||||||
SharedDataImpl::SharedDataImpl(const SHARER_NAME &sharerName, const char *path, const int &projectId)
|
SharedDataImpl::SharedDataImpl(const SHARER_NAME &sharerName, const char *path, const int &projectId)
|
||||||
: SharedMemory(path, projectId), mSharerName(sharerName)
|
: SharedMemory(path, projectId), mSharerName(sharerName)
|
||||||
|
|
|
@ -15,13 +15,16 @@
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include "LinuxApi.h"
|
#include "LinuxApi.h"
|
||||||
|
#include "SharedData.h"
|
||||||
#include "SharedDataCode.h"
|
#include "SharedDataCode.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
constexpr int SHMGET_FAILED = -1;
|
constexpr int SHMGET_FAILED = -1;
|
||||||
SharedMemory::SharedMemory(const char *path, const int &projectId) : mPath(path), mProjectId(projectId)
|
SharedMemory::SharedMemory(const char *path, const int &projectId) : mPath(path), mProjectId(projectId)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user