Skip to content

Commit d2e263b

Browse files
committed
fix(cc): Fix meter_control_test check on frame without cmd
Also fix related test, to always fail: 102 - zwave_command_class_meter_control_test (Failed) For some reason I dont remember seeing it failed despite the read should be invalid, this should be triggered by CI Origin: SiliconLabsSoftware#117 Relate-to: SiliconLabsSoftware#110 (comment) Relate-to: SiliconLabsSoftware#111 (comment) Thanks-to: Laudin Molina Troconis <[email protected]> Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#10 Signed-off-by: Philippe Coval <[email protected]>
1 parent c94518e commit d2e263b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

applications/zpc/components/zwave_command_classes/src/zwave_command_class_meter_control.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ static sl_status_t zwave_command_class_meter_control_handler(
742742
const uint8_t *frame,
743743
uint16_t frame_length)
744744
{
745-
if (frame_length < COMMAND_INDEX) {
745+
if (frame_length <= COMMAND_INDEX) {
746746
return SL_STATUS_NOT_SUPPORTED;
747747
}
748748

@@ -823,4 +823,4 @@ sl_status_t zwave_command_class_meter_control_init()
823823
zwave_command_handler_register_handler(handler);
824824

825825
return SL_STATUS_OK;
826-
}
826+
}

applications/zpc/components/zwave_command_classes/test/zwave_command_class_meter_control_test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,13 +854,16 @@ void test_meter_report_too_short()
854854
void test_meter_command_class_no_command()
855855
{
856856
// Simulate a frame
857-
const uint8_t incoming_frame[] = {COMMAND_CLASS_METER};
857+
const uint8_t incoming_frame[] = {COMMAND_CLASS_METER,
858+
METER_REPORT_V5, // Add deterministic valid value for overflow check
859+
};
858860

859861
TEST_ASSERT_NOT_NULL(meter_handler.control_handler);
860862
TEST_ASSERT_EQUAL(SL_STATUS_NOT_SUPPORTED,
861863
meter_handler.control_handler(&info,
862864
incoming_frame,
863-
sizeof(incoming_frame)));
865+
sizeof(incoming_frame) -1 // Remove padding
866+
));
864867
}
865868

866869
void test_supported_rate_types_unknown_values()

0 commit comments

Comments
 (0)