diff --git a/middleware/McuManager/src/McuDevice.cpp b/middleware/McuManager/src/McuDevice.cpp index 664d3874..266d147b 100644 --- a/middleware/McuManager/src/McuDevice.cpp +++ b/middleware/McuManager/src/McuDevice.cpp @@ -220,7 +220,7 @@ void McuDevice::DeviceRecvData(const char *keyHead, const size_t headLength) dataLength - headLength - recvTotalLength, RECV_TIMEOUT_MS); if (recvLength > 0) { - PrintHexadecimalData(dataBuf, recvLength, "Recv data:"); + PrintHexadecimalData(dataBuf + headLength + recvTotalLength, recvLength, "Recv data:"); } recvTotalLength += recvLength; diff --git a/test/middleware/McuManager/src_mock/McuManager_AbnormalData_Test.cpp b/test/middleware/McuManager/src_mock/McuManager_AbnormalData_Test.cpp index 6a1d47ed..c6053663 100644 --- a/test/middleware/McuManager/src_mock/McuManager_AbnormalData_Test.cpp +++ b/test/middleware/McuManager/src_mock/McuManager_AbnormalData_Test.cpp @@ -22,14 +22,16 @@ const unsigned char McuRecvData[] = { 0xC1, 0x00, 0x03, 0x08, 0xEC, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x41, 0x07, 0x00, 0x0C, 0x35, 0x88, 0xFA, 0xC1, 0x00, 0x00, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x03, 0x08, 0xEC, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 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}; namespace McuManager_AbnormalData_Test { /** * @brief Construct a new test f object * ../output_files/test/bin/McuManagerTest - * --gtest_filter=McuManagerMockTest.HS_INTEGRATION_McuManager_AUTO_ProtocolLengthIsWrong + * --gtest_filter=McuManagerMockTest.HS_INTEGRATION_McuManager_EXAMPLE_ProtocolLengthIsWrong */ -TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_ProtocolLengthIsWrong) +TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_ProtocolLengthIsWrong) { IMcuManager::GetInstance()->Init(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -37,4 +39,17 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_ProtocolLengthIsWrong) 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_OtherSideGetDateTime + */ +TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_OtherSideGetDateTime) +{ + IMcuManager::GetInstance()->Init(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + McuManagerTestTool::MockOtherSideSendData(mLinuxTest, McuSendData_GetDateTime, sizeof(McuSendData_GetDateTime)); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + IMcuManager::GetInstance()->UnInit(); +} } // namespace McuManager_AbnormalData_Test \ No newline at end of file diff --git a/test/utils/McuProtocol/tool/src/McuProtocolTestTool.cpp b/test/utils/McuProtocol/tool/src/McuProtocolTestTool.cpp index 786d4861..94606321 100644 --- a/test/utils/McuProtocol/tool/src/McuProtocolTestTool.cpp +++ b/test/utils/McuProtocol/tool/src/McuProtocolTestTool.cpp @@ -209,7 +209,9 @@ void McuProtocolTestTool::ChecCRC16Code(const void *buf, const size_t &count) void McuProtocolTestTool::ResetCheckCode(const void *buf, const size_t &count) { short checkCode = calculate_check_sum((unsigned char *)buf, count - PROTOCOL_CHECK_CODE_LENGTH); - // checkCode = htons(checkCode); + if (ORDER_LITTLE_ENDIAN == ProtocolHandle::GetByteOrder()) { + checkCode = ntohs(checkCode); + } memcpy((unsigned char *)buf + count - PROTOCOL_CHECK_CODE_LENGTH, &checkCode, PROTOCOL_CHECK_CODE_LENGTH); } void McuProtocolTestTool::SelectInit(std::shared_ptr &mock, const int &uartFd) diff --git a/utils/McuProtocol/src/LittleEndianHandle.cpp b/utils/McuProtocol/src/LittleEndianHandle.cpp index 91a11b86..d6e848e0 100644 --- a/utils/McuProtocol/src/LittleEndianHandle.cpp +++ b/utils/McuProtocol/src/LittleEndianHandle.cpp @@ -45,10 +45,9 @@ void LittleEndianHandle::HostByteOrderConversion(ProtocolPacket &packet) } bool LittleEndianHandle::CheckoutTheCheckCode(const ProtocolPacket &packet) { - ProtocolHandle::PrintHexadecimalData( - mProtocolData, mProtocolDataLength - CHECK_CODE_LENGTH, "CheckoutTheCheckCode little endian:"); + ProtocolHandle::PrintHexadecimalData(&packet.mCheckCode, CHECK_CODE_LENGTH, "CheckoutTheCheckCode little endian:"); short code = calculate_check_sum(mProtocolData, mProtocolDataLength - sizeof(short)); - code = ntohs(code); // TODO: + // code = ntohs(code); // TODO: if (code == packet.mCheckCode) { return true; } diff --git a/utils/McuProtocol/src/ProtocolHandle.cpp b/utils/McuProtocol/src/ProtocolHandle.cpp index 9f3b9129..30e21960 100644 --- a/utils/McuProtocol/src/ProtocolHandle.cpp +++ b/utils/McuProtocol/src/ProtocolHandle.cpp @@ -284,8 +284,7 @@ void ProtocolHandle::AnalyzeOtherSideSendGetPirSensitivity(const ProtocolPacket } bool ProtocolHandle::CheckoutTheCheckCode(const ProtocolPacket &packet) { - ProtocolHandle::PrintHexadecimalData( - mProtocolData, mProtocolDataLength - CHECK_CODE_LENGTH, "CheckoutTheCheckCode:"); + ProtocolHandle::PrintHexadecimalData(&packet.mCheckCode, CHECK_CODE_LENGTH, "CheckoutTheCheckCode:"); short code = calculate_check_sum(mProtocolData, mProtocolDataLength - CHECK_CODE_LENGTH); if (code == packet.mCheckCode) { return true;