mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Improve:include cleaner.
This commit is contained in:
commit
d5ed510a20
32
README.md
32
README.md
|
@ -9,11 +9,33 @@
|
|||
* SDK工程所有开发文档均使用markdown语法编写,需要使用markdown语法解析器进行解析,方便阅读,如:Typora;开发工程师建议使用vscode安装markdownlint插件进行阅读;
|
||||
* SDK工程所有文档描述路径时,"//"双斜杠表示工程根目录;
|
||||
|
||||
## 1.2. 编译
|
||||
## 1.2. 开发环境准备
|
||||
|
||||
  工程的开发,需要预安装一些开发工具。例如:cmake的特定版本,llvm工具等。
|
||||
|
||||
### 1.2.1. cmake安装
|
||||
|
||||
  cmake是一个跨平台的安装(编译)工具,它是由Kitware公司开发的一个开源软件,可以用来配置、构建、编译一个工程。
|
||||
|
||||
```code
|
||||
# 项目根目录执行:
|
||||
$ make install-cmake
|
||||
```
|
||||
|
||||
### 1.2.2. llvm工具安装
|
||||
|
||||
  LLVM是一个编译器工具链,包含clang编译器、llvm核心库等。此处只用了clang-tidy和clang-format工具,一个负责编码规范,一个负责代码格式化。
|
||||
|
||||
```code
|
||||
# 项目根目录执行:
|
||||
$ make compile_llvm
|
||||
```
|
||||
|
||||
## 1.3. 编译
|
||||
|
||||
  架构设计上支持去平台编译和运行,本仓库源码可仿真运行在ubuntu系统。
|
||||
|
||||
### 1.2.1. Ubuntu系统
|
||||
### 1.3.1. Ubuntu系统
|
||||
|
||||
在项目根目录下执行命令:
|
||||
|
||||
|
@ -24,7 +46,7 @@ cd cmake-shell/ // 在中间文件目录进行编译,把所有中间文件
|
|||
make // 编译全部输出构建文件
|
||||
```
|
||||
|
||||
### 1.2.2. 交叉编译
|
||||
### 1.3.2. 交叉编译
|
||||
|
||||
参考:
|
||||
|
||||
|
@ -37,9 +59,9 @@ make // 编译全部输出构建文件
|
|||
|
||||
  交叉编译请参考基于IPC SDK作为子仓库的工程配置,此处忽略。
|
||||
|
||||
### 1.2.3. 小技巧
|
||||
### 1.3.3. 小技巧
|
||||
|
||||
#### 1.2.3.1. 代码阅读辅助工具(基于vscode)
|
||||
#### 1.3.3.1. 代码阅读辅助工具(基于vscode)
|
||||
|
||||
  为了方便代码跳转阅读,除了安装基本的c++插件外,结合cmake构建工具生成的compile_commands.json文件可实现代码之间的精准跳转。
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ include_directories(
|
|||
link_directories(
|
||||
${LIBS_OUTPUT_PATH}
|
||||
${EXTERNAL_LIBS_OUTPUT_PATH}
|
||||
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
|
||||
)
|
||||
|
||||
aux_source_directory(. SRC_FILES)
|
||||
|
|
|
@ -13,8 +13,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "AppMonitor.h"
|
||||
#include "IAppManager.h"
|
||||
#include "ILog.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "StatusCode.h"
|
||||
#include <vector>
|
||||
AppMonitor::AppMonitor() : mMicStatus(SwitchStatus::END)
|
||||
{
|
||||
}
|
||||
StatusCode AppMonitor::GetProductInfo(AppGetProductInfo ¶m)
|
||||
{
|
||||
LogInfo("AppMonitor::GetProductInfo.\n");
|
||||
|
@ -65,7 +71,7 @@ StatusCode AppMonitor::GetBatteryInfo(AppGetBatteryInfo ¶m)
|
|||
}
|
||||
StatusCode AppMonitor::GetParamValue(AppParamValue ¶m)
|
||||
{
|
||||
param.mMicStatus = SwitchStatus::ON;
|
||||
param.mMicStatus = mMicStatus;
|
||||
param.mRec = SwitchStatus::OFF;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
|
@ -114,16 +120,18 @@ StatusCode AppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::v
|
|||
}
|
||||
StatusCode AppMonitor::SetDateTime(const AppSetDateTime ¶m)
|
||||
{
|
||||
//
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::SetTimeZone(const unsigned int &zone)
|
||||
{
|
||||
//
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::SetParamValue(const AppSetParamValue ¶m)
|
||||
{
|
||||
LogInfo("SetParamValue: param = %s.\n", param.mName.c_str());
|
||||
if (param.mName == "mic") {
|
||||
mMicStatus = static_cast<SwitchStatus>(param.mValue);
|
||||
}
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::EnterRecorder(void)
|
||||
|
@ -136,7 +144,6 @@ StatusCode AppMonitor::AppPlayback(const PlayBackEvent &event)
|
|||
}
|
||||
StatusCode AppMonitor::UploadFile(AppUploadFile ¶m)
|
||||
{
|
||||
//
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::GetThumbnail(AppGetThumbnail ¶m)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
class AppMonitor : public VAppMonitor
|
||||
{
|
||||
public:
|
||||
AppMonitor() = default;
|
||||
AppMonitor();
|
||||
virtual ~AppMonitor() = default;
|
||||
StatusCode GetProductInfo(AppGetProductInfo ¶m) override;
|
||||
StatusCode GetDeviceAttr(AppGetDeviceAttr ¶m) override;
|
||||
|
@ -41,5 +41,8 @@ public:
|
|||
|
||||
private:
|
||||
SdCardStatus SdCardStatusConvert(const StorageEvent &event);
|
||||
|
||||
private:
|
||||
SwitchStatus mMicStatus; // TODO: improve delete.
|
||||
};
|
||||
#endif
|
|
@ -14,6 +14,13 @@
|
|||
*/
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "KeyControl.h"
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
const bool NOT_EXECUTED = false;
|
||||
const bool EXECUTED = true;
|
||||
key_event_data::key_event_data(const std::string &keyName, const KeyEvent &keyEvent, const unsigned int &holdTime)
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
*/
|
||||
#include "IMissionManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
std::shared_ptr<IMissionManager> &IMissionManager::GetInstance(std::shared_ptr<IMissionManager> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<IMissionManager>();
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "IdleState.h"
|
||||
#include "IFilesManager.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include "IStateMachine.h"
|
||||
IdleState::IdleState() : State("IdleState")
|
||||
{
|
||||
// mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&IdleState::MediaReportHandle, this, _1);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
*/
|
||||
#include "LedsHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "LedControl.h"
|
||||
#include "SetLedState.h"
|
||||
void LedsHandle::ControlDeviceStatusLed(const DeviceStatus &status, const long int &keepAliveTime,
|
||||
const unsigned int &blinkPeriod)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "McuMonitor.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include <memory>
|
||||
void McuMonitor::Init(std::shared_ptr<VMcuMonitor> &monitor)
|
||||
{
|
||||
IMcuManager::GetInstance()->SetMcuMonitor(monitor);
|
||||
|
|
|
@ -13,10 +13,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "MediaHandleState.h"
|
||||
#include "IFilesManager.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "MediaTaskHandle.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
MediaHandleState::MediaHandleState() : State("MediaHandleState")
|
||||
{
|
||||
mEventHandle[InternalStateEvent::RESET_KEY_MEDIA_TASK] =
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "MediaTask.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "IMediaManager.h"
|
||||
#include <memory>
|
||||
MediaTask::MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEvent,
|
||||
const std::weak_ptr<VMediaTaskIniator> &iniator)
|
||||
: mType(type), mBindEvent(bindEvent), mIniator(iniator)
|
||||
|
|
|
@ -13,8 +13,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "MediaTaskHandle.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "MediaTask.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
MediaTaskHandle::MediaTaskHandle()
|
||||
{
|
||||
mMediaHandle.reset();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "MissionManager.h"
|
||||
#include "IAppManager.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include "StatusCode.h"
|
||||
const StatusCode MissionManager::Init(void)
|
||||
{
|
||||
MissionStateMachine::GetInstance()->Init();
|
||||
|
|
|
@ -14,16 +14,21 @@
|
|||
*/
|
||||
#include "MissionManagerMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "IdleState.h"
|
||||
#include "MediaHandleState.h"
|
||||
#include "MissionManager.h"
|
||||
#include "OnMissionState.h"
|
||||
#include "PirTriggeredMissionState.h"
|
||||
#include "SdCardHandleState.h"
|
||||
#include "StatusCode.h"
|
||||
#include "StorageHandleState.h"
|
||||
#include "TestMissionState.h"
|
||||
#include "TopState.h"
|
||||
#include "UpgradeState.h"
|
||||
#include <memory>
|
||||
bool CreateMissionManagerModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IMissionManager>();
|
||||
|
|
|
@ -13,9 +13,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "MissionState.h"
|
||||
#include "IAppManager.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "LedsHandle.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include <functional>
|
||||
#include <string>
|
||||
MissionState::MissionState(const std::string &name) : State(name)
|
||||
{
|
||||
mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&MissionState::MediaReportHandle, this, _1);
|
||||
|
|
|
@ -15,8 +15,13 @@
|
|||
#include "MissionStateMachine.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "McuAskBase.h"
|
||||
#include "MissionManagerMakePtr.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
// #include "TopState.h"
|
||||
std::shared_ptr<MissionStateMachine> &MissionStateMachine::GetInstance(std::shared_ptr<MissionStateMachine> *impl)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
*/
|
||||
#include "OnMissionState.h"
|
||||
#include "ILog.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "MissionState.h"
|
||||
#include "MissionStateMachine.h"
|
||||
OnMissionState::OnMissionState() : MissionState("OnMissionState")
|
||||
{
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "PirTriggeredMissionState.h"
|
||||
#include "ILog.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "MissionState.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include "PirTriggeredMissionState.h"
|
||||
PirTriggeredMissionState::PirTriggeredMissionState() : MissionState("PirTriggeredMissionState")
|
||||
{
|
||||
// mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] =
|
||||
|
|
|
@ -13,10 +13,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "SdCardHandleState.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "IFilesManager.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include "StatusCode.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
using std::placeholders::_1;
|
||||
SdCardHandleState::SdCardHandleState() : State("SdCardHandleState"), mSdCardStatus(StorageEvent::END)
|
||||
{
|
||||
mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&SdCardHandleState::MediaReportHandle, this, _1);
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "SetLedState.h"
|
||||
#include "IDeviceManager.h"
|
||||
#include "LedControl.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
SetLedState::SetLedState(const LedState &state, const unsigned int &keepAliveTime, const unsigned int &blinkPeriod)
|
||||
: mState(state), mKeepAliveTime(keepAliveTime), mBlinkPeriod(blinkPeriod)
|
||||
{
|
||||
|
|
|
@ -13,9 +13,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "StorageHandleState.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
StorageHandleState::StorageHandleState() : State("StorageHandleState")
|
||||
{
|
||||
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
|
||||
|
|
|
@ -13,10 +13,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "TestMissionState.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "IAppManager.h"
|
||||
#include "ILog.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "LedsHandle.h"
|
||||
#include "MissionState.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
TestMissionState::TestMissionState() : MissionState("TestMissionState")
|
||||
{
|
||||
mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] =
|
||||
|
|
|
@ -13,10 +13,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "TopState.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "IDeviceManager.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "KeyControl.h"
|
||||
#include "McuMonitor.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include "StatusCode.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
TopState::TopState() : State("TopState")
|
||||
{
|
||||
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "UpgradeState.h"
|
||||
#include "DataProcessing.h"
|
||||
#include "IHuntingUpgrade.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "MissionStateMachine.h"
|
||||
#include <functional>
|
||||
UpgradeState::UpgradeState() : State("UpgradeState")
|
||||
{
|
||||
mEventHandle[InternalStateEvent::CHECK_UPGRADE_FILE] = std::bind(&UpgradeState::CheckUpgradeFileHandle, this, _1);
|
||||
|
|
|
@ -27,7 +27,7 @@ llvm-twine-local,\
|
|||
misc-confusable-identifiers,\
|
||||
misc-definitions-in-headers,\
|
||||
misc-header-include-cycle,\
|
||||
-misc-include-cleaner,\
|
||||
misc-include-cleaner,\
|
||||
misc-misleading-bidirectional,\
|
||||
misc-misleading-identifier,\
|
||||
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")
|
||||
set(CLANG_TIDY_SUPPORT "true")
|
||||
set(CLANG_FORMAT_SUPPORT "true")
|
||||
set(COMPILE_IMPROVE_SUPPORT "false") # 开启后每次编译可能会很慢
|
||||
set(COMPILE_IMPROVE_SUPPORT "true") # 开启后每次编译可能会很慢
|
||||
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
||||
endif()
|
||||
# ------------ build clang-tools end ------------ #
|
||||
|
|
42
doc/clang-tidy_user_guide.md
Normal file
42
doc/clang-tidy_user_guide.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# 1. clang-tidy使用指南
|
||||
|
||||
   使用clang-tidy工具进行代码规范管理。
|
||||
1. 编译时实时报错;
|
||||
2. 指定自研源码检测;
|
||||
|
||||
## 1.1. 环境搭建
|
||||
|
||||
1. llvm使用cmake编译,cmake版本要求 3.20以上,此处使用cmake-3.27.4
|
||||
```
|
||||
// cmake源码目录://tools/cmake/cmake-3.27.4.tar.gz
|
||||
// cmake源码安装:
|
||||
tar zxvf cmake-3.27.4.tar.gz
|
||||
cd cmake-3.27.4/
|
||||
sudo apt-get install openssl // 如果执行./bootstrap提示缺少ssl相关资源,执行此安装命令
|
||||
./bootstrap
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
2. 安装llvm
|
||||
```
|
||||
// 下载源码
|
||||
git clone https://github.com/llvm/llvm-project.git
|
||||
cd llvm-project/
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ../llvm
|
||||
make -j8
|
||||
find ./ -name clang-tidy // 确认编译完成
|
||||
```
|
||||
|
||||
## 1.2. clang-tidy使用
|
||||
修改配置:< IPC-SDK >/build/global_config.cmake
|
||||
```
|
||||
# ------------ build clang-tools ------------ #
|
||||
if(${LINUX_TEST} MATCHES "true")
|
||||
set(CLANG_TIDY_SUPPORT "true") // 使能工具
|
||||
set(CLANG_FORMAT_SUPPORT "true")
|
||||
set(LLVM_PATH "/home/xiaojiazhu/project/tmp/llvm-project") // llvm安装目录
|
||||
endif()
|
||||
# ------------ build clang-tools end ------------ #
|
||||
```
|
54
doc/cmake_exploitReport.md
Normal file
54
doc/cmake_exploitReport.md
Normal file
|
@ -0,0 +1,54 @@
|
|||
# 1.cmake开发报告
|
||||
|
||||
## 1.1 前言
|
||||
该篇md用于ipc项目下log功能的cmakelist的开发报告,以阐述其功能和组成。
|
||||
|
||||
## 1.2 功能介绍
|
||||
* 设置库文件输出路径:`set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})`.
|
||||
该语句用于设置该功能的静态库的生成路径,其中`${LIBS_OUTPUT_PATH}`在/build/cmake/global_config.cmake被定义在项目根目录的/output_files/libs/。
|
||||
|
||||
* 添加实现功能的文件目录:`include_directories(./)`.
|
||||
该语句旨在向编译器告知该功能的实现文件和头文件的所在位置。
|
||||
|
||||
* 添加功能目录到搜索路径:`set(CMAKE_AUTOMOC ON);set(CMAKE_INCLUDE_CURRENT_DIR ON)`
|
||||
这些 CMake 命令支持自动处理 Qt moc(元对象编译器),并将当前目录设置为包含在包含文件的搜索路径中;在构建过程中自动运行Qt moc编译器,用于包含Q_OBJECT宏的任何源文件。这对于为信号和插槽生成必要的C++代码是必需的;该选项将当前源目录添加到包含文件的搜索路径中。这允许构建系统查找与正在编译的源文件位于同一目录中的头文件。
|
||||
|
||||
* 收集、生成头文件列表:`file(GLOB_RECURSE HEADER_FILES "*.h")`
|
||||
该语句的功能是搜索当前目录及其子目录中扩展名为 .h 的所有文件。生成的文件列表存储在 HEADER_FILES 变量中。
|
||||
|
||||
* 收集源文件列表:`aux_source_directory(. SRC_FILES)`
|
||||
在本语句中,aux_source_directory(.SRC_FILES) 从当前目录(由 .) 及其子目录中收集所有源文件(例如,.cpp 个文件),生成的文件列表存储在 SRC_FILES 变量中。
|
||||
|
||||
* 添加编译器标志和定义到当前目录及其子目录:`add_definitions("-fexceptions")`
|
||||
添加编译器标志`-fexceptions`以在代码中启用异常处理。此标志告诉编译器生成支持捕获和引发异常的代码。通过使用 add_definitions(),可以将特定的编译器标志或定义全局应用于项目或特定源文件。
|
||||
|
||||
* 创建静态库目标:`add_library(xlog STATIC ${SRC_FILES} ${HEADER_FILES})`
|
||||
在这种情况下,本语句使用提供的源文件和头文件列表创建一个名为“xlog”的静态库目标;`STATIC`关键字指定库将构建为静态库,这意味着库代码将在编译时直接链接到最终可执行文件中;`${SRC_FILES}`变量包含应编译并链接到库中的源文件(通常.cpp文件)的列表。${HEADER_FILES} 变量包含头文件(通常为 .h 文件)的列表,这些文件定义库使用的接口和声明。
|
||||
|
||||
## 1.3 总结
|
||||
该篇cmakelists.txt的主要用途是对ipc项目下xlog功能的显现文件的编译和汇总。
|
||||
|
||||
## 2.1 返回码管理库概述
|
||||
提供整个应用程序的返回码管理功能,例如:打印返回码的字符串含义。提供C语言接口,内部实现不限于C或者C++,形成项目内部唯一返回码标准。
|
||||
|
||||
## 2.2 功能介绍
|
||||
* 设置可执行文件的输出路径:`set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})`;`set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})`
|
||||
|
||||
* 引入头文件目录:`include_directories`。`include_directories`表示引入头文件搜索路径,当工程要用到某个头文件的时候,就会去该路径下搜索。
|
||||
|
||||
* 开启自动编译:`set(CMAKE_AUTOMOC ON)` `set(CMAKE_INCLUDE_CURRENT_DIR ON)`. 这段代码开启了 CMake 的元对象编译器、界面编译器和资源编译器自动编译,这样当项目使用了包含元对象的文件、界面文件和资源文件时 CMake 可以自动检测并编译。
|
||||
|
||||
* 查找在./src路径下的所有源文件:`aux_source_directory(./src SRC_FILES)` 。
|
||||
|
||||
* 设置ReturnCode地址:`set(TARGET_NAME ReturnCode)`。根据提供的源文件创建一个叫ReturnCode的静态库。然后将目标文件与库文件进行链接:`target_link_libraries(${TARGET_NAME} Log)`。
|
||||
|
||||
## 2.3 返回码test
|
||||
* 添加test文件到目录,本目录为测试代码目录,目录结构保持与源码目录结构一致。
|
||||
|
||||
* 在test各个文件夹里添加相对应的CMakeLists.txt文件,通过`add_subdirectory(utils)`添加与源码目录结构相对应的子文件夹。
|
||||
|
||||
* 在src文件夹下创建ReturnCodeTest.cpp,调用返回码管理接口。在根目录添加第三方库文件,存放需要用到的第三方库。
|
||||
|
||||
## 2.4 总结
|
||||
Cmake的语句都在CMakeLists.txt的文件中,Cmake运行之后就会产生想要的makefile文件,然后再直接make就可以编译出可执行程序。
|
||||
|
299
doc/cmake_guide.md
Normal file
299
doc/cmake_guide.md
Normal file
|
@ -0,0 +1,299 @@
|
|||
# 1. CMake构建工具使用
|
||||
|
||||
  SDK使用CMake工具构建。
