sefl test for tuyamcu calibration

This commit is contained in:
Tester23
2025-06-17 17:45:20 +02:00
parent e663cf5d30
commit 901a43ceaf
3 changed files with 55 additions and 1 deletions

View File

@ -76,7 +76,8 @@ void Test_TwoPWMsOneChannel();
void Test_ClockEvents();
void Test_Commands_Channels();
void Test_LEDDriver();
void Test_TuyaMCU_Basic();
void Test_TuyaMCU_Basic();
void Test_TuyaMCU_Calib();
void Test_TuyaMCU_Boolean();
void Test_TuyaMCU_DP22();
void Test_TuyaMCU_Mult();

View File

@ -667,5 +667,57 @@ void Test_TuyaMCU_Basic() {
SIM_ClearUART();
}
void Test_TuyaMCU_Calib() {
{
// reset whole device
SIM_ClearOBK(0);
SIM_UART_InitReceiveRingBuffer(2048);
CMD_ExecuteCommand("startDriver TuyaMCU", 0);
g_cfg.pins.channelTypes[3] = ChType_Voltage_div10;
g_cfg.pins.channelTypes[7] = ChType_Current_div1000;
g_cfg.pins.channelTypes[9] = ChType_Power;
CMD_ExecuteCommand("linkTuyaMCUOutputToChannel 113 RAW_VCPPfF", 0);
CMD_ExecuteCommand("uartFakeHex 55 AA 03 07 00 13 71 00 00 0F 09 29 00 01 B7 00 03 FC 00 00 00 03 E8 C3 32 65", 0);
// above command will just put into buffer - need at least a frame to parse it
Sim_RunFrames(100, false);
SELFTEST_ASSERT_CHANNEL(3, 2345);
SELFTEST_ASSERT_CHANNEL(7, 439);
SELFTEST_ASSERT_CHANNEL(9, 1020);
SIM_ClearUART();
}
{
// reset whole device
SIM_ClearOBK(0);
SIM_UART_InitReceiveRingBuffer(2048);
CMD_ExecuteCommand("startDriver TuyaMCU", 0);
g_cfg.pins.channelTypes[3] = ChType_Voltage_div10;
g_cfg.pins.channelTypes[7] = ChType_Current_div1000;
g_cfg.pins.channelTypes[9] = ChType_Power;
CMD_ExecuteCommand("linkTuyaMCUOutputToChannel 113 RAW_VCPPfF -1 0 1 0 22 33 44", 0);
CMD_ExecuteCommand("uartFakeHex 55 AA 03 07 00 13 71 00 00 0F 09 29 00 01 B7 00 03 FC 00 00 00 03 E8 C3 32 65", 0);
// above command will just put into buffer - need at least a frame to parse it
Sim_RunFrames(100, false);
SELFTEST_ASSERT_CHANNEL(3, 2345+22);
SELFTEST_ASSERT_CHANNEL(7, 439+33);
SELFTEST_ASSERT_CHANNEL(9, 1020+44);
SIM_ClearUART();
}
}
#endif

View File

@ -190,6 +190,7 @@ void Win_DoUnitTests() {
#if ENABLE_BL_SHARED
Test_EnergyMeter();
#endif
Test_TuyaMCU_Calib();
// this is slowest
Test_TuyaMCU_Basic();
Test_TuyaMCU_Mult();