Improve:OnMissionState.
This commit is contained in:
		
							parent
							
								
									19247f0646
								
							
						
					
					
						commit
						88ea6411b9
					
				| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
#include "MissionManagerMakePtr.h"
 | 
			
		||||
#include "ILog.h"
 | 
			
		||||
#include "MissionManager.h"
 | 
			
		||||
#include "OnMissionState.h"
 | 
			
		||||
#include "SdCardHandleState.h"
 | 
			
		||||
#include "StorageHandleState.h"
 | 
			
		||||
#include "TestMissionState.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +64,23 @@ std::shared_ptr<State> MissionManagerMakePtr::CreateTopState(void)
 | 
			
		|||
}
 | 
			
		||||
std::shared_ptr<State> MissionManagerMakePtr::CreateMissionState(const IpcMission &mission)
 | 
			
		||||
{
 | 
			
		||||
    std::shared_ptr<State> state = std::make_shared<TestMissionState>();
 | 
			
		||||
    LogInfo("MissionManagerMakePtr::CreateMissionState\n");
 | 
			
		||||
    std::shared_ptr<State> state;
 | 
			
		||||
    switch (mission) {
 | 
			
		||||
    case IpcMission::TEST:
 | 
			
		||||
        LogInfo("Create TestMissionState.\n");
 | 
			
		||||
        state = std::make_shared<TestMissionState>();
 | 
			
		||||
        break;
 | 
			
		||||
    case IpcMission::ON:
 | 
			
		||||
        LogInfo("Create OnMissionState.\n");
 | 
			
		||||
        state = std::make_shared<OnMissionState>();
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
        LogWarning("Unknown mission.\n");
 | 
			
		||||
        state = std::make_shared<TestMissionState>();
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    return state;
 | 
			
		||||
}
 | 
			
		||||
std::shared_ptr<State> MissionManagerMakePtr::CreateStorageHandleState(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,7 +85,8 @@ IpcMission MissionStateMachine::GetStartMission(void)
 | 
			
		|||
}
 | 
			
		||||
void MissionStateMachine::RunStateMachine(const IpcMission &mission)
 | 
			
		||||
{
 | 
			
		||||
    LogInfo("Make all states and start the state machine.\n");
 | 
			
		||||
    LogInfo("Make all states and start the state machine, ipc mission = %s.\n",
 | 
			
		||||
            IMcuManager::GetInstance()->PrintIpcMissionString(mission));
 | 
			
		||||
    mStateTree[SystemState::TOP_STATE] = MissionManagerMakePtr::GetInstance()->CreateTopState();
 | 
			
		||||
    mStateTree[SystemState::MISSION_STATE] = MissionManagerMakePtr::GetInstance()->CreateMissionState(mission);
 | 
			
		||||
    mStateTree[SystemState::STORAGE_HANDLE_STATE] = MissionManagerMakePtr::GetInstance()->CreateStorageHandleState();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										37
									
								
								application/MissionManager/src/OnMissionState.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								application/MissionManager/src/OnMissionState.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 "OnMissionState.h"
 | 
			
		||||
#include "ILog.h"
 | 
			
		||||
#include "IStorageManager.h"
 | 
			
		||||
#include "MissionStateMachine.h"
 | 
			
		||||
OnMissionState::OnMissionState() : MissionState("OnMissionState")
 | 
			
		||||
{
 | 
			
		||||
    // mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] =
 | 
			
		||||
    //     std::bind(&OnMissionState::SdCardEventReportSendToApp, this, _1);
 | 
			
		||||
}
 | 
			
		||||
void OnMissionState::GoInState()
 | 
			
		||||
{
 | 
			
		||||
    MissionState::GoInState();
 | 
			
		||||
    LogInfo(" ========== OnMissionState::GoInState.\n");
 | 
			
		||||
}
 | 
			
		||||
void OnMissionState::GoOutState()
 | 
			
		||||
{
 | 
			
		||||
    MissionState::GoOutState();
 | 
			
		||||
    LogInfo(" ========== OnMissionState::GoOutState.\n");
 | 
			
		||||
}
 | 
			
		||||
bool OnMissionState::SdCardEventReportSendToApp(VStateMachineData *msg)
 | 
			
		||||
{
 | 
			
		||||
    return EXECUTED;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								application/MissionManager/src/OnMissionState.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								application/MissionManager/src/OnMissionState.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,31 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 ON_MISSION_STATE_H
 | 
			
		||||
#define ON_MISSION_STATE_H
 | 
			
		||||
#include "IStateMachine.h"
 | 
			
		||||
#include "IStorageManager.h"
 | 
			
		||||
#include "MissionState.h"
 | 
			
		||||
class OnMissionState : public MissionState
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    OnMissionState();
 | 
			
		||||
    virtual ~OnMissionState() = default;
 | 
			
		||||
    void GoInState() override;
 | 
			
		||||
    void GoOutState() override;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    bool SdCardEventReportSendToApp(VStateMachineData *msg);
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,9 @@
 | 
			
		|||
# 1. 打猎相机APP(WiFi单机版)设计文档
 | 
			
		||||
 | 
			
		||||
| 版本 | 时间 | 说明 |
 | 
			
		||||
| ---- | ---- | ---- |
 | 
			
		||||
| V1.0 | 2024-5-21 | 首次评审。 |
 | 
			
		||||
 | 
			
		||||
## 1.1. 概述
 | 
			
		||||
 | 
			
		||||
    打猎相机手机APP是用于查看相机的实时视频,回放保存在SD卡的MP4视频文件,以及对相机进行设置/管理。
 | 
			
		||||
| 
						 | 
				
			
			@ -152,3 +156,14 @@
 | 
			
		|||
| 时间 | 时间 | ---- | 设置时间 |
 | 
			
		||||
| 功能 | 功能按钮 | 取消/确定 | 例如:格式化/恢复出厂/重启<br>可通过协议自由定义,协议带显示字符 |
 | 
			
		||||
| 选项 | 数字 | ---- | 协议带选项对应的文字字符 |
 | 
			
		||||
 | 
			
		||||
### 1.4.2. 动态渲染设置界面
 | 
			
		||||
 | 
			
		||||
1. APP获取设置参数列表,协议根据设置类型定义;
 | 
			
		||||
2. 设置界面根据设置类型显示设置控件;
 | 
			
		||||
3. 有操作后回传自定义控件信息;
 | 
			
		||||
4. 设备根据协议解析操作的控件,并执行自定义行为;
 | 
			
		||||
 | 
			
		||||
### 1.4.3. 拓展规划
 | 
			
		||||
 | 
			
		||||
  需要考虑拓展为4G版本。
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ bool DestroyMcuManager(void);
 | 
			
		|||
enum class IpcMission
 | 
			
		||||
{
 | 
			
		||||
    PIR_TRIGGERED = 0,
 | 
			
		||||
    ON,
 | 
			
		||||
    TEST,
 | 
			
		||||
    CONTINUOUS_SHOOTING,
 | 
			
		||||
    PIR_TRIGGERED_DELAY,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -135,6 +135,9 @@ const char *McuManagerImpl::PrintIpcMissionString(const IpcMission &mission)
 | 
			
		|||
    case IpcMission::PIR_TRIGGERED: {
 | 
			
		||||
        return "PIR_TRIGGERED";
 | 
			
		||||
    }
 | 
			
		||||
    case IpcMission::ON: {
 | 
			
		||||
        return "ON";
 | 
			
		||||
    }
 | 
			
		||||
    case IpcMission::TEST: {
 | 
			
		||||
        return "TEST";
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,19 +27,28 @@ namespace McuManager_Mock_Test
 | 
			
		|||
/**
 | 
			
		||||
 * @brief Construct a new test f object
 | 
			
		||||
 * ../output_files/test/bin/HuntingCameraTest
 | 
			
		||||
 * --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_EXAMPLE_UartOpenSuccessButReadNothing
 | 
			
		||||
 * --gtest_filter=HuntingCameraTest.HS_INTEGRATION_HunttingCamera_EXAMPLE_UartOpenSuccessButReadNothing
 | 
			
		||||
 */
 | 
			
		||||
TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_EXAMPLE_UartOpenSuccessButReadNothing)
 | 
			
		||||
TEST_F(HuntingCameraTest, HS_INTEGRATION_HunttingCamera_EXAMPLE_UartOpenSuccessButReadNothing)
 | 
			
		||||
{
 | 
			
		||||
    // SetAllCamerasResult(mAllCamerasMock);
 | 
			
		||||
    // MockReportCameraEvent("/tmp/test.MP4", CameraType::MAIN_CAMERA);
 | 
			
		||||
    // CreateUpgradeFile();
 | 
			
		||||
    McuManagerTestTool::MockMcuDeviceOpenSuccessButReadNothing(mLinuxTest);
 | 
			
		||||
    // std::this_thread::sleep_for(std::chrono::milliseconds(100));
 | 
			
		||||
    MainThread::GetInstance()->Init();
 | 
			
		||||
    TestManager::ResetTimeOut(1000 * 6);
 | 
			
		||||
    TestManager::ResetTimeOut(1000 * 3);
 | 
			
		||||
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
 | 
			
		||||
    MainThread::GetInstance()->Runing();
 | 
			
		||||
    RemoveUpgradeFile();
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Construct a new test f object
 | 
			
		||||
 * ../output_files/test/bin/HuntingCameraTest
 | 
			
		||||
 * --gtest_filter=HuntingCameraTest.HS_INTEGRATION_HunttingCamera_EXAMPLE_OnMissionStateStart
 | 
			
		||||
 */
 | 
			
		||||
TEST_F(HuntingCameraTest, HS_INTEGRATION_HunttingCamera_EXAMPLE_OnMissionStateStart)
 | 
			
		||||
{
 | 
			
		||||
    McuManagerTestTool::MockOtherSideIpcMissionReply(IpcMission::ON);
 | 
			
		||||
    MainThread::GetInstance()->Init();
 | 
			
		||||
    TestManager::ResetTimeOut(1000 * 3);
 | 
			
		||||
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
 | 
			
		||||
    MainThread::GetInstance()->Runing();
 | 
			
		||||
}
 | 
			
		||||
} // namespace McuManager_Mock_Test
 | 
			
		||||
| 
						 | 
				
			
			@ -14,6 +14,7 @@
 | 
			
		|||
 */
 | 
			
		||||
#include "MissionManagerMakePtrTest.h"
 | 
			
		||||
#include "ILog.h"
 | 
			
		||||
#include "OnMissionStateMock.h"
 | 
			
		||||
#include "TestMissionStateMock.h"
 | 
			
		||||
#include "TopStateMock.h"
 | 
			
		||||
void OverrideMissionManagerMakePtrObject(std::shared_ptr<MissionManagerMock> &appManagerMock)
 | 
			
		||||
| 
						 | 
				
			
			@ -51,6 +52,22 @@ std::shared_ptr<State> MissionManagerMakePtrTest::CreateTopState(void)
 | 
			
		|||
}
 | 
			
		||||
std::shared_ptr<State> MissionManagerMakePtrTest::CreateMissionState(const IpcMission &mission)
 | 
			
		||||
{
 | 
			
		||||
    std::shared_ptr<State> state = std::make_shared<TestMissionStateMock>();
 | 
			
		||||
    LogInfo("MissionManagerMakePtrTest::CreateMissionState\n");
 | 
			
		||||
    std::shared_ptr<State> state;
 | 
			
		||||
    switch (mission) {
 | 
			
		||||
    case IpcMission::TEST:
 | 
			
		||||
        LogInfo("Create TestMissionStateMock.\n");
 | 
			
		||||
        state = std::make_shared<TestMissionStateMock>();
 | 
			
		||||
        break;
 | 
			
		||||
    case IpcMission::ON:
 | 
			
		||||
        LogInfo("Create OnMissionStateMock.\n");
 | 
			
		||||
        state = std::make_shared<OnMissionStateMock>();
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
        LogWarning("Unknown mission.\n");
 | 
			
		||||
        state = std::make_shared<TestMissionStateMock>();
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    return state;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 "OnMissionStateMock.h"
 | 
			
		||||
#include "ILog.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -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 ON_MISSION_STATE_MOCK_H
 | 
			
		||||
#define ON_MISSION_STATE_MOCK_H
 | 
			
		||||
#include "MissionManagerTestTool.h"
 | 
			
		||||
#include "OnMissionState.h"
 | 
			
		||||
class OnMissionStateTest : public OnMissionState
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    OnMissionStateTest() = default;
 | 
			
		||||
    virtual ~OnMissionStateTest() = default;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
};
 | 
			
		||||
class OnMissionStateMock : public OnMissionStateTest
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    OnMissionStateMock() = default;
 | 
			
		||||
    virtual ~OnMissionStateMock() = default;
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -304,7 +304,7 @@ void AppManagerTestTool::AppManagerMockInit(std::shared_ptr<IAppManager> &vMock)
 | 
			
		|||
        AppManagerTestTool::AppMonitorInit(mAppMonitorMock);
 | 
			
		||||
    };
 | 
			
		||||
    EXPECT_CALL(*mock.get(), SetAppMonitorTrace(_))
 | 
			
		||||
        .Times(ONLY_BE_CALLED_ONCE)
 | 
			
		||||
        .Times(testing::Between(0, 1))
 | 
			
		||||
        .WillOnce(DoAll(WithArgs<0>(Invoke(getAppMonitor)), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
 | 
			
		||||
}
 | 
			
		||||
std::shared_ptr<VAppMonitor> AppManagerTestTool::MakeMonitorMock(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,8 @@ const unsigned char McuRecvData[] = {
 | 
			
		|||
    0x41, 0x07, 0x00, 0x0C, 0x35, 0x88, 0xFA, 0xC1, 0x00, 0x00, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A};
 | 
			
		||||
const unsigned char McuSendData_GetDateTime[] = {
 | 
			
		||||
    0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x41, 0x07, 0x00, 0x0C, 0x35, 0x88};
 | 
			
		||||
const unsigned char McuSendData_OtherSideReplyGetIpcMission[] = {
 | 
			
		||||
    0xFA, 0xC1, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x0D, 0x03, 0x09, 0xBA};
 | 
			
		||||
namespace McuManager_AbnormalData_Test
 | 
			
		||||
{
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -52,4 +54,18 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_OtherSideGetDateTim
 | 
			
		|||
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
 | 
			
		||||
    IMcuManager::GetInstance()->UnInit();
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Construct a new test f object
 | 
			
		||||
 * ../output_files/test/bin/McuManagerTest
 | 
			
		||||
 * --gtest_filter=McuManagerMockTest.HS_INTEGRATION_McuManager_EXAMPLE_OtherSideReplyGetIpcMission
 | 
			
		||||
 */
 | 
			
		||||
TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_OtherSideReplyGetIpcMission)
 | 
			
		||||
{
 | 
			
		||||
    IMcuManager::GetInstance()->Init();
 | 
			
		||||
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
 | 
			
		||||
    McuManagerTestTool::MockOtherSideSendData(
 | 
			
		||||
        mLinuxTest, McuSendData_OtherSideReplyGetIpcMission, sizeof(McuSendData_OtherSideReplyGetIpcMission));
 | 
			
		||||
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
 | 
			
		||||
    IMcuManager::GetInstance()->UnInit();
 | 
			
		||||
}
 | 
			
		||||
} // namespace McuManager_AbnormalData_Test
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +44,7 @@ protected:
 | 
			
		|||
    void MockOtherSideSendData(std::shared_ptr<LinuxTest> &mock, const void *data, const size_t &size);
 | 
			
		||||
    void MockMcuDeviceOpenFailed(std::shared_ptr<LinuxTest> &mock);
 | 
			
		||||
    void MockMcuDeviceOpenSuccessButReadNothing(std::shared_ptr<LinuxTest> &mock);
 | 
			
		||||
    void MockOtherSideIpcMissionReply(const IpcMission &replyIpcMission);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    std::shared_ptr<McuManagerImplTest> mMcuManagerMock;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,4 +77,9 @@ void McuManagerTestTool::MockMcuDeviceOpenFailed(std::shared_ptr<LinuxTest> &moc
 | 
			
		|||
void McuManagerTestTool::MockMcuDeviceOpenSuccessButReadNothing(std::shared_ptr<LinuxTest> &mock)
 | 
			
		||||
{
 | 
			
		||||
    McuProtocolTestTool::ReadNothingAnyTime(mock);
 | 
			
		||||
}
 | 
			
		||||
void McuManagerTestTool::MockOtherSideIpcMissionReply(const IpcMission &replyIpcMission)
 | 
			
		||||
{
 | 
			
		||||
    unsigned char reply = static_cast<unsigned char>(replyIpcMission);
 | 
			
		||||
    McuProtocolTestTool::MockOtherSideIpcMissionReply(reply);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -39,8 +39,10 @@ public:
 | 
			
		|||
    void MockOtherSideAskSendAnyData(std::shared_ptr<LinuxTest> &mock, const void *data, const size_t &size);
 | 
			
		||||
    void ReadNothingAnyTime(std::shared_ptr<LinuxTest> &mock);
 | 
			
		||||
    void ReadOnceSelectSucceed(std::shared_ptr<LinuxTest> &mock, const int &uartFd);
 | 
			
		||||
    void MockOtherSideIpcMissionReply(const unsigned char &replyIpcMission);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void InitProtocolBuff(void);
 | 
			
		||||
    void CheckSerialNumber(const void *buf, const size_t &count);
 | 
			
		||||
    void ChecCRC16Code(const void *buf, const size_t &count);
 | 
			
		||||
    void ResetCheckCode(const void *buf, const size_t &count);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,6 +39,7 @@ constexpr size_t PROTOCOL_DATA_LENGTH_OFFSET = PROTOCOL_COMMAND_OFFSET + PROTOCO
 | 
			
		|||
constexpr size_t PROTOCOL_CHECK_CODE_LENGTH = sizeof(short);
 | 
			
		||||
constexpr size_t PROTOCOL_DATA_KEY_HEAD_LENGTH =
 | 
			
		||||
    PROTOCOL_HEAD_LENGTH + PROTOCOL_SERIAL_NUMBER_LENGTH + PROTOCOL_COMMAND_LENGTH + PROTOCOL_DATA_LENGTH_LENGTH;
 | 
			
		||||
constexpr size_t PROTOCOL_DATA_OFFSET = PROTOCOL_DATA_KEY_HEAD_LENGTH;
 | 
			
		||||
unsigned char ASK_IPC_MISSION_X[] = {0xFA, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x81, 0x01, 0x00, 0x0C, 0xFF, 0xFF};
 | 
			
		||||
unsigned char REPLY_IPC_MISSION_X[] = {0xFA, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x0D, 0x01, 0xFF, 0xFF};
 | 
			
		||||
unsigned char ASK_CUT_OFF_POWER_SUPPLY_X[] = {0xFA, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x81, 0x02, 0x00, 0x0C, 0xFF, 0xFF};
 | 
			
		||||
| 
						 | 
				
			
			@ -129,6 +130,7 @@ void McuProtocolTestTool::Init(std::shared_ptr<LinuxTest> &mock, const UartInfo
 | 
			
		|||
        .WillRepeatedly(
 | 
			
		||||
            DoAll(SaveArg<2>(&WRITE_COUNT), WithArgs<0, 1, 2>(Invoke(api_write)), ReturnPointee(&WRITE_COUNT)));
 | 
			
		||||
    SelectInit(mock, mUartFd);
 | 
			
		||||
    InitProtocolBuff();
 | 
			
		||||
}
 | 
			
		||||
void McuProtocolTestTool::UnInit(void)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -190,6 +192,10 @@ void McuProtocolTestTool::ReadNothingAnyTime(std::shared_ptr<LinuxTest> &mock)
 | 
			
		|||
        LogWarning("mUart is null.\n");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
void McuProtocolTestTool::InitProtocolBuff(void)
 | 
			
		||||
{
 | 
			
		||||
    REPLY_IPC_MISSION_X[PROTOCOL_DATA_OFFSET] = 0x01;
 | 
			
		||||
}
 | 
			
		||||
void McuProtocolTestTool::CheckSerialNumber(const void *buf, const size_t &count)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int serialNumber = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -341,6 +347,10 @@ void McuProtocolTestTool::ReadOnceSelectSucceed(std::shared_ptr<LinuxTest> &mock
 | 
			
		|||
        .WillRepeatedly(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectTimeOut)), Return(MOCK_SELECT_TIME_OUT)));
 | 
			
		||||
    PipeSelectTimeoutForProtocolHandleImmediately();
 | 
			
		||||
}
 | 
			
		||||
void McuProtocolTestTool::MockOtherSideIpcMissionReply(const unsigned char &replyIpcMission)
 | 
			
		||||
{
 | 
			
		||||
    REPLY_IPC_MISSION_X[PROTOCOL_DATA_OFFSET] = replyIpcMission;
 | 
			
		||||
}
 | 
			
		||||
void McuProtocolTestTool::ReplySelectTimeOut(std::shared_ptr<LinuxTest> &mock, const int &uartFd)
 | 
			
		||||
{
 | 
			
		||||
    if (mUart) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user