|
||||
|
||||
## 1.1. 安装
|
||||
|
||||
```code
|
||||
详见://tools/cmake/Makefile
|
||||
$ cd tools/cmake
|
||||
$ make
|
||||
$ cmake --version
|
||||
cmake version 3.27.4
|
||||
```
|
||||
|
||||
## 1.2. SDK构建配置脚本
|
||||
|
||||
* build目录下是基本的配置脚本。
|
||||
|
||||
```code
|
||||
build/
|
||||
├── cmake
|
||||
│ ├── Makefile // 调用cmake命令生成Makefile文件;
|
||||
│ └── toolchain
|
||||
│ └── linux.toolchain.cmake // 工具链配置文件已经一些全局变量;
|
||||
├── global_config.cmake // 配置文件
|
||||
└── sdk_config.cmake // 配置文件
|
||||
```
|
||||
|
||||
### 1.2.1. //build/cmake/Makefile
|
||||
|
||||
  调用cmake命令生成Makefile文件。
|
||||
|
||||
```code
|
||||
all:
|
||||
@mkdir -p ../../cmake-shell;\ // 创建cmake输出目录,这一步很关键,所有cmake的中间文件都将会存放在此目录。
|
||||
cd ../../cmake-shell;\
|
||||
pwd;\
|
||||
# 调用cmake命令,并指定工具链配置文件,生成Makefile文件。
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="./build/cmake/toolchain/linux.toolchain.cmake" ..;\
|
||||
cd ..
|
||||
clean:
|
||||
rm -rf ../../cmake-shell
|
||||
```
|
||||
|
||||
在根目录执行:make cmake 的时候,即是调用上述Makefile生成Makefile文件。
|
||||
|
||||
### 1.2.2. //build/cmake/toolchain/linux.toolchain.cmake
|
||||
|
||||
  工具链配置文件或者一些跨平台差异化的配置文件。该文件在//build/cmake/Makefile中被指定,当需要交叉编译时,此文件的变量需要被重新配置。
|
||||
|
||||
```code
|
||||
|
||||
INCLUDE(CMakeForceCompiler)
|
||||
|
||||
set(LINUX_TEST "true")
|
||||
set(CROSS_COMPILE_PREFIX "") // 工具链前缀
|
||||
set(CMAKE_C_COMPILER "${CROSS_COMPILE_PREFIX}gcc") // 配置工具链
|
||||
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE_PREFIX}g++") // 配置工具链
|
||||
|
||||
# path to compiler and utilities
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
# Name of the target platform
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
# Version of the system
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
cmake_policy(SET CMP0005 NEW)
|
||||
|
||||
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") // 编译系统平台,Linux表示在PC的ubuntu系统上编译
|
||||
set(SUBMODULE_PATH_OF_IPC_SDK "") // 子仓库路面,此处为空,交叉编译时设置
|
||||
set(PLATFORM_PATH "${CMAKE_CURRENT_SOURCE_DIR}") // 平台路径
|
||||
set(TEST_COVERAGE "true") // 覆盖率报告开关
|
||||
add_definitions(-DPLATFORM_PATH=\"${PLATFORM_PATH}\") // 定义一个宏
|
||||
set(PROJECT_OUTPUT_FOLDER "output_files") // 编译的目标文件输出目录
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_OUTPUT_FOLDER}")
|
||||
|
||||
... // 此处省略不同模块的配置参数,一般是一些宏定义;
|
||||
```
|
||||
|
||||
### 1.2.3. //CMakeLists.txt
|
||||
|
||||
  SDK跟目录下的第一个CMakeLists.txt文件,cmake命令执行的时候会指定根目录,到此目录下寻找CMakeLists.txt文件作为整个项目的构建起点。
|
||||
|
||||
## 1.3. 重要的配置
|
||||
|
||||
### 1.3.1. 目录设置
|
||||
|
||||
  目录结构都是通过.cmake脚本来配置的。
|
||||
|
||||
#### 1.3.1.1. 源码目录结构配置
|
||||
|
||||
详见://build/global_config.cmake
|
||||
|
||||
```code
|
||||
set(EXEC_OUTPUT_PATH "${PLATFORM_PATH}/${PROJECT_OUTPUT_FOLDER}/bin")
|
||||
set(LIBS_OUTPUT_PATH "${PLATFORM_PATH}/${PROJECT_OUTPUT_FOLDER}/libs")
|
||||
set(TEST_TOOLS_OUTPUT_PATH "${PLATFORM_PATH}/${PROJECT_OUTPUT_FOLDER}/libs/test_tools")
|
||||
set(EXTERNAL_LIBS_OUTPUT_PATH "${PLATFORM_PATH}/${PROJECT_OUTPUT_FOLDER}/libs/external")
|
||||
set(TEST_OUTPUT_PATH "${PLATFORM_PATH}/${PROJECT_OUTPUT_FOLDER}/test")
|
||||
|
||||
set(PROJECT_ROOT_PATH "${PLATFORM_PATH}")
|
||||
set(APPLICATION_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/application") # 应用层目录
|
||||
set(MIDDLEWARE_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/middleware") # 中间件层目录
|
||||
set(UTILS_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/utils") # 工具层目录
|
||||
set(HAL_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/hal") # 硬件抽象层目录
|
||||
set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/test") # 自动化测试代码/example目录
|
||||
set(EXTERNAL_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/external") # 外部依赖库目录
|
||||
```
|
||||
|
||||
## 1.4. CMakeLists.txt基本语法
|
||||
|
||||
### 1.4.1. 概述
|
||||
|
||||
  概括性描述就是,只需要告诉CMakeLists.txt文件,构建时包含哪些配置文件,依赖的头文件目录,需要编译的源码文件,依赖的目标目录(如有),输出的目标,依赖的目标(一般是库),CMakeLists.txt即可生成一个Makefile代码来构建这个目标。
|
||||
|
||||
  整个SDK由很多的CMakeLists.txt文件组成,绝大多数的CMakeLists.txt文件负责把该目录的源码编译成一个库,SDK通过链接不同功能的库来构建不同的应用程序。
|
||||
|
||||
```code
|
||||
./application/CMakeLists.txt
|
||||
./application/HuntingCamera/CMakeLists.txt
|
||||
./CMakeLists.txt
|
||||
./hal/CMakeLists.txt
|
||||
./middleware/AppManager/CMakeLists.txt
|
||||
./middleware/CMakeLists.txt
|
||||
./test/all/CMakeLists.txt
|
||||
./test/application/CMakeLists.txt
|
||||
./test/application/HuntingCamera/CMakeLists.txt
|
||||
./test/application/MissionManager/CMakeLists.txt
|
||||
./test/application/MissionManager/tool/CMakeLists.txt
|
||||
./test/application/VersionReleaseTool/CMakeLists.txt
|
||||
./test/CMakeLists.txt
|
||||
./test/hal/CMakeLists.txt
|
||||
./test/hal/tool/CMakeLists.txt
|
||||
./test/middleware/AppManager/CMakeLists.txt
|
||||
./tools/clang-tidy/CMakeLists.txt
|
||||
./utils/CMakeLists.txt
|
||||
./utils/Config/CMakeLists.txt
|
||||
./utils/ConfigBase/CMakeLists.txt
|
||||
```
|
||||
|
||||
### 1.4.2. 一个CMakeLists.txt示例
|
||||
|
||||
  CMakeLists.txt可以通过调用一些shell脚本来完成除编译之外的其它工具,例如:格式化代码。
|
||||
|
||||
```code
|
||||
|
||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH}) // 设置可执行文件的输出目录
|
||||
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) // 设置库文件的输出目录
|
||||
|
||||
include_directories( // 该目标需要依赖的头文件的目录
|
||||
./src
|
||||
./include
|
||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
)
|
||||
|
||||
#do not rely on any other library
|
||||
#link_directories( // 该目标需要链接依赖的库的目录,因为是目标是库,无需链接,此设置无
|
||||
#)
|
||||
|
||||
aux_source_directory(./src SRC_FILES) // 需要编译的源码文件,此处是src目录下的所有文件
|
||||
|
||||
set(TARGET_NAME StatusCode) // 设置输出目标名称
|
||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||
target_link_libraries(${TARGET_NAME} Log) // 该目标需要依赖的库,这一步很关键,cmake将会根据依赖关系自动去编译需要的依赖库;
|
||||
|
||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||
add_custom_target( // 静态检测代码
|
||||
StatusCode_code_check
|
||||
COMMAND ${CLANG_TIDY_EXE}
|
||||
-checks='${CLANG_TIDY_CHECKS}'
|
||||
--header-filter=.*
|
||||
--system-headers=false
|
||||
${SRC_FILES}
|
||||
${CLANG_TIDY_CONFIG}
|
||||
-p ${PLATFORM_PATH}/cmake-shell
|
||||
WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/StatusCode
|
||||
)
|
||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||
add_custom_target( // 格式化代码
|
||||
StatusCode_code_format
|
||||
COMMAND ${CLANG_FORMAT_EXE}
|
||||
-style=file
|
||||
-i ${SRC_FILES} ${HEADER_FILES}
|
||||
WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/StatusCode
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
PRE_BUILD
|
||||
COMMAND make StatusCode_code_check
|
||||
COMMAND make StatusCode_code_format
|
||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||
)
|
||||
endif()
|
||||
|
||||
define_file_name(${TARGET_NAME}) // 该函数实现log库打印时,可打印文件名
|
||||
|
||||
file(GLOB_RECURSE INSTALL_HEADER_FILES include/*.h)
|
||||
install(FILES ${INSTALL_HEADER_FILES} DESTINATION include) // 拷贝头文件到安装目录
|
||||
```
|
||||
|
||||
### 1.4.3. 通过CMakeLists.txt构建开源库
|
||||
|
||||
  通过CMakeLists.txt构建开源库,可以自动关联第三方的依赖库,编译的时候自动按需编译对应的开源库。
