Skip to content

Python OSITrace method get_messages_in_index_range() ignores arguments for *.osi format #426

@tpajenkamp-dspace

Description

@tpajenkamp-dspace

Describe the bug

In the Python OSI Trace reader (format/OSITrace.py), when using the binary OSI trace format (type_name=None), the method get_messages_in_index_range(bening, end) ignores the arguments begin and end. Instead, it always returns an iterator over all messages. Because of that, the method get_message_by_index(index) always returns the first message regardless of the index argument.

Describe how to reproduce the bug

Steps to reproduce the behavior:

tr = OSITrace()
tr.from_file("MySensorViewTrace.osi")
l = list(tr.get_messages_in_index_range(10, 12))
m = tr.get_message_by_index(5)

l contains all message instead of messages 10, 11 and 12, m is message 0 instead if message 5.

Describe the expected behavior

l contains only the messages 10, 11 and 12 (or at least a documentation that it does not work as expected).

Describe the OS you are using

  • OS: Windows 10
  • Python 3.6.8 64-bit

Additional context

Possible fix:

  1. In the "OSI"-branch of the method, replace self.scenario_file.seek(0) with self.scenario_file.seek(self.message_offsets[begin])
  2. in the while loop condition, end with min(len(serialized_message), self.message_offsets[end+1]) (requires additional index range check for self.message_offsets)

Metadata

Metadata

Assignees

Labels

BugProblems in the build system, build scripts, etc or faults in the interface.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions