diff --git a/atest/terminated_fields.txt b/atest/terminated_fields.txt index 2f38bfe..a94e697 100644 --- a/atest/terminated_fields.txt +++ b/atest/terminated_fields.txt @@ -5,26 +5,28 @@ Suite teardown Reset Rammbock Resource Protocols.txt Default tags Regression -*** Variables *** -${default terminator}= 0x00 - - *** Test Cases *** Get message with chars and end byte - Message with chars and end byte + Message with chars and end byte 0x00 ${msg} get message arbitrary_length:foo.bar.zig Should be equal foo.bar.zig ${msg.arbitrary_length.ascii} should be equal as integers 12 ${msg.arbitrary_length.len} +Get message with chars and end byte long termination + Message with chars and end byte 0x0d0a + ${msg} get message arbitrary_length:foo.bar.zig + Should be equal foo.bar.zig ${msg.arbitrary_length.ascii} + Should be equal foo.bar.zig\r\n ${msg.arbitrary_length._raw} + should be equal as integers 13 ${msg.arbitrary_length.len} + Send and receive message with chars with end byte [tags] Setup TCP server and client Test - Message with chars and end byte + Message with chars and end byte 0x0d0a Client sends message arbitrary_length:foo.bar.zig ${msg}= Server receives message Should be equal foo.bar.zig ${msg.arbitrary_length.ascii} - should be equal as integers 12 ${msg.arbitrary_length.len} - + should be equal as integers 13 ${msg.arbitrary_length.len} *** Keywords *** Define protocol @@ -34,6 +36,7 @@ Define protocol end protocol Message with chars and end byte + [Arguments] ${terminator} new message ExampleMessage Test - chars * arbitrary_length ${none} terminator=${default terminator} + chars * arbitrary_length ${none} terminator=${terminator} uint 8 some_integer 0x00 diff --git a/src/Rammbock/templates/primitives.py b/src/Rammbock/templates/primitives.py index 2aed91f..80630b9 100644 --- a/src/Rammbock/templates/primitives.py +++ b/src/Rammbock/templates/primitives.py @@ -207,7 +207,7 @@ def _encode_value(self, value, message, little_endian=False): def _prepare_data(self, data): if self._terminator: - return data[0:data.index(self._terminator) + 1] + return data[0:data.index(self._terminator) + len(self._terminator)] return data