|
||||
|
||||
```code
|
||||
|
||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
||||
include(build/config_base.cmake)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})
|
||||
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
|
||||
|
||||
include_directories(
|
||||
./src
|
||||
./include
|
||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib
|
||||
)
|
||||
# link_directories(
|
||||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||
# )
|
||||
|
||||
aux_source_directory(./src SRC_FILES)
|
||||
|
||||
set(TARGET_NAME ConfigBase)
|
||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||
target_link_libraries(${TARGET_NAME} StatusCode Log libconfig.a)
|
||||
|
||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||
add_custom_target(
|
||||
ConfigBase_code_check
|
||||
COMMAND ${CLANG_TIDY_EXE}
|
||||
-checks='${CLANG_TIDY_CHECKS}'
|
||||
--header-filter=.*
|
||||
--system-headers=false
|
||||
${SRC_FILES}
|
||||
${CLANG_TIDY_CONFIG}
|
||||
-p ${PLATFORM_PATH}/cmake-shell
|
||||
WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/ConfigBase
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
PRE_BUILD
|
||||
COMMAND make ConfigBase_code_check
|
||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||
)
|
||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
||||
add_custom_target(
|
||||
ConfigBase_code_format
|
||||
COMMAND ${CLANG_FORMAT_EXE}
|
||||
-style=file
|
||||
-i ${SRC_FILES} ${HEADER_FILES}
|
||||
WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/ConfigBase
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
PRE_BUILD
|
||||
COMMAND make ConfigBase_code_check
|
||||
COMMAND make ConfigBase_code_format
|
||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
||||
)
|
||||
endif()
|
||||
|
||||
# build libconfig before make libConfigBase.a
|
||||
add_custom_command(
|
||||
# OUTPUT ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a
|
||||
OUTPUT ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a // 创建这个开源库输出文件的生成方法
|
||||
COMMAND echo "Build libconfig-1.7.3. COMPILE_HOST = ${COMPILE_HOST}"
|
||||
# COMMAND tar zxvf libconfig-1.7.3.tar.gz
|
||||
COMMAND sh build_libconfig.sh ${TARGET_PLATFORM} ${COMPILE_HOST}
|
||||
# 把生成的开源库拷贝到输出目录
|
||||
COMMAND mv ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a
|
||||
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
|
||||
)
|
||||
add_custom_target(
|
||||
libconfig.a // 创建一个库目标
|
||||
# DEPENDS ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs/libconfig.a
|
||||
DEPENDS ${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig.a // 这个目标依赖开源库的编译输出文件
|
||||
)
|
||||
|
||||
define_file_name(${TARGET_NAME})
|
||||
config_owner(${TARGET_NAME})
|
||||
|
||||
file(GLOB_RECURSE INSTALL_HEADER_FILES include/*.h)
|
||||
install(FILES ${INSTALL_HEADER_FILES} DESTINATION include)
|
||||
```
|
1103
doc/design.md
Normal file
1103
doc/design.md
Normal file
File diff suppressed because it is too large
Load Diff
111
doc/develop_standard.md
Normal file
111
doc/develop_standard.md
Normal file
|
@ -0,0 +1,111 @@
|
|||
# 1. SDK开发规范
|
||||
|
||||
## 1.1. 编码规范
|
||||
|
||||
### 1.1.1. 指针/智能指针
|
||||
|
||||
* C++编码只能使用智能指针;
|
||||
* 指针遵循谁使用谁进行“非空”判断,且无比使用前进行“非空”判断;
|
||||
* 智能指针经过转换后务必进行“非空”判断;
|
||||
|
||||
理论上,**明显不可能为空的指针,可以不进行“非空”判断**,可以不进行“非空”判断的场景:
|
||||
|
||||
```
|
||||
void McuManagerImpl::OtherSideSendIpcMission(const unsigned int &serialNumber, const unsigned char &mission)
|
||||
{
|
||||
class McuRecvIpcMission : public McuRecvImpl, public McuRecv<unsigned char>
|
||||
{
|
||||
public:
|
||||
McuRecvIpcMission(std::shared_ptr<McuManagerImpl> &mcuManager, const unsigned int &serialNumber,
|
||||
const OtherSideSendType &sendType, const unsigned char &mission)
|
||||
: McuRecvImpl(serialNumber, sendType)
|
||||
{
|
||||
McuRecv::mDataRecvReply = mission;
|
||||
McuRecvImpl::mMcuManager = mcuManager;
|
||||
}
|
||||
~McuRecvIpcMission() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
// 此处可以不进行“非空”判断,该值在有限范围内(OtherSideSendIpcMission函数内部)就能看出是否为空
|
||||
McuRecvImpl::mMcuManager->ReplyOtherSideSendIpcMission(ASK_RESULT::SUCCEED, McuRecvImpl::mSerialNumber);
|
||||
}
|
||||
};
|
||||
std::shared_ptr<VMcuMonitor> monitor = GetMcuMonitor();
|
||||
std::shared_ptr<McuManagerImpl> manager = std::dynamic_pointer_cast<McuManagerImpl>(SharedFromThis());
|
||||
std::shared_ptr<VMcuRecv> recv =
|
||||
std::make_shared<McuRecvIpcMission>(manager, serialNumber, OtherSideSendType::SEND_IPC_MISSION, mission);
|
||||
if (monitor) {
|
||||
monitor->RecvIpcMissionEvent(recv, static_cast<IpcMission>(mission));
|
||||
}
|
||||
else {
|
||||
LogWarning("mMonitor is nullptr, AddMcuRecv.\n");
|
||||
AddMcuRecv(recv);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**没有进行“非空”判断的代码,应该开发测试用例,保证“空指针”的报错。**
|
||||
|
||||
### 1.1.2. 注释
|
||||
|
||||
* 注释必须使用英文,且使用翻译器翻译;
|
||||
  避免编码问题导致的乱码,且需要保证阅读困难时可使用翻译器翻译成可读的中文;
|
||||
|
||||
**注:** 注释翻译工具使用[百度翻译](https://fanyi.baidu.com/);翻译的注释在使用doxygen工具生成接口文档时,在网页上方便翻译成中文。
|
||||
|
||||
### 1.1.3. C++继承
|
||||
|
||||
* 子类使用父类的函数时,函数前必须加父类名,降低阅读难度,没有父类名的一律为本类函数(有可能是虚函数);
|
||||
|
||||
### 1.1.4. 变量命名
|
||||
|
||||
#### 1.1.4.1. 结构体/类成员
|
||||
|
||||
* 结构体和类成员必须要使用驼峰命名法,且首字母必须为m表示成员变量;
|
||||
|
||||
```
|
||||
typedef struct app_get_product_info
|
||||
{
|
||||
app_get_product_info();
|
||||
std::string mModel;
|
||||
std::string mCompany;
|
||||
std::string mSoc;
|
||||
std::string mSp;
|
||||
} AppGetProductInfo;
|
||||
```
|
||||
|
||||
### 1.1.5. 文件命名
|
||||
|
||||
* 文件名必须使用驼峰命名法,且首字母大写;
|
||||
|
||||
### 1.1.6. 代码排版
|
||||
|
||||
* 使用统一标准的代码排版风格,保持多人开发时代码的整洁,避免因为排版(特别是编辑工具的自动排版功能)导致每次提交时都产生大量的排版修改,影响后续代码异常排查;
|
||||
|
||||
  请使用仓库跟目录下.clang-format配置文件进行排版,如果使用vscode编辑器开发代码,可直接使用快捷键ctrl+alt+f进行排版;也可以使用构建脚本对代码进行排版。
|
||||
|
||||
**对发生修改的代码进行格式化:**
|
||||
|
||||
```code
|
||||
$ make cmake // 在仓库根目录执行,对发生修改的文件创建格式化命令
|
||||
$ cd cmake-shell/
|
||||
$ make improve_modified_code // 文件格式化命令,统一排版,此命名只对发生修改的文件进行格式化
|
||||
```
|
||||
|
||||
**对全部文件进行格式化:**
|
||||
|
||||
```code
|
||||
详见配置文件://build/global_config.cmake
|
||||
把 COMPILE_IMPROVE_SUPPORT 设置为 true 时,将会在每次编译代码时进行格式化。
|
||||
if(${LINUX_TEST} MATCHES "true")
|
||||
set(CLANG_TIDY_SUPPORT "true")
|
||||
set(CLANG_FORMAT_SUPPORT "true")
|
||||
set(COMPILE_IMPROVE_SUPPORT "false") # 开启后每次编译可能会很慢
|
||||
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
||||
endif()
|
||||
```
|
||||
|
||||
### 1.1.7. 函数
|
||||
|
||||
* 单个函数代码行控制在50行内,阅读时无需上下滚动去理解代码逻辑;极少数初始化数据的无逻辑推理的代码除外;
|
||||
* 函数参数不能超过10个;
|
21
doc/doxygen_user_guide.md
Normal file
21
doc/doxygen_user_guide.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
# 1. Linux嵌入式项目使用Doxygen生成API文档
|
||||
|
||||
## 1.1. Doxygen简介
|
||||
|
||||
  Doxygen是一个开源的文档生成工具,可以用来生成项目源代码的API文档。
|
||||
|
||||
## 1.2. Doxygen安装
|
||||
|
||||
  Doxygen安装非常简单,直接在官网下载最新版本即可。
|
||||
|
||||
```
|
||||
$ sudo apt-get install doxygen
|
||||
```
|
||||
|
||||
## 1.3. 安装Graphviz
|
||||
|
||||
  Doxygen本身不直接支持画图功能,但它可以生成DOT格式的图形描述文件,然后使用Graphviz工具进行渲染。
|
||||
|
||||
```
|
||||
$ sudo apt-get install graphviz
|
||||
```
|
209
doc/gdb_coredump_guide.md
Normal file
209
doc/gdb_coredump_guide.md
Normal file
|
@ -0,0 +1,209 @@
|
|||
# 1. gdb coredump分析
|
||||
|
||||
  本文介绍ubuntu系统环境下coredump文件的分析方法。
|
||||
|
||||
**一个coredump示例:**
|
||||
|
||||
```
|
||||
$ ../output_files/test/bin/McuManagerTest --gtest_filter=McuManagerTest.RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission
|
||||
Note: Google Test filter = McuManagerTest.RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission
|
||||
[==========] Running 1 test from 1 test suite.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 1 test from McuManagerTest
|
||||
NewLog succeed.
|
||||
LogImplInit
|
||||
[ RUN ] McuManagerTest.RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission
|
||||
2024-05-15 17:43:04,782 INFO [default] [McuManagerMakePtr.cpp:23]:CreateMcuManager is ok.
|
||||
|
||||
2024-05-15 17:43:04,783 INFO [default] [IMcuManager.cpp:72]:Instance changed succeed.
|
||||
|
||||
2024-05-15 17:43:04,783 INFO [default] [UartDeviceImpl.cpp:277]:Create the uart device object.
|
||||
|
||||
Can't Open Serial Port: No such file or directory
|
||||
2024-05-15 17:43:04,784 ERROR [default] [McuDevice.cpp:51]:IUartOpen failed.
|
||||
|
||||
2024-05-15 17:43:04,787 INFO [default] [UartDeviceImpl.cpp:277]:Create the uart device object.
|
||||
|
||||
Can't Open Serial Port: No such file or directory
|
||||
2024-05-15 17:43:04,787 ERROR [default] [McuDevice.cpp:51]:IUartOpen failed.
|
||||
|
||||
terminate called without an active exception
|
||||
Aborted (core dumped)
|
||||
```
|
||||
|
||||
## 1.1. coredump文件生成路径查询
|
||||
|
||||
```
|
||||
$ cat /proc/sys/kernel/core_pattern
|
||||
|/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E
|
||||
```
|
||||
|
||||
修改coredump文件生成路径:
|
||||
|
||||
```
|
||||
$ sudo sh -c 'echo /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p > /proc/sys/kernel/core_pattern'
|
||||
$ cat /proc/sys/kernel/core_pattern
|
||||
/home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p
|
||||
```
|
||||
命令:
|
||||
sudo sh -c 'echo /path/core.%e.%p > /proc/sys/kernel/core_pattern'
|
||||
|
||||
例如:
|
||||
```
|
||||
sudo sh -c 'echo /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p > /proc/sys/kernel/core_pattern'
|
||||
```
|
||||
|
||||
**发现路径下并未生成coredump文件**
|
||||
|
||||
```
|
||||
$ ulimit -a
|
||||
core file size (blocks, -c) 0 // 0表示终端未开启core dump
|
||||
data seg size (kbytes, -d) unlimited
|
||||
scheduling priority (-e) 0
|
||||
file size (blocks, -f) unlimited
|
||||
pending signals (-i) 63499
|
||||
max locked memory (kbytes, -l) 65536
|
||||
max memory size (kbytes, -m) unlimited
|
||||
open files (-n) 1024
|
||||
pipe size (512 bytes, -p) 8
|
||||
POSIX message queues (bytes, -q) 819200
|
||||
real-time priority (-r) 0
|
||||
stack size (kbytes, -s) 8192
|
||||
cpu time (seconds, -t) unlimited
|
||||
max user processes (-u) 63499
|
||||
virtual memory (kbytes, -v) unlimited
|
||||
file locks (-x) unlimited
|
||||
```
|
||||
|
||||
解决:
|
||||
```
|
||||
$ ulimit -c unlimited
|
||||
```
|
||||
|
||||
sudo echo /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p > /proc/sys/kernel/core_pattern
|
||||
|
||||
## 1.2. gdb查看堆栈信息
|
||||
|
||||
**Ubuntu系统需要加sudo执行程序才会生成coredump文件。**
|
||||
|
||||
### 1.2.1. 无法识别coredump文件
|
||||
|
||||
  在gdb中无法识别coredump文件,如下所示:
|
||||
|
||||
```
|
||||
$ sudo gdb ../output_files/test/bin/McuManagerTest core.smbd.3390383
|
||||
[sudo] password for xiaojiazhu:
|
||||
Sorry, try again.
|
||||
[sudo] password for xiaojiazhu:
|
||||
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
Type "show copying" and "show warranty" for details.
|
||||
This GDB was configured as "x86_64-linux-gnu".
|
||||
Type "show configuration" for configuration details.
|
||||
For bug reporting instructions, please see:
|
||||
<http://www.gnu.org/software/gdb/bugs/>.
|
||||
Find the GDB manual and other documentation resources online at:
|
||||
<http://www.gnu.org/software/gdb/documentation/>.
|
||||
|
||||
For help, type "help".
|
||||
Type "apropos word" to search for commands related to "word"...
|
||||
Reading symbols from ../output_files/test/bin/McuManagerTest...
|
||||
|
||||
warning: core file may not match specified executable file. // 表示coredump文件与可执行文件不匹配
|
||||
[New LWP 3390383]
|
||||
Core was generated by `/usr/sbin/smbd --foreground --no-process-group'.
|
||||
Program terminated with signal SIGABRT, Aborted.
|
||||
#0 0x00007fd59718600b in ?? ()
|
||||
(gdb) bt
|
||||
#0 0x00007fd59718600b in ?? ()
|
||||
#1 0x0000000000001c80 in ?? ()
|
||||
#2 0x0000000000000000 in ?? ()
|
||||
```
|
||||
|
||||
由于gdb和asan同时启用会冲突,导致无法识别coredump文件。解决办法如下:
|
||||
|
||||
修改://build/sdk_config.cmake
|
||||
|
||||
```
|
||||
# Gdb debug
|
||||
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
||||
message("---------------------------Debug mode.-----------------------")
|
||||
SET(CMAKE_BUILD_TYPE "Debug")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -g -ggdb")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -Wall -g -ggdb")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
|
||||
# asan
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=leak -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined")
|
||||
else()
|
||||
message("---------------------------Release mode.-----------------------")
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os")
|
||||
endif()
|
||||
```
|
||||
|
||||
解决后:
|
||||
|
||||
```
|
||||
$ sudo gdb ../output_files/test/bin/McuManagerTest core.McuManagerTest.3406751
|
||||
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
Type "show copying" and "show warranty" for details.
|
||||
This GDB was configured as "x86_64-linux-gnu".
|
||||
Type "show configuration" for configuration details.
|
||||
For bug reporting instructions, please see:
|
||||
<http://www.gnu.org/software/gdb/bugs/>.
|
||||
Find the GDB manual and other documentation resources online at:
|
||||
<http://www.gnu.org/software/gdb/documentation/>.
|
||||
|
||||
For help, type "help".
|
||||
Type "apropos word" to search for commands related to "word"...
|
||||
Reading symbols from ../output_files/test/bin/McuManagerTest...
|
||||
[New LWP 3406751]
|
||||
[New LWP 3406753]
|
||||
[New LWP 3406752]
|
||||
[Thread debugging using libthread_db enabled]
|
||||
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
|
||||
Core was generated by `../output_files/test/bin/McuManagerTest --gtest_filter=McuManagerTest.RH_INTEGR'.
|
||||
Program terminated with signal SIGABRT, Aborted.
|
||||
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
|
||||
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
|
||||
[Current thread is 1 (Thread 0x7fd355968740 (LWP 3406751))]
|
||||
(gdb) bt
|
||||
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
|
||||
#1 0x00007fd35598f859 in __GI_abort () at abort.c:79
|
||||
#2 0x00007fd355d678d1 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
|
||||
#3 0x00007fd355d7337c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
|
||||
#4 0x00007fd355d733e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
|
||||
#5 0x000055c247b3ae41 in std::thread::operator= (__t=..., this=0x55c248d19748) at /usr/include/c++/9/thread:152
|
||||
#6 McuProtocol::Init (this=this@entry=0x55c248d196f8) at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/src/McuProtocol.cpp:58
|
||||
#7 0x000055c247b03e57 in McuManagerImpl::Init (this=0x55c248d19680)
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/middleware/McuManager/src/McuManagerImpl.cpp:46
|
||||
#8 0x000055c247acd3d4 in McuManagerTest::McuManagerTest_RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission_Test::TestBody (this=<optimized out>)
|
||||
at /usr/include/c++/9/bits/shared_ptr_base.h:1020
|
||||
#9 0x000055c247b303fd in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) () at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#10 0x000055c247b23343 in testing::Test::Run() () at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#11 0x000055c247b2342b in testing::TestInfo::Run() ()
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#12 0x000055c247b2376e in testing::TestSuite::Run() ()
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#13 0x000055c247b2a0fa in testing::internal::UnitTestImpl::RunAllTests() ()
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#14 0x000055c247b3085e in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ()
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#15 0x000055c247b23529 in testing::UnitTest::Run() ()
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
||||
#16 0x000055c247ac9287 in RUN_ALL_TESTS ()
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/external/gtest/googletest-release-1.11.0/googletest/include/gtest/gtest.h:2490
|
||||
#17 main (argc=<optimized out>, argv=<optimized out>)
|
||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/test/middleware/McuManager/mainTest.cpp:22
|
||||
(gdb)
|
||||
```
|
239
doc/git_guide.md
Normal file
239
doc/git_guide.md
Normal file
|
@ -0,0 +1,239 @@
|
|||
# 1. git使用手册
|
||||
|
||||
## 1.1. 概述
|
||||
|
||||
  git是分布式版本控制系统,在多人开发中,git可以很好的管理代码的版本。
|
||||
|
||||
## 1.2. 源码托管服务器
|
||||
|
||||
  github和gitlab还有gitee(国产)都是开源的代码托管服务器,可以用来管理源码。
|
||||
|
||||
## 1.3. git安装
|
||||
|
||||
## 1.4. git分支管理
|
||||
|
||||
### 1.4.1. git创建本地分支
|
||||
|
||||
* 基于远端分支创建一个本地分支,同时新建一个对应的远端分支:
|
||||
|
||||
  当主干发生较大变化,例如:原厂更新sdk时,需要新建分支,划分界限。
|
||||
|
||||
```code
|
||||
$ git branch -a
|
||||
----------------
|
||||
* master
|
||||
remotes/origin/HEAD -> origin/master
|
||||
remotes/origin/app_test
|
||||
remotes/origin/master
|
||||
$ git checkout -b master-sdk-202405 origin/master
|
||||
-------------------------------------------------
|
||||
M ipc-sdk
|
||||
Branch 'master-sdk-202405' set up to track remote branch 'master' from 'origin'.
|
||||
Switched to a new branch 'master-sdk-202405'
|
||||
$ git branch -a
|
||||
----------------
|
||||
master
|
||||
* master-sdk-202405
|
||||
remotes/origin/HEAD -> origin/master
|
||||
remotes/origin/app_test
|
||||
remotes/origin/master
|
||||
$ git push origin master-sdk-202405:sdk-202405
|
||||
----------------------------------------------
|
||||
Enumerating objects: 3, done.
|
||||
Counting objects: 100% (3/3), done.
|
||||
Delta compression using up to 8 threads
|
||||
Compressing objects: 100% (2/2), done.
|
||||
Writing objects: 100% (2/2), 250 bytes | 250.00 KiB/s, done.
|
||||
Total 2 (delta 1), reused 0 (delta 0)
|
||||
remote: Powered by GITEE.COM [GNK-6.4]
|
||||
remote: Create a pull request for 'sdk-202405' on Gitee by visiting:
|
||||
remote: https://gitee.com/shenzhen-jiuyilian/ipc-rk1106/pull/new/shenzhen-jiuyilian:sdk-202405...shenzhen-jiuyilian:master
|
||||
To gitee.com:shenzhen-jiuyilian/ipc-rk1106.git
|
||||
* [new branch] master-sdk-202405 -> sdk-202405
|
||||
$ git branch -a
|
||||
---------------
|
||||
master
|
||||
* master-sdk-202405
|
||||
remotes/origin/HEAD -> origin/master
|
||||
remotes/origin/app_test
|
||||
remotes/origin/master
|
||||
remotes/origin/sdk-202405
|
||||
```
|
||||
|
||||
### 1.4.2. git获取远端分支
|
||||
|
||||
  当想知道远端是否新建了分支,可使用git fetch命令获取远端分支。
|
||||
|
||||
**git fetch示例:**
|
||||
|
||||
```code
|
||||
$ git fetch
|
||||
------------
|
||||
remote: Enumerating objects: 21, done.
|
||||
remote: Counting objects: 100% (21/21), done.
|
||||
remote: Compressing objects: 100% (11/11), done.
|
||||
remote: Total 14 (delta 8), reused 0 (delta 0), pack-reused 0
|
||||
Unpacking objects: 100% (14/14), 2.14 KiB | 156.00 KiB/s, done.
|
||||
From gitee.com:shenzhen-jiuyilian/ipc-rk1106
|
||||
bf71a01..2b9b803 master -> origin/master
|
||||
* [new branch] sdk-202402 -> origin/sdk-202402 // 此处发现远端新建了分支
|
||||
Fetching submodule ipc-sdk
|
||||
From gitee.com:shenzhen-jiuyilian/ipc
|
||||
7c261bd..eec9fb4 master-develop -> origin/master-develop
|
||||
```
|
||||
|
||||
**多个远端仓库git fetch示例:**
|
||||
|
||||
```code
|
||||
$ git remote -v
|
||||
----------------
|
||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (fetch)
|
||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (push)
|
||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (fetch)
|
||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (push)
|
||||
$ git fetch dgiot // git fetch + 远端仓库名称
|
||||
---------------------------------------------
|
||||
remote: Enumerating objects: 9, done.
|
||||
remote: Counting objects: 100% (9/9), done.
|
||||
remote: Compressing objects: 100% (7/7), done.
|
||||
remote: Total 9 (delta 3), reused 5 (delta 2), pack-reused 0
|
||||
Unpacking objects: 100% (9/9), 8.74 KiB | 746.00 KiB/s, done.
|
||||
From gitee.com:shenzhen-jiuyilian/fastbootserver
|
||||
* [new branch] sdk-202405 -> dgiot/sdk-202405
|
||||
```
|
||||
|
||||
### 1.4.3. git新增远端地址
|
||||
|
||||
  在一个git仓库中,可以同时管理多个远端地址,例如:在原厂的git仓库中,可以在仓库添加一个私人的git仓库,这样后续把修改提交到自己的仓库进行代码管理。
|
||||
|
||||
**git remote add示例:**
|
||||
|
||||
命令格式:
|
||||
|
||||
```code
|
||||
git remote add <remote-name> <remote-url>
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
```code
|
||||
$ git remote add dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git
|
||||
---------------------------------------------------------------------------
|
||||
$ git remote -v
|
||||
----------------
|
||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (fetch)
|
||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (push)
|
||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (fetch)
|
||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (push)
|
||||
$ git fetch dgiot
|
||||
------------------
|
||||
remote: Enumerating objects: 107, done.
|
||||
remote: Counting objects: 100% (104/104), done.
|
||||
remote: Compressing objects: 100% (45/45), done.
|
||||
remote: Total 99 (delta 47), reused 89 (delta 42), pack-reused 0
|
||||
Unpacking objects: 100% (99/99), 29.55 KiB | 315.00 KiB/s, done.
|
||||
From gitee.com:shenzhen-jiuyilian/fastbootserver
|
||||
* [new branch] master -> dgiot/master
|
||||
* [new branch] sdk-202405 -> dgiot/sdk-202405
|
||||
$ git branch -a
|
||||
----------------
|
||||
* (HEAD detached at bf91101)
|
||||
remotes/dgiot/master
|
||||
remotes/dgiot/sdk-202405
|
||||
remotes/m/master
|
||||
remotes/rk/master
|
||||
$ git checkout -b sdk-202405 m/master
|
||||
--------------------------------------
|
||||
Switched to a new branch 'sdk-202405'
|
||||
$ git branch -a
|
||||
----------------
|
||||
* sdk-202405
|
||||
remotes/dgiot/master
|
||||
remotes/dgiot/sdk-202405
|
||||
remotes/m/master
|
||||
remotes/rk/master
|
||||
$ git pull dgiot sdk-202405
|
||||
---------------------------
|
||||
From gitee.com:shenzhen-jiuyilian/fastbootserver
|
||||
* branch sdk-202405 -> FETCH_HEAD
|
||||
Updating bf91101..dc76264
|
||||
Fast-forward
|
||||
.clang-format | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
.gitmodules | 3 +++
|
||||
README.md | 30 ++++++++++++++++++++++++++++++
|
||||
rv1106_ipc_sdk | 1 +
|
||||
4 files changed, 170 insertions(+)
|
||||
create mode 100644 .clang-format
|
||||
create mode 100644 .gitmodules
|
||||
create mode 100755 README.md
|
||||
create mode 160000 rv1106_ipc_sdk
|
||||
$ git submodule update --init
|
||||
-----------------------------
|
||||
Submodule 'rv1106_ipc_sdk' (git@gitee.com:shenzhen-jiuyilian/ipc-rk1106.git) registered for path 'rv1106_ipc_sdk'
|
||||
Cloning into '/home/xiaojiazhu/project/rkipc/ipc_20240517/project/app/component/fastboot_server/rv1106_ipc_sdk'...
|
||||
Submodule path 'rv1106_ipc_sdk': checked out 'ff8da760b201d365300aed78190de8564f0d2171'
|
||||
```
|
||||
|
||||
### 1.4.4. git删除远端地址
|
||||
|
||||
```code
|
||||
# git remote remove <remote-name>
|
||||
$ git remote -v
|
||||
---------------
|
||||
Germany payton@git.affgt.com:Germany/hunting.git (fetch)
|
||||
Germany payton@git.affgt.com:Germany/hunting.git (push)
|
||||
origin git@gitee.com:shenzhen-jiuyilian/ipc.git (fetch)
|
||||
origin git@gitee.com:shenzhen-jiuyilian/ipc.git (push)
|
||||
$ git remote remove Germany
|
||||
---------------------------
|
||||
$ git remote -v
|
||||
----------------
|
||||
origin git@gitee.com:shenzhen-jiuyilian/ipc.git (fetch)
|
||||
origin git@gitee.com:shenzhen-jiuyilian/ipc.git (push)
|
||||
```
|
||||
|
||||
### 1.4.5. git删除一个远端分支
|
||||
|
||||
```code
|
||||
# git push <remote-name> --delete <branch-name>
|
||||
$ git branch -r
|
||||
---------------
|
||||
origin/Branch_QT
|
||||
origin/HEAD -> origin/master
|
||||
origin/master
|
||||
origin/master-develop
|
||||
origin/without-testtools
|
||||
$ git push origin --delete Branch_QT
|
||||
-------------------------------------
|
||||
remote: Powered by GITEE.COM [GNK-6.4]
|
||||
To gitee.com:shenzhen-jiuyilian/ipc.git
|
||||
- [deleted] Branch_QT
|
||||
```
|
||||
|
||||
## 1.5. 多仓库管理
|
||||
|
||||
### 1.5.1. 合并两个无关联记录的仓库
|
||||
|
||||
  在一个仓库上合并另外一个无关联记录的仓库。
