You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/07/28 09:23:31 UTC
[plc4x] branch develop updated: - Fixed one little issue with
firing errors when reading too much - Commented in a test that strangely
stopped failing
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 6cfdf0e - Fixed one little issue with firing errors when reading too much - Commented in a test that strangely stopped failing
6cfdf0e is described below
commit 6cfdf0e6835b5940e6596083f6e00927d6144167
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Jul 28 11:23:24 2020 +0200
- Fixed one little issue with firing errors when reading too much
- Commented in a test that strangely stopped failing
---
sandbox/plc4c/drivers/s7/test/s7_test.c | 11 ++++++++---
sandbox/plc4c/spi/src/read_buffer.c | 4 ++++
sandbox/plc4c/spi/test/read_buffer_test.c | 3 +--
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/sandbox/plc4c/drivers/s7/test/s7_test.c b/sandbox/plc4c/drivers/s7/test/s7_test.c
index f8a302f..db92b4a 100644
--- a/sandbox/plc4c/drivers/s7/test/s7_test.c
+++ b/sandbox/plc4c/drivers/s7/test/s7_test.c
@@ -21,12 +21,18 @@
#include "plc4c/spi/read_buffer.h"
#include "tpkt_packet.h"
-void internal_assert_arrays_equal(const uint8_t* expected_array,
+void internal_assert_arrays_equal(uint8_t* expected_array,
plc4c_spi_write_buffer* write_buffer,
uint8_t num_bytes) {
for (int i = 0; i < num_bytes; i++) {
uint8_t expected_value = *(expected_array + i);
uint8_t actual_value = *(write_buffer->data + i);
+ // Needed for debugging on remote machines: Output the entire arrays content.
+ if(expected_value != actual_value) {
+ for(int j = 0; j < num_bytes; j++) {
+ printf("E=%02X %s A=%02X", expected_value, (*(expected_array + j) != *(write_buffer->data + j) ? "!=" : "=="), actual_value);
+ }
+ }
TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected_value, actual_value, "Byte arrays differ");
}
}
@@ -217,8 +223,7 @@ int main(void) {
RUN_TEST(parse_s7_communication_setup_request);
RUN_TEST(parse_s7_communication_setup_response);
RUN_TEST(parse_s7_read_plc_type_request);
- // TODO: This seems to fail only when being run from Maven
- //RUN_TEST(parse_s7_read_plc_type_response);
+ RUN_TEST(parse_s7_read_plc_type_response);
RUN_TEST(parse_s7_read_request);
RUN_TEST(parse_s7_read_response);
RUN_TEST(parse_s7_read_error_response);
diff --git a/sandbox/plc4c/spi/src/read_buffer.c b/sandbox/plc4c/spi/src/read_buffer.c
index 4d45fbf..790b899 100644
--- a/sandbox/plc4c/spi/src/read_buffer.c
+++ b/sandbox/plc4c/spi/src/read_buffer.c
@@ -57,6 +57,10 @@ plc4c_return_code plc4c_spi_read_unsigned_bits_internal(
if (buf == NULL) {
return NULL_VALUE;
}
+ // Check if there are enough bytes in total left.
+ if (!plc4c_spi_read_has_more(buf, num_bits)) {
+ return OUT_OF_RANGE;
+ }
// If the bit-offset is currently 0 and we're reading
// a full byte, go this shortcut.
diff --git a/sandbox/plc4c/spi/test/read_buffer_test.c b/sandbox/plc4c/spi/test/read_buffer_test.c
index ba07957..c7ef266 100644
--- a/sandbox/plc4c/spi/test/read_buffer_test.c
+++ b/sandbox/plc4c/spi/test/read_buffer_test.c
@@ -349,8 +349,7 @@ void test_plc4c_spi_read_unsigned_short(void) {
test_plc4c_spi_read_unsigned_short_args("Short only reading 14 bits", read_buffer, 14, OK, 1543);
// We only have 8 bytes, so with this we would exceed the range.
- // TODO: This should fail ...
- //test_plc4c_spi_read_unsigned_short_args("Try to read mode bytes than the buffer has available", read_buffer, 16, OUT_OF_RANGE, 0);
+ test_plc4c_spi_read_unsigned_short_args("Try to read mode bytes than the buffer has available", read_buffer, 16, OUT_OF_RANGE, 0);
test_plc4c_spi_read_unsigned_short_args("Try to read too many bytes for a short", read_buffer, 18, OUT_OF_RANGE, 0);
}