Fix wrong calculation of frames in bacapp_data_len (#491)

* Fixed wrong calculation of data length.  In cases when 2 sets of opening & closing tags (first opening tag context tag is 3, second is 0) were sent, one of the frames wasn't added, and the resulted sum was wrong

* Added unit test for case with two sets of opening & closing tags
This commit is contained in:
bakmaria
2023-09-11 16:41:06 +02:00
committed by GitHub
parent 55b8b3d93c
commit e4dd30ed89
2 changed files with 19 additions and 0 deletions
+17
View File
@@ -811,6 +811,23 @@ static void testBACnetApplicationDataLength(void)
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_REQUESTED_SHED_LEVEL);
zassert_equal(test_len, len, NULL);
/* 7. context opening & closing tag */
test_len = 0;
apdu_len = 0;
len = encode_opening_tag(&apdu[apdu_len], 3);
apdu_len += len;
len = encode_opening_tag(&apdu[apdu_len], 0);
apdu_len += len;
test_len += len;
len = encode_closing_tag(&apdu[apdu_len], 0);
apdu_len += len;
test_len += len;
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_WEEKLY_SCHEDULE);
zassert_equal(test_len, len, NULL);
}
/**