|
||||
|
||||
```code
|
||||
# 假设A仓库的代码合入到B仓库
|
||||
# 在需要合并的仓库A下面执行
|
||||
$ rm -rf .git # 如果不需要A仓库的修改记录,需要重新创建一个新的本地分支和记录;
|
||||
$ git init # 初始化一个空的仓库,并创建.git目录;
|
||||
$ git add . # 添加A仓库的代码;
|
||||
$ git commit -m "new log" # 保存代码,创建新的log;此时创建了一个本地的master分支;
|
||||
$ git remote add B <B仓库的地址> # 添加B仓库的地址;
|
||||
$ git fetch B # 拉取B仓库的信息;
|
||||
$ git checkout -b open B/master # 创建一个B仓库的本地分支,并切换到该分支;
|
||||
$ git merge master --allow-unrelated-histories # 合并A仓库的代码,并允许两个分支没有关联记录;
|
||||
$ git checkout --theirs . # 合并如果有冲突,选择A仓库的代码;
|
||||
$ git restore --source=master output_files/libs/ # 按需,恢复A仓库的某些代码;
|
||||
$ git add . # 添加需要合并的代码;
|
||||
$ git commit -m "merge log" # 合并后的代码,保存到本地仓库;
|
||||
$ git push B open:master # 推送到B仓库的master分支;
|
||||
```
|
||||
|
||||
## 1.6. 存疑
|
||||
|
||||
* 不同的分支之间如何同步某个文件?
|
20
doc/huntting_project_report.md
Normal file
20
doc/huntting_project_report.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# 1. 项目进度汇总
|
||||
|
||||
## 1.1. 软件开发进度
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
dateFormat YYYY-MM-DD
|
||||
title 软件进度-3月
|
||||
section 3月
|
||||
6帧探RTSP推流 : done, rtsp_media, 2024-03-18,3d
|
||||
SC230AI快启验证(快启报错) : crit, active, 2024-03-21,3d
|
||||
6帧探视频回放 : active, 2024-03-25,3d
|
||||
```
|
||||
|
||||
### 1.1.1. 总结
|
||||
|
||||
* 截至2024-3-25:
|
||||
1. 6侦探协议框架含http和tcp,http协议框架开发完成,rtsp推流到手机APP完成;
|
||||
2. 存在问题:rtsp推流存在卡顿问题,待优化;
|
||||
3. 更换SC230AI调试快启,快启报错,需要提问题单找原厂协助;
|
101
doc/markdown_user_guide.md
Normal file
101
doc/markdown_user_guide.md
Normal file
|
@ -0,0 +1,101 @@
|
|||
# 1. Markdown使用手册
|
||||
|
||||
## 1.1. 概述
|
||||
|
||||
使用markdown编辑开发文档有以下好处:
|
||||
|
||||
* markdown语法是一种语言,类似代码一样可以方便git管理,查看修改记录;
|
||||
* 对代码显示支持良好;
|
||||
* 可以进行UML类图和时序图的编辑/迭代/维护(强烈推荐);
|
||||
|
||||
## 1.2. 如何使用Markdown
|
||||
|
||||
此处介绍基于vscode编辑环境下使用Markdown的方法:
|
||||
|
||||
* 首先安装vscode插件:
|
||||
1. Markdown All in One
|
||||
2. Markdown Preview Enhanced
|
||||
* 使用Markdown语法编辑开发文档,并使用vscode预览;
|
||||
* 右键使用浏览器打开并打印可生成PDF文档;
|
||||
|
||||
## 1.3. 基本语法介绍
|
||||
|
||||
提供常用语法参考,直接copy模块代码进行编辑。
|
||||
|
||||
### 1.3.1. 常用命令
|
||||
|
||||
```
|
||||
Markdown All in One: Create Table of Contents 创建目录
|
||||
Markdown All in One: Update Table of Contents 更新目录
|
||||
Markdown All in One: Add/Update section numbers 添加 / 更新章节编号
|
||||
Markdown All in One: Remove section numbers 删除章节编号
|
||||
Markdown All in One: Toggle code span 触发设置代码范围(`code`)
|
||||
Markdown All in One: Toggle code block 触发设置代码块(```codes```)
|
||||
Markdown All in One: Print current document to HTML
|
||||
Markdown All in One: Toggle math environment 触发设置数学环境
|
||||
Markdown All in One: Toggle list 触发设置列表环境
|
||||
```
|
||||
|
||||
### 1.3.2. 代码段
|
||||
|
||||
```
|
||||
/*This is your code.*/
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### 1.3.3. UML类图语法
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
Animal <|-- Fish:继承
|
||||
Animal <|.. Zebra:实现
|
||||
Animal : +int age
|
||||
Animal : +String gender
|
||||
Animal: +isMammal()
|
||||
Animal: +mate()
|
||||
class Animal{
|
||||
<<interface>>
|
||||
+call() int
|
||||
}
|
||||
class Fish{
|
||||
-int sizeInFeet
|
||||
-canEat()
|
||||
}
|
||||
class Zebra{
|
||||
<<class>>
|
||||
-func(int, int) int
|
||||
+bool is_wild
|
||||
+run(void)
|
||||
}
|
||||
```
|
||||
|
||||
实现:一般指对抽象类的实例类 \
|
||||
继承:一般指对普通功能基类的派生/重载
|
||||
|
||||
### 1.3.4. UML时序图
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
Alice->>+Jhon:Call function
|
||||
Jhon->>Jhon:handle
|
||||
Jhon-->>-Alice:Call return
|
||||
note left of Alice:function
|
||||
|
||||
Alice->>+Jhon:Call function
|
||||
Jhon->>+Fancy:Call
|
||||
Fancy-->>-Jhon:Call return
|
||||
Jhon-->>-Alice:Call return
|
||||
|
||||
Alice->>+Jhon:Call function
|
||||
Jhon->>+Fancy:Call
|
||||
Fancy->>-Fancy:End
|
||||
Jhon-->>-Alice:Call return
|
||||
```
|
||||
|
||||
### 1.3.5. 踩坑记录
|
||||
|
||||
1. 状态图不能使用default关键字作为一个状态名称,无法画图;
|
9
doc/sdk_build_guide.md
Normal file
9
doc/sdk_build_guide.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# 1. SDK构建设计文档
|
||||
|
||||
## 1.1. 概述
|
||||
|
||||
  SDK使用cmake构建,把分层解耦合的独立模块编译成静态库,应用程序根据依赖关系进行自动关联链接。
|
||||
|
||||
## 1.2. 启用/禁用功能模块
|
||||
|
||||
  根据不同的产品需求来启用/禁用功能模块,避免编译不需要的模块。
|
89
doc/vscode_ssh_guide.md
Normal file
89
doc/vscode_ssh_guide.md
Normal file
|
@ -0,0 +1,89 @@
|
|||
# 1. vscode使用ssh链接虚拟机服务器
|
||||
|
||||
# 2. 前言
|
||||
|
||||
   在vscode使用ssh工具远程登录虚拟机服务器进行代码编辑。
|
||||
|
||||
| 内容 | 时间 | 作者 | 备注 |
|
||||
|----|----|----|----|
|
||||
| 首版 | 2024-2-26 | xjz | - |
|
||||
|
||||
## 2.1. Windows系统
|
||||
|
||||
* 安装ssh
|
||||
|
||||
   直接安装git工具即可支持ssh
|
||||
|
||||
安装完后确认:
|
||||
```
|
||||
xiaojiazhu@ubuntu:~/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell$ ssh
|
||||
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
|
||||
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
|
||||
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
|
||||
[-i identity_file] [-J [user@]host[:port]] [-L address]
|
||||
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
|
||||
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
|
||||
[-w local_tun[:remote_tun]] destination [command]
|
||||
```
|
||||
|
||||
* vscode安装ssh插件
|
||||
|
||||
   使用 Remote - SSH 插件
|
||||
|
||||
* ssh密钥配置
|
||||
|
||||
1. Windows生成密钥;
|
||||
2. 把xxx.pub文件内容拷贝到虚拟机的ssh目录下的authorized_keys文件;
|
||||
此处是:
|
||||
|
||||
```
|
||||
xiaojiazhu@ubuntu:~/project/.ssh$ pwd
|
||||
/home/xiaojiazhu/project/.ssh
|
||||
xiaojiazhu@ubuntu:~/project/.ssh$ ls
|
||||
authorized_keys id_rsa id_rsa.pub
|
||||
```
|
||||
|
||||
这样设置后,每次登录ssh无需手动输入密码;
|
||||
|
||||
3. 在Windows远程登录虚拟机:
|
||||
|
||||
参考命令:ssh xiaojiazhu@192.168.1.29
|
||||
|
||||
```
|
||||
PS C:\Users\xjz\.ssh> ssh xiaojiazhu@192.168.1.29
|
||||
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-94-generic x86_64)
|
||||
|
||||
* Documentation: https://help.ubuntu.com
|
||||
* Management: https://landscape.canonical.com
|
||||
* Support: https://ubuntu.com/advantage
|
||||
|
||||
Expanded Security Maintenance for Applications is not enabled.
|
||||
|
||||
75 updates can be applied immediately.
|
||||
To see these additional updates run: apt list --upgradable
|
||||
|
||||
9 additional security updates can be applied with ESM Apps.
|
||||
Learn more about enabling ESM Apps service at https://ubuntu.com/esm
|
||||
|
||||
New release '22.04.3 LTS' available.
|
||||
Run 'do-release-upgrade' to upgrade to it.
|
||||
|
||||
Your Hardware Enablement Stack (HWE) is supported until April 2025.
|
||||
*** System restart required ***
|
||||
Last login: Sun Feb 25 17:20:04 2024 from 192.168.1.29
|
||||
xiaojiazhu@ubuntu:~$
|
||||
```
|
||||
## 2.2. vscode设置
|
||||
|
||||
配置文件参考
|
||||
|
||||
```
|
||||
Host dgiot // 自定义的主机名
|
||||
HostName 192.168.1.29 // 远端的IP地址
|
||||
User xiaojiazhu 用户名
|
||||
Port 22
|
||||
IdentityFile "C:\Users\xjz\.ssh\id_ed25519" // 本端的私钥文件路径
|
||||
ForwardAgent yes // 忽略
|
||||
```
|
||||
|
||||
多个远端IP复制即可。
|
3
external/CMakeLists.txt
vendored
3
external/CMakeLists.txt
vendored
|
@ -20,4 +20,5 @@ add_subdirectory(httpserver.h-master/src)
|
|||
|
||||
add_subdirectory(cJSON-1.7.17)
|
||||
add_subdirectory(libhv/libhv-1.3.2)
|
||||
add_subdirectory(ffmpeg)
|
||||
add_subdirectory(ffmpeg)
|
||||
add_subdirectory(libconfig)
|
7
external/ffmpeg/CMakeLists.txt
vendored
7
external/ffmpeg/CMakeLists.txt
vendored
|
@ -1,12 +1,8 @@
|
|||
|
||||
|
||||
add_custom_target(
|
||||
ffmpeg
|
||||
# DEPENDS ${EXTERNAL_LIBS_OUTPUT_PATH}/libgo.a
|
||||
# COMMAND mkdir ${GOAHEAD_UPLOAD_TMP_PATH}
|
||||
# COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/modify/http.c ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src
|
||||
# COMMAND touch ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src/http.c
|
||||
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz
|
||||
COMMAND chmod 777 -R ffmpeg-6.1.1
|
||||
COMMAND cd ffmpeg-6.1.1 && ./configure --enable-cross-compile --target-os=linux --arch=arm64
|
||||
--cc=${CMAKE_C_COMPILER}
|
||||
--cxx=${CMAKE_CXX_COMPILER}
|
||||
|
@ -27,6 +23,7 @@ add_custom_target(
|
|||
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug
|
||||
COMMAND cd ffmpeg-6.1.1 && make
|
||||
COMMAND cd ffmpeg-6.1.1 && make install
|
||||
COMMAND cd ffmpeg-6.1.1 && make clean
|
||||
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/ffmpeg/
|
||||
)
|
||||
|
||||
|
|
26
external/libconfig/CMakeLists.txt
vendored
Normal file
26
external/libconfig/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
set(LIBCONFIG_INSTALL_PATH "${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig")
|
||||
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
||||
set(CONFIGURE_COMMAND "--disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}")
|
||||
else()
|
||||
set(CONFIGURE_COMMAND "--host=${COMPILE_HOST} --disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}")
|
||||
endif()
|
||||
message("Compile libconfig comand : ${CONFIGURE_COMMAND}")
|
||||
add_custom_target(
|
||||
libconfig
|
||||
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/libconfig-1.7.3/Makefile || tar zxvf libconfig-1.7.3.tar.gz
|
||||
COMMAND chmod 777 -R libconfig-1.7.3
|
||||
# COMMAND cd libconfig-1.7.3 && ./configure --disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}
|
||||
COMMAND cd libconfig-1.7.3 && bash -c "./configure ${CONFIGURE_COMMAND}"
|
||||
COMMAND cd libconfig-1.7.3 && make
|
||||
COMMAND cd libconfig-1.7.3 && make install
|
||||
COMMAND cd libconfig-1.7.3 && make clean
|
||||
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
|
||||
)
|
||||
add_custom_target(
|
||||
remove_libconfig_source_files
|
||||
COMMAND rm -rf libconfig-1.7.3
|
||||
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
|
||||
)
|
||||
|
||||
# 将clean目标依赖于我们自定义的clean_script目标
|
||||
add_dependencies(sdk_clean remove_libconfig_source_files)
|
|
@ -12,6 +12,7 @@ include_directories(
|
|||
${UTILS_SOURCE_PATH}/Log/include
|
||||
${UTILS_SOURCE_PATH}/LinuxApi/include
|
||||
${UTILS_SOURCE_PATH}/KeyControl/include
|
||||
${UTILS_SOURCE_PATH}/LedControl/include
|
||||
)
|
||||
#do not rely on any other library
|
||||
# link_directories(
|
||||
|
@ -24,7 +25,7 @@ aux_source_directory(./src IMPL_SRC_FILES)
|
|||
set(ABSTRACT_TARGET HalAbstract)
|
||||
set(IMPL_TARGET Hal)
|
||||
add_library(${ABSTRACT_TARGET} STATIC ${ABSTRACT_SRC_FILES})
|
||||
target_link_libraries(${ABSTRACT_TARGET} LinuxApi KeyControl StatusCode Log)
|
||||
target_link_libraries(${ABSTRACT_TARGET} LinuxApi KeyControl LedControl StatusCode Log)
|
||||
add_library(${IMPL_TARGET} STATIC ${IMPL_SRC_FILES})
|
||||
target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET})
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
camera_report_event::camera_report_event(const std::string &fileName, const CameraType &cameraType)
|
||||
: mFileName(fileName), mCameraType(cameraType)
|
||||
{
|
||||
|
@ -64,8 +67,14 @@ void VCameraHalMonitor::ReportEvent(const CameraReportEvent &event)
|
|||
{
|
||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
}
|
||||
StatusCode VCameraTaskContext::TaskFinished(void)
|
||||
{
|
||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
camera_task_param::camera_task_param(const CameraTaskType &cameraTask) : mCameraTask(cameraTask)
|
||||
{
|
||||
mVideoRecordingTimeMs = DEFAULT_VIDEO_RECORDING_TIME_MS;
|
||||
}
|
||||
void VCameraHal::SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor)
|
||||
{
|
||||
|
@ -76,6 +85,21 @@ StatusCode VCameraHal::StartSingleTask(const CameraTaskParam ¶m)
|
|||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VCameraHal::StopTask(void)
|
||||
{
|
||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VCameraHal::SetAudioStreamCallback(AudioStreamCallback callback)
|
||||
{
|
||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VCameraHal::SetVideoStreamCallback(VideoStreamCallback callback)
|
||||
{
|
||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
void VSdCardHalMonitor::ReportEvent(const SdCardHalStatus &status)
|
||||
{
|
||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef I_HAL_CPP_H
|
||||
#define I_HAL_CPP_H
|
||||
#include "StatusCode.h"
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
@ -70,7 +71,6 @@ public:
|
|||
virtual void CheckKeyStatus(void);
|
||||
virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event);
|
||||
virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor);
|
||||
// virtual std::string GetKeyHalName(void);
|
||||
};
|
||||
class VLedHal
|
||||
{
|
||||
|
@ -100,6 +100,7 @@ class VCameraTaskContext
|
|||
public:
|
||||
VCameraTaskContext() = default;
|
||||
virtual ~VCameraTaskContext() = default;
|
||||
virtual StatusCode TaskFinished(void);
|
||||
};
|
||||
template <typename T>
|
||||
class CameraTaskContext : public VCameraTaskContext
|
||||
|
@ -113,12 +114,18 @@ public:
|
|||
public:
|
||||
T mData;
|
||||
};
|
||||
constexpr int DEFAULT_VIDEO_RECORDING_TIME_MS = 10 * 1000;
|
||||
typedef struct camera_task_param
|
||||
{
|
||||
camera_task_param(const CameraTaskType &cameraTask);
|
||||
const CameraTaskType mCameraTask;
|
||||
unsigned int mVideoRecordingTimeMs;
|
||||
std::shared_ptr<VCameraTaskContext> mCtx;
|
||||
} CameraTaskParam;
|
||||
// using AudioStreamCallback = void (*)(const void *, const int, const unsigned long long);
|
||||
// using VideoStreamCallback = void (*)(const void *, const int, const unsigned long long);
|
||||
using AudioStreamCallback = std::function<void(const void *, const unsigned int &, const unsigned long long &)>;
|
||||
using VideoStreamCallback = std::function<void(const void *, const unsigned int &, const unsigned long long &)>;
|
||||
class VCameraHal
|
||||
{
|
||||
public:
|
||||
|
@ -126,6 +133,9 @@ public:
|
|||
virtual ~VCameraHal() = default;
|
||||
virtual void SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor);
|
||||
virtual StatusCode StartSingleTask(const CameraTaskParam ¶m);
|
||||
virtual StatusCode StopTask(void);
|
||||
virtual StatusCode SetAudioStreamCallback(AudioStreamCallback callback);
|
||||
virtual StatusCode SetVideoStreamCallback(VideoStreamCallback callback);
|
||||
};
|
||||
class VSdCardHalMonitor
|
||||
{
|
||||
|
|
58
hal/src/CameraHal.cpp
Normal file
58
hal/src/CameraHal.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CameraHal.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "StatusCode.h"
|
||||
CameraHal::CameraHal() : mTaskRuning(false), mAudioStreamCallback(nullptr), mVideoStreamCallback(nullptr)
|
||||
{
|
||||
}
|
||||
void CameraHal::Init(void)
|
||||
{
|
||||
}
|
||||
void CameraHal::UnInit(void)
|
||||
{
|
||||
}
|
||||
StatusCode CameraHal::StartSingleTask(const CameraTaskParam ¶m)
|
||||
{
|
||||
mTaskRuning = true;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode CameraHal::StopTask(void)
|
||||
{
|
||||
mTaskRuning = false;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode CameraHal::SetAudioStreamCallback(AudioStreamCallback callback)
|
||||
{
|
||||
mAudioStreamCallback = callback;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode CameraHal::SetVideoStreamCallback(VideoStreamCallback callback)
|
||||
{
|
||||
mVideoStreamCallback = callback;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
void CameraHal::GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
if (mTaskRuning && nullptr != mAudioStreamCallback) {
|
||||
mAudioStreamCallback(stream, length, timeStamp);
|
||||
}
|
||||
}
|
||||
void CameraHal::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
if (mTaskRuning && nullptr != mVideoStreamCallback) {
|
||||
mVideoStreamCallback(stream, length, timeStamp);
|
||||
}
|
||||
}
|
45
hal/src/CameraHal.h
Normal file
45
hal/src/CameraHal.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef CAMERA_HAL_H
|
||||
#define CAMERA_HAL_H
|
||||
#include "IHalCpp.h"
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
constexpr unsigned int NO_MEDIA_RECORDING = -1;
|
||||
class CameraHal : public VCameraHal, public std::enable_shared_from_this<CameraHal>
|
||||
{
|
||||
public:
|
||||
CameraHal();
|
||||
virtual ~CameraHal() = default;
|
||||
virtual void Init(void);
|
||||
virtual void UnInit(void);
|
||||
|
||||
protected:
|
||||
StatusCode StartSingleTask(const CameraTaskParam ¶m) override;
|
||||
StatusCode StopTask(void) override;
|
||||
StatusCode SetAudioStreamCallback(AudioStreamCallback callback) override;
|
||||
StatusCode SetVideoStreamCallback(VideoStreamCallback callback) override;
|
||||
|
||||
protected:
|
||||
void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
|
||||
void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
|
||||
|
||||
private:
|
||||
// std::mutex mMutex;
|
||||
bool mTaskRuning;
|
||||
AudioStreamCallback mAudioStreamCallback;
|
||||
VideoStreamCallback mVideoStreamCallback;
|
||||
};
|
||||
#endif
|
|
@ -13,7 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "Hal.h"
|
||||
#include "IHal.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
StatusCode HalInit(IHal *hal)
|
||||
|
|
|
@ -14,9 +14,15 @@
|
|||
*/
|
||||
#include "HalCpp.h"
|
||||
#include "HalMakePtr.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "SdCardHal.h"
|
||||
#include "StatusCode.h"
|
||||
#include "WifiHal.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
StatusCode HalCpp::Init(void)
|
||||
{
|
||||
LogInfo("HalCpp::Init\n");
|
||||
|
@ -30,12 +36,8 @@ StatusCode HalCpp::Init(void)
|
|||
if (nullptr != sdCardImpl) {
|
||||
sdCardImpl->Init();
|
||||
}
|
||||
HalMakePtr::GetInstance()->CreateAllKeyHal(mKeys);
|
||||
// auto checkPinValue = [](std::shared_ptr<HalCpp> impl) {
|
||||
// LogInfo("HalCpp::CheckAllPinVauleThread start\n");
|
||||
// impl->CheckAllPinVauleThread();
|
||||
// };
|
||||
// mCheckPinThread = std::thread(checkPinValue, shared_from_this());
|
||||
HalMakePtr::GetInstance()->CreateAllKeysHal(mKeys);
|
||||
HalMakePtr::GetInstance()->CreateAllLedsHal(mLeds);
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode HalCpp::UnInit(void)
|
||||
|
@ -45,10 +47,6 @@ StatusCode HalCpp::UnInit(void)
|
|||
if (nullptr != sdCardImpl) {
|
||||
sdCardImpl->UnInit();
|
||||
}
|
||||
mThreadRuning = false;
|
||||
if (mCheckPinThread.joinable()) {
|
||||
mCheckPinThread.join();
|
||||
}
|
||||
mWifiHal.reset();
|
||||
mSdCardHal.reset();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
|
@ -63,6 +61,19 @@ StatusCode HalCpp::GetSdCardHal(std::shared_ptr<VSdCardHal> &sdCard)
|
|||
sdCard = mSdCardHal;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode HalCpp::GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
||||
{
|
||||
LogInfo("GetAllLeds, size = %d\n", mLeds.size());
|
||||
for (auto &led : mLeds) {
|
||||
std::shared_ptr<VLedHal> ledControl = std::dynamic_pointer_cast<VLedHal>(led);
|
||||
if (nullptr == ledControl) {
|
||||
LogError("ledControl is nullptr\n");
|
||||
continue;
|
||||
}
|
||||
allLeds.insert(std::make_pair(led->GetLedName(), ledControl));
|
||||
}
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode HalCpp::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
||||
{
|
||||
LogInfo("GetAllKeys\n");
|
||||
|
@ -76,12 +87,3 @@ StatusCode HalCpp::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &a
|
|||
}
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
void HalCpp::CheckAllPinVauleThread(void)
|
||||
{
|
||||
// mThreadRuning = true;
|
||||
// while (mThreadRuning) {
|
||||
// for (auto &keyHalImpl : mKeys) {
|
||||
// }
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(PERIPHERAL_CHECK_PERIOD_MS));
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define HALCPP_H
|
||||
#include "IHalCpp.h"
|
||||
#include "KeyControl.h"
|
||||
#include "LedControl.h"
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
class HalCpp : public IHalCpp, public std::enable_shared_from_this<HalCpp>
|
||||
|
@ -27,17 +28,15 @@ public:
|
|||
StatusCode UnInit(void) override;
|
||||
StatusCode GetWifiHal(std::shared_ptr<VWifiHal> &wifi) override;
|
||||
StatusCode GetSdCardHal(std::shared_ptr<VSdCardHal> &sdCard) override;
|
||||
StatusCode GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds) override;
|
||||
StatusCode GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys) override;
|
||||
|
||||
private:
|
||||
void CheckAllPinVauleThread(void);
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<VLedHal>> mLedHals;
|
||||
std::shared_ptr<VWifiHal> mWifiHal;
|
||||
std::shared_ptr<VSdCardHal> mSdCardHal;
|
||||
std::vector<std::shared_ptr<VKeyControl>> mKeys;
|
||||
bool mThreadRuning = false;
|
||||
std::thread mCheckPinThread;
|
||||
std::vector<std::shared_ptr<VLedControl>> mLeds;
|
||||
};
|
||||
#endif
|
|
@ -15,14 +15,21 @@
|
|||
#include "HalMakePtr.h"
|
||||
#include "Hal.h"
|
||||
#include "HalCpp.h"
|
||||
#include "IHal.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "KeyControl.h"
|
||||
#include "LedControl.h"
|
||||
#include "SdCardHal.h"
|
||||
#include "StatusCode.h"
|
||||
#include "WifiHal.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
StatusCode CreateHalModule(void)
|
||||
{
|
||||
IHal *hal = NULL;
|
||||
IHal *hal = nullptr;
|
||||
StatusCode code = HalMakePtr::GetInstance()->CreateHalPtr(&hal);
|
||||
if (IsCodeOK(code) && NULL != hal) {
|
||||
if (IsCodeOK(code) && nullptr != hal) {
|
||||
LogInfo("Create Hal instance ok.\n");
|
||||
ResetHalImpl((IHal *)hal);
|
||||
}
|
||||
|
@ -93,7 +100,12 @@ StatusCode HalMakePtr::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl)
|
|||
impl = std::make_shared<SdCardHal>();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode HalMakePtr::CreateAllKeyHal(std::vector<std::shared_ptr<VKeyControl>> &keys)
|
||||
StatusCode HalMakePtr::CreateAllKeysHal(std::vector<std::shared_ptr<VKeyControl>> &keys)
|
||||
{
|
||||
LogInfo("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode HalMakePtr::CreateAllLedsHal(std::vector<std::shared_ptr<VLedControl>> &leds)
|
||||
{
|
||||
LogInfo("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
#define HALMAKEPTR_H
|
||||
#include "IHal.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "StatusCode.h"
|
||||
#include "KeyControl.h"
|
||||
#include "LedControl.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
class HalMakePtr
|
||||
{
|
||||
|
@ -38,6 +39,7 @@ public:
|
|||
virtual StatusCode CreateWifiHal(std::shared_ptr<VWifiHal> &impl);
|
||||
virtual StatusCode CreateCameraHal(std::shared_ptr<VCameraHal> &impl);
|
||||
virtual StatusCode CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl);
|
||||
virtual StatusCode CreateAllKeyHal(std::vector<std::shared_ptr<VKeyControl>> &keys);
|
||||
virtual StatusCode CreateAllKeysHal(std::vector<std::shared_ptr<VKeyControl>> &keys);
|
||||
virtual StatusCode CreateAllLedsHal(std::vector<std::shared_ptr<VLedControl>> &leds);
|
||||
};
|
||||
#endif
|
|
@ -13,17 +13,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "SdCardHal.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "LinuxApi.h"
|
||||
#include <errno.h>
|
||||
#include "StatusCode.h"
|
||||
#include <chrono>
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
const char *SD_CARD_DEVICE = SD_CARD_DEV;
|
||||
const char *SD_MOUNT_PATH = SD_CARD_MOUNT_PATH;
|
||||
|
|
|
@ -23,7 +23,8 @@ public:
|
|||
virtual ~SdCardHal() = default;
|
||||
void SetSdCardMonitor(std::shared_ptr<VSdCardHalMonitor> &monitor) override;
|
||||
SdCardHalStatus GetSdCardStatus(void) override;
|
||||
StatusCode GetCapacity(unsigned long long &totalSizeMB, unsigned long long &freeSizeMB, unsigned long long &usedSizeMB) override;
|
||||
StatusCode GetCapacity(unsigned long long &totalSizeMB, unsigned long long &freeSizeMB,
|
||||
unsigned long long &usedSizeMB) override;
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
void DevDetectingThread(void);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "WifiHal.h"
|
||||
#include "ILog.h"
|
||||
#include "LinuxApi.h"
|
||||
#include "StatusCode.h"
|
||||
#include <chrono>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -29,12 +31,22 @@ StatusCode WifiHal::OpenApMode(void)
|
|||
constexpr int SLEEP_TIME_MS = 5;
|
||||
constexpr int WAITING_TIME_MS = 1000 * 10;
|
||||
unsigned int sleepingTime_ms = 0;
|
||||
unsigned int resetWifiPowerCount = 0;
|
||||
mInitRunning = true;
|
||||
while (CheckWlan0IfExist() == false) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
|
||||
sleepingTime_ms += SLEEP_TIME_MS;
|
||||
if (sleepingTime_ms > WAITING_TIME_MS) {
|
||||
LogError("wlan0 not found. \n");
|
||||
if (0 == resetWifiPowerCount) {
|
||||
LogWarning("wlan0 not found, try to reset. \n");
|
||||
PowerOff();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
PowerOn();
|
||||
sleepingTime_ms = 0;
|
||||
resetWifiPowerCount++;
|
||||
continue;
|
||||
}
|
||||
LogError("wlan0 not found, reset wifi power count: %d. \n", resetWifiPowerCount);
|
||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
}
|
||||
if (false == mInitRunning) {
|
||||
|
@ -84,7 +96,5 @@ bool WifiHal::CheckWlan0IfExist(void)
|
|||
if (wlan0_found) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -13,9 +13,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "AppClient.h"
|
||||
#include "IAppManager.h"
|
||||
#include "IAppProtocolHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "TcpModule.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
AppClient::AppClient(const void *clientObject) : mClientObject(clientObject)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,10 +15,15 @@
|
|||
#include "AppManager.h"
|
||||
#include "AppClient.h"
|
||||
#include "AppManagerMakePtr.h"
|
||||
#include "IAppManager.h"
|
||||
#include "IAppProtocolHandle.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include "TcpModule.h"
|
||||
#include "WebServer.h"
|
||||
#include <memory>
|
||||
#include <sys/types.h>
|
||||
AppManager::AppManager() : mTcpServer(nullptr), mInitRuning(false)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
*/
|
||||
#include "AppManagerMakePtr.h"
|
||||
#include "AppManager.h"
|
||||
#include "IAppManager.h"
|
||||
#include "IAppProtocolHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
// extern bool CreateProtocolHandleImpl();
|
||||
bool CreateAppManagerModule(void)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
*/
|
||||
#include "IAppManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
app_get_product_info::app_get_product_info()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,7 +13,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "IAppProtocolHandle.h"
|
||||
#include "IAppManager.h"
|
||||
#include "ILog.h"
|
||||
#include "WebServer.h"
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
protocol_packet::~protocol_packet()
|
||||
{
|
||||
if (nullptr != mData) {
|
||||
|
|
|
@ -13,11 +13,21 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "SixFrameHandle.h"
|
||||
#include "IAppManager.h"
|
||||
#include "IAppProtocolHandle.h"
|
||||
#include "ILog.h"
|
||||
#include <WebServer.h>
|
||||
#include <cJSON.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
using std::placeholders::_1;
|
||||
using std::placeholders::_2;
|
||||
using std::placeholders::_3;
|
||||
|
@ -423,8 +433,8 @@ void SixFrameHandle::ResponseGetParamItems(cJSON *result, const AppGetCapability
|
|||
cJSON_AddItemToObject(mic, CJSON_INDEX_STRING, index);
|
||||
cJSON_AddItemToArray(items, cJSON_CreateString("on"));
|
||||
cJSON_AddItemToArray(items, cJSON_CreateString("off"));
|
||||
cJSON_AddItemToArray(index, cJSON_CreateNumber(0));
|
||||
cJSON_AddItemToArray(index, cJSON_CreateNumber(1));
|
||||
cJSON_AddItemToArray(index, cJSON_CreateNumber(0));
|
||||
}
|
||||
}
|
||||
// {
|
||||
|
@ -714,16 +724,10 @@ AppSetParamValue inline SixFrameHandle::RequestSetParamValueParse(const std::str
|
|||
auto parseFunc = [](const std::string &key, const std::string &value, std::shared_ptr<VParseUrl> &parse) {
|
||||
std::shared_ptr<ParseUrl<AppSetParamValue>> parseImpl =
|
||||
std::dynamic_pointer_cast<ParseUrl<AppSetParamValue>>(parse);
|
||||
if ("switchcam" == key) {
|
||||
parseImpl->mData.mName = "switchcam";
|
||||
parseImpl->mData.mValue = std::stoi(value);
|
||||
if ("param" == key) {
|
||||
parseImpl->mData.mName = value;
|
||||
}
|
||||
if ("rec" == key) {
|
||||
parseImpl->mData.mName = "rec";
|
||||
parseImpl->mData.mValue = std::stoi(value);
|
||||
}
|
||||
if ("mic" == key) {
|
||||
parseImpl->mData.mName = "mic";
|
||||
if ("value" == key) {
|
||||
parseImpl->mData.mValue = std::stoi(value);
|
||||
}
|
||||
};
|
||||
|
@ -1010,10 +1014,8 @@ std::shared_ptr<ProtocolPacket> SixFrameHandle::MakePacket(const cJSON *json)
|
|||
if (nullptr != resultStr) {
|
||||
return std::make_shared<ProtocolPacket>(resultStr, strlen(resultStr));
|
||||
}
|
||||
else {
|
||||
LogError("MakePacket failed.\n");
|
||||
return std::make_shared<ProtocolPacket>();
|
||||
}
|
||||
LogError("MakePacket failed.\n");
|
||||
return std::make_shared<ProtocolPacket>();
|
||||
}
|
||||
void SixFrameHandle::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
||||
{
|
||||
|
|
|
@ -13,8 +13,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "SixFrameMakePtr.h"
|
||||
#include "AppManagerMakePtr.h"
|
||||
#include "IAppProtocolHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "SixFrameHandle.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateProtocolHandleImpl(void)
|
||||
{
|
||||
LogInfo("CreateProtocolHandleImpl SixFrameMakePtr.\n");
|
||||
|
|
|
@ -13,10 +13,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "DeviceManager.h"
|
||||
#include "IDeviceManager.h"
|
||||
#include "ILog.h"
|
||||
#include "KeyManager.h"
|
||||
#include "LedManager.h"
|
||||
#include <vector>
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
const StatusCode DeviceManager::Init(void)
|
||||
{
|
||||
KeyManager::GetInstance()->Init();
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
#include "DeviceManagerMakePtr.h"
|
||||
#include "DeviceManager.h"
|
||||
#include "IDeviceManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateDeviceManagerModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IDeviceManager>();
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
*/
|
||||
#include "IDeviceManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
void VKeyMonitor::KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,7 +13,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "KeyManager.h"
|
||||
#include "IDeviceManager.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
// #include "KeyControl.h"
|
||||
#include "StatusCode.h"
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
std::shared_ptr<KeyManager> &KeyManager::GetInstance(std::shared_ptr<KeyManager> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<KeyManager>();
|
||||
|
|
|
@ -13,7 +13,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "LedManager.h"
|
||||
#include "IDeviceManager.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "LedControl.h"
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
std::shared_ptr<LedManager> &LedManager::GetInstance(std::shared_ptr<LedManager> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<LedManager>();
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
*/
|
||||
#ifndef FILES_DATABASE_H
|
||||
#define FILES_DATABASE_H
|
||||
#include "StatusCode.h"
|
||||
#include "FilesHandle.h"
|
||||
#include "IFilesManager.h"
|
||||
#include "StatusCode.h"
|
||||
class FilesDatabase : public FilesHandle
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -14,17 +14,14 @@
|
|||
*/
|
||||
#include "FilesHandle.h"
|
||||
#include "ILog.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <string>
|
||||
std::string FilesHandle::CreateFilePathName(const std::string &sourceFile)
|
||||
{
|
||||
const std::string ERROR_SUFFIX = "";
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "FilesManagerImpl.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "IFilesManager.h"
|
||||
// #include "IStorageManager.h"
|
||||
#include "FilesDatabase.h"
|
||||
#include "StatusCode.h"
|
||||
StatusCode FilesManagerImpl::Init(void)
|
||||
{
|
||||
FilesDatabase::Init();
|
||||
|
|
|
@ -13,8 +13,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "FilesManagerMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "FilesManagerImpl.h"
|
||||
#include "IFilesManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateFilesManagerModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IFilesManager>();
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
*/
|
||||
#include "IFilesManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
save_file_info::save_file_info(const std::string &fileName) : mFileName(fileName)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,9 +13,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "FilesDatabase.h"
|
||||
#include "FilesHandle.h"
|
||||
#include "IFilesManager.h"
|
||||
#include "ILog.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "SqliteHandle.h"
|
||||
#include "StatusCode.h"
|
||||
#include <string>
|
||||
void FilesDatabase::Init(void)
|
||||
{
|
||||
SqliteHandle::GetInstance()->Init();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "SqliteHandle.h"
|
||||
#include "ILog.h"
|
||||
#include "sqlite3.h"
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
std::shared_ptr<SqliteHandle> &SqliteHandle::GetInstance(std::shared_ptr<SqliteHandle> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<SqliteHandle>();
|
||||
|
@ -31,7 +33,7 @@ std::shared_ptr<SqliteHandle> &SqliteHandle::GetInstance(std::shared_ptr<SqliteH
|
|||
}
|
||||
void SqliteHandle::Init(void)
|
||||
{
|
||||
sqlite3 *db;
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
rc = sqlite3_open("test.db", &db);
|
||||
if (rc) {
|
||||
|
@ -42,5 +44,4 @@ void SqliteHandle::Init(void)
|
|||
}
|
||||
void SqliteHandle::UnInit(void)
|
||||
{
|
||||
|
||||
}
|
|
@ -14,6 +14,8 @@
|
|||
*/
|
||||
#include "HuntingUpgradeImpl.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include "UpgradeBase.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
#include "HuntingUpgradeMakePtr.h"
|
||||
#include "HuntingUpgradeImpl.h"
|
||||
#include "IHuntingUpgrade.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateHuntingUpgradeModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IHuntingUpgrade>();
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
*/
|
||||
#include "IHuntingUpgrade.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
std::shared_ptr<IHuntingUpgrade> &IHuntingUpgrade::GetInstance(std::shared_ptr<IHuntingUpgrade> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<IHuntingUpgrade>();
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
*/
|
||||
#include "IIpcConfig.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
working_time::working_time() : mHourFrom(0), mHourTo(0), mMinuteFrom(0), mMinuteTo(0)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,13 +13,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "IpcConfigImpl.h"
|
||||
#include "ConfigBase.h"
|
||||
#include "IIpcConfig.h"
|
||||
#include "ILog.h"
|
||||
#include "LinuxApi.h"
|
||||
#include <dirent.h>
|
||||
#include "StatusCode.h"
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#define CHECK_MAP(map) (map.size() == 1 ? true : false)
|
||||
const char *CONFIG_WIFI_SSID = "wifi_ssid";
|
||||
const char *CONFIG_WIFI_SSID_DEFAULT = "Hunting 2024";
|
||||
|
|
|
@ -13,8 +13,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "IpcConfigMakePtr.h"
|
||||
#include "IIpcConfig.h"
|
||||
#include "ILog.h"
|
||||
#include "IpcConfigImpl.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateIpcConfigModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IIpcConfig>();
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "McuAskBase.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include <semaphore.h>
|
||||
McuAskBase::McuAskBase(const McuAskBlock isBlock, const McuAskReply needReply, const unsigned int timeoutMs)
|
||||
: mIsBlock(isBlock), mNeedReply(needReply), mTimeout(timeoutMs)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
*/
|
||||
#include "IMcuManager.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
mcu_ask_date_time::mcu_ask_date_time(const unsigned short year, const unsigned char mon, const unsigned char day,
|
||||
const unsigned char hour, const unsigned char min, const unsigned char second)
|
||||
: mYear(year), mMon(mon), mDay(day), mHour(hour), mMin(min), mSecond(second)
|
||||
|
|
|
@ -14,7 +14,19 @@
|
|||
*/
|
||||
#include "McuDevice.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "McuProtocol.h"
|
||||
#include "StatusCode.h"
|
||||
#include "UartDevice.h"
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <thread>
|
||||
constexpr int SLEEP_TIME_MS = 1000;
|
||||
constexpr bool REMOVE_THE_ASK = true;
|
||||
constexpr bool KEEP_THE_ASK = false;
|
||||
|
|
|
@ -14,7 +14,19 @@
|
|||
*/
|
||||
#include "McuManagerImpl.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "McuAskBase.h"
|
||||
#include "McuDevice.h"
|
||||
#include "McuProtocol.h"
|
||||
#include "StatusCode.h"
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
class McuRecvImpl
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
#include "McuManagerMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "McuManagerImpl.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateMcuManager(void)
|
||||
{
|
||||
auto instance = std::make_shared<IMcuManager>();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "UartRecvAsk.h"
|
||||
#include "McuAskBase.h"
|
||||
UartRecvAsk::UartRecvAsk() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
}
|
|
@ -14,6 +14,10 @@
|
|||
*/
|
||||
#include "IMediaManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
media_report_event::media_report_event(const std::string &fileName, const MediaChannel &mediaChannedl)
|
||||
: mFileName(fileName), mMediaChannedl(mediaChannedl)
|
||||
{
|
||||
|
|
|
@ -13,11 +13,48 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "MediaHandle.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "SaveStream.h"
|
||||
#include "StatusCode.h"
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
MediaHandle::MediaHandle(const MediaChannel &mediaChannel, const std::shared_ptr<VCameraHal> &cameraHal)
|
||||
: mMediaChannel(mediaChannel), mCameraHal(cameraHal)
|
||||
: mMediaChannel(mediaChannel), mCameraHal(cameraHal), mTaskRuning(false)
|
||||
{
|
||||
}
|
||||
void MediaHandle::Init(void)
|
||||
{
|
||||
if (mCameraHal == nullptr) {
|
||||
LogError("CameraHal is null.\n");
|
||||
return;
|
||||
}
|
||||
auto audioFunc = std::bind(&MediaHandle::GetAudioStreamCallback, this, _1, _2, _3);
|
||||
mCameraHal->SetAudioStreamCallback(audioFunc);
|
||||
auto videoFunc = std::bind(&MediaHandle::GetVideoStreamCallback, this, _1, _2, _3);
|
||||
mCameraHal->SetVideoStreamCallback(videoFunc);
|
||||
}
|
||||
void MediaHandle::UnInit(void)
|
||||
{
|
||||
mTaskRuning = false;
|
||||
mCv.notify_one();
|
||||
if (mTaskTimerThread.joinable()) {
|
||||
mTaskTimerThread.join();
|
||||
}
|
||||
if (mCameraHal) {
|
||||
/**
|
||||
* @brief Before releasing the class instance, it is necessary to call the UnInit function to ensure that the
|
||||
* callback function is cleared elsewhere, otherwise it will crash.
|
||||
*/
|
||||
mCameraHal->SetAudioStreamCallback(nullptr);
|
||||
mCameraHal->SetVideoStreamCallback(nullptr);
|
||||
}
|
||||
}
|
||||
StatusCode MediaHandle::ExecuteTask(std::shared_ptr<VMediaTask> &task)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mMutex);
|
||||
|
@ -29,11 +66,18 @@ StatusCode MediaHandle::ExecuteTask(std::shared_ptr<VMediaTask> &task)
|
|||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
}
|
||||
}
|
||||
mStreamHandle = std::make_shared<SaveStream>();
|
||||
if (nullptr == mStreamHandle) {
|
||||
LogError("Create stream handle failed.\n");
|
||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
}
|
||||
mStreamHandle->Init();
|
||||
CameraTaskType taskType = TaskTypeConvert(task->GetTaskType());
|
||||
CameraTaskParam data(taskType);
|
||||
auto code = mCameraHal->StartSingleTask(data);
|
||||
if (IsCodeOK(code)) {
|
||||
mCurrentTask = task;
|
||||
StartTaskTimer();
|
||||
}
|
||||
else {
|
||||
LogError("Execute task failed.\n");
|
||||
|
@ -48,7 +92,53 @@ StatusCode MediaHandle::ClearTask(void)
|
|||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
void MediaHandle::StartTaskTimer(void)
|
||||
{
|
||||
auto taskTimerThread = [=](std::shared_ptr<MediaHandle> media) {
|
||||
LogInfo("StartTaskTimer start.\n");
|
||||
media->TaskTimer();
|
||||
};
|
||||
std::shared_ptr<MediaHandle> media = shared_from_this();
|
||||
mTaskTimerThread = std::thread(taskTimerThread, media);
|
||||
}
|
||||
void MediaHandle::TaskTimer(void)
|
||||
{
|
||||
constexpr int TASK_TIMER = 1000 * 10;
|
||||
mTaskRuning = true;
|
||||
while (mTaskRuning) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mCv.wait_for(lock, std::chrono::milliseconds(TASK_TIMER), [&] {
|
||||
return !mTaskRuning;
|
||||
});
|
||||
/**
|
||||
* @brief If the recording time is over, you need to stop the recording timer here.
|
||||
*/
|
||||
mTaskRuning = false;
|
||||
}
|
||||
if (mCameraHal) {
|
||||
mCameraHal->StopTask();
|
||||
}
|
||||
mMutex.lock();
|
||||
auto runingTask = mCurrentTask.lock();
|
||||
if (mCurrentTask.expired()) {
|
||||
LogWarning("SdCardHal: monitor is expired.\n");
|
||||
return;
|
||||
}
|
||||
LogInfo("Task finished response to application.\n");
|
||||
std::vector<MediaTaskResponse> responses;
|
||||
runingTask->Response(responses);
|
||||
mCurrentTask.reset();
|
||||
mMutex.unlock();
|
||||
}
|
||||
CameraTaskType MediaHandle::TaskTypeConvert(const MediaTaskType &type)
|
||||
{
|
||||
return CameraTaskType::END;
|
||||
}
|
||||
void MediaHandle::GetVideoStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
mStreamHandle->GetVideoStream(stream, length, timeStamp);
|
||||
}
|
||||
void MediaHandle::GetAudioStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
mStreamHandle->GetAudioStream(stream, length, timeStamp);
|
||||
}
|
|
@ -16,23 +16,41 @@
|
|||
#define MEDI_AHANDLE_H
|
||||
#include "IHalCpp.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "VStreamHandle.h"
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
using std::placeholders::_1;
|
||||
using std::placeholders::_2;
|
||||
using std::placeholders::_3;
|
||||
class MediaHandle : public VMediaHandle, public std::enable_shared_from_this<MediaHandle>
|
||||
{
|
||||
public:
|
||||
MediaHandle(const MediaChannel &mediaChannel, const std::shared_ptr<VCameraHal> &cameraHal);
|
||||
virtual ~MediaHandle() = default;
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
|
||||
protected:
|
||||
StatusCode ExecuteTask(std::shared_ptr<VMediaTask> &task) override;
|
||||
StatusCode StopTask(void) override;
|
||||
StatusCode ClearTask(void) override;
|
||||
|
||||
private:
|
||||
void StartTaskTimer(void);
|
||||
void TaskTimer(void);
|
||||
CameraTaskType TaskTypeConvert(const MediaTaskType &type);
|
||||
void GetVideoStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp);
|
||||
void GetAudioStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp);
|
||||
|
||||
private:
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mCv;
|
||||
const MediaChannel &mMediaChannel;
|
||||
std::shared_ptr<VCameraHal> mCameraHal;
|
||||
std::weak_ptr<VMediaTask> mCurrentTask;
|
||||
std::shared_ptr<VStreamHandle> mStreamHandle;
|
||||
bool mTaskRuning;
|
||||
std::thread mTaskTimerThread;
|
||||
};
|
||||
#endif
|
|
@ -13,8 +13,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "MediaManagerImpl.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "MediaHandle.h"
|
||||
#include "StatusCode.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
StatusCode MediaManagerImpl::Init(void)
|
||||
{
|
||||
IHalCpp::GetInstance()->GetCameraHal(mAllCameras);
|
||||
|
@ -23,6 +29,7 @@ StatusCode MediaManagerImpl::Init(void)
|
|||
}
|
||||
StatusCode MediaManagerImpl::UnInit(void)
|
||||
{
|
||||
UnInitMediaHandles();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode MediaManagerImpl::GetMediaChannel(const MediaChannel &channel, std::shared_ptr<VMediaHandle> &handle)
|
||||
|
@ -76,8 +83,21 @@ void MediaManagerImpl::InitMediaHandles(std::map<CameraType, std::shared_ptr<VCa
|
|||
continue;
|
||||
}
|
||||
MediaChannel channel = static_cast<MediaChannel>(i);
|
||||
std::shared_ptr<VMediaHandle> media = std::make_shared<MediaHandle>(channel, camera->second);
|
||||
std::shared_ptr<MediaHandle> media = std::make_shared<MediaHandle>(channel, camera->second);
|
||||
media->Init();
|
||||
mAllMediaChannels[channel] = media;
|
||||
LogInfo("InitMediaHandles. channel = %d \n", static_cast<MediaChannel>(i));
|
||||
}
|
||||
}
|
||||
void MediaManagerImpl::UnInitMediaHandles(void)
|
||||
{
|
||||
for (auto &media : mAllMediaChannels) {
|
||||
LogInfo("UnInitMediaHandles. channel = %d \n", media.first);
|
||||
std::shared_ptr<MediaHandle> mediaImpl = std::dynamic_pointer_cast<MediaHandle>(media.second);
|
||||
if (nullptr == mediaImpl) {
|
||||
LogWarning("mediaImpl is null.\n");
|
||||
continue;
|
||||
}
|
||||
mediaImpl->UnInit();
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ public:
|
|||
private:
|
||||
void SetCamerasMonitor(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras);
|
||||
void InitMediaHandles(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras);
|
||||
void UnInitMediaHandles(void);
|
||||
|
||||
private:
|
||||
std::map<CameraType, std::shared_ptr<VCameraHal>> mAllCameras;
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
#include "MediaManagerMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "MediaManagerImpl.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
bool CreateMediaManagerModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IMediaManager>();
|
||||
|
|
58
middleware/MediaManager/src/SaveStream.cpp
Normal file
58
middleware/MediaManager/src/SaveStream.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this mFileAudio 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "SaveStream.h"
|
||||
#include "ILog.h"
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
SaveStream::SaveStream() : mFileAudio(nullptr), mFileVideo(nullptr)
|
||||
{
|
||||
}
|
||||
void SaveStream::Init(void)
|
||||
{
|
||||
mFileAudio = fopen("/tmp/audio.g711", "a+"); // TODO:
|
||||
mFileVideo = fopen("/tmp/video.h264", "a+"); // TODO:
|
||||
}
|
||||
void SaveStream::UnInit(void)
|
||||
{
|
||||
if (mFileAudio) {
|
||||
fclose(mFileAudio);
|
||||
mFileAudio = nullptr;
|
||||
}
|
||||
if (mFileVideo) {
|
||||
fclose(mFileVideo);
|
||||
mFileVideo = nullptr;
|
||||
}
|
||||
}
|
||||
void SaveStream::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
if (mFileVideo) {
|
||||
size_t writeLength = fwrite(stream, 1, length, mFileVideo);
|
||||
if (writeLength != length) {
|
||||
LogError("Write video stream failed.\n");
|
||||
}
|
||||
fflush(mFileVideo);
|
||||
}
|
||||
}
|
||||
void SaveStream::GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
if (mFileAudio) {
|
||||
size_t writeLength = fwrite(stream, 1, length, mFileAudio);
|
||||
if (writeLength != length) {
|
||||
LogError("Write video stream failed.\n");
|
||||
}
|
||||
fflush(mFileAudio);
|
||||
}
|
||||
}
|
33
middleware/MediaManager/src/SaveStream.h
Normal file
33
middleware/MediaManager/src/SaveStream.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef SAVE_STREAM_H
|
||||
#define SAVE_STREAM_H
|
||||
#include "VStreamHandle.h"
|
||||
#include <cstdio>
|
||||
class SaveStream : public VStreamHandle
|
||||
{
|
||||
public:
|
||||
SaveStream();
|
||||
virtual ~SaveStream() = default;
|
||||
void Init(void) override;
|
||||
void UnInit(void) override;
|
||||
void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
|
||||
void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
|
||||
|
||||
private:
|
||||
FILE *mFileAudio;
|
||||
FILE *mFileVideo;
|
||||
};
|
||||
#endif
|
27
middleware/MediaManager/src/VStreamHandle.cpp
Normal file
27
middleware/MediaManager/src/VStreamHandle.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "VStreamHandle.h"
|
||||
void VStreamHandle::Init(void)
|
||||
{
|
||||
}
|
||||
void VStreamHandle::UnInit(void)
|
||||
{
|
||||
}
|
||||
void VStreamHandle::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
}
|
||||
void VStreamHandle::GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
|
||||
{
|
||||
}
|
27
middleware/MediaManager/src/VStreamHandle.h
Normal file
27
middleware/MediaManager/src/VStreamHandle.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef V_STREAM_HANDLE_H
|
||||
#define V_STREAM_HANDLE_H
|
||||
class VStreamHandle
|
||||
{
|
||||
public:
|
||||
VStreamHandle() = default;
|
||||
virtual ~VStreamHandle() = default;
|
||||
virtual void Init(void);
|
||||
virtual void UnInit(void);
|
||||
virtual void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
|
||||
virtual void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
|
||||
};
|
||||
#endif
|
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
#include "IStateMachine.h"
|
||||
#include "ILog.h"
|
||||
#include <thread>
|
||||
#include "StatusCode.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
std::string State::GetStateName()
|
||||
{
|
||||
return mStateName;
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "StateMachineImpl.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "StateMachineMakePtr.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
const StatusCode StateMachineImpl::CreateStateMachine(std::shared_ptr<VStateMachineHandle> &stateMachine)
|
||||
{
|
||||
return StateMachineMakePtr::GetInstance()->CreateStateMachine(stateMachine);
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
#include "ILog.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "StateMachineImpl.h"
|
||||
#include "StatusCode.h"
|
||||
#include "state_machine.h"
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
bool CreateStateMachine(void)
|
||||
{
|
||||
auto instance = std::make_shared<IStateMachine>();
|
||||
|
|
|
@ -12,4 +12,4 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "EmmcHandle.h"
|
||||
// #include "EmmcHandle.h"
|
|
@ -14,6 +14,9 @@
|
|||
*/
|
||||
#include "IStorageManager.h"
|
||||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
sd_card_info::sd_card_info() : mEvent(StorageEvent::END), mTotalSizeMB(0), mFreeSizeMB(0)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,8 +13,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "SdCardHandle.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include "IStorageManager.h"
|
||||
#include "LinuxApi.h"
|
||||
#include "StatusCode.h"
|
||||
#include "StorageBase.h"
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
void SdCardHandle::ReportEvent(const SdCardHalStatus &status)
|
||||
{
|
||||
LogInfo("SdCardHal: ReportEvent.\n");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user