Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions dlt/core/core_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def payload_decoded(self):
if self.is_mode_non_verbose and not self.is_type_control and self.noar == 0:
buf = ctypes.create_string_buffer('\000' * DLT_DAEMON_TEXTSIZE)
dltlib.dlt_message_payload(ctypes.byref(self), buf, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, self.verbose)
return b"[{}] #{}#".format(self.message_id_string, buf.value[4:])
return b"[%s] #%s#" % (self.message_id_string, buf.value[4:].rstrip(b'\000'))

if self.type == DLT_TYPE_CONTROL and self.subtype == DLT_CONTROL_RESPONSE:
if self.ctrl_service_id == DLT_SERVICE_ID_MARKER:
Expand All @@ -286,7 +286,7 @@ def payload_decoded(self):
service_id = self.ctrl_service_id

if self.ctrl_service_id == DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
text += ctypes.string_at(self.databuffer, self.datasize)[9:]
text += ctypes.string_at(self.databuffer, self.datasize)[9:].rstrip(b'\000')
elif self.ctrl_service_id == DLT_SERVICE_ID_CONNECTION_INFO:
if self.datasize == ctypes.sizeof(cDltServiceConnectionInfo):
conn_info = cDltServiceConnectionInfo.from_buffer(bytearray(self.databuffer[:self.datasize]))
Expand All @@ -296,25 +296,27 @@ def payload_decoded(self):
text += b"connected"
else:
text += b"unknown"
text += b" " + ctypes.string_at(conn_info.comid, DLT_ID_SIZE)
text += b" " + ctypes.string_at(conn_info.comid, DLT_ID_SIZE).rstrip(b'\000')
else:
text += ctypes.string_at(self.databuffer, self.datasize)[5:256+5]
text += ctypes.string_at(self.databuffer, self.datasize)[5:256+5].rstrip(b'\000')
elif service_id == DLT_SERVICE_ID_TIMEZONE:
text += ctypes.string_at(self.databuffer, self.datasize)[5:256+5]
text += ctypes.string_at(self.databuffer, self.datasize)[5:256+5].rstrip(b'\000')
else:
buf = ctypes.create_string_buffer(b'\000' * DLT_DAEMON_TEXTSIZE)
dltlib.dlt_message_payload(ctypes.byref(self), buf, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII,
self.verbose)
text += buf.value
text += buf.value.rstrip(b'\000')
return text

if self.type == DLT_TYPE_CONTROL:
return b"[{}] {}".format(self.ctrl_service_id_string,
ctypes.string_at(self.databuffer, self.datasize)[4:256+4])
return b"[%s] %s" % (
self.ctrl_service_id_string,
ctypes.string_at(self.databuffer, self.datasize)[4:256+4].rstrip(b'\000'),
)

buf = ctypes.create_string_buffer(b'\000' * DLT_DAEMON_TEXTSIZE)
dltlib.dlt_message_payload(ctypes.byref(self), buf, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, self.verbose)
return buf.value
return buf.value.rstrip(b'\000').strip()


class cDltStorageHeader(ctypes.Structure):
Expand Down
4 changes: 2 additions & 2 deletions tests/dlt_message_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_from_bytes_control(self):
assert_equal(msg.ecuid, "MGHS")
assert_equal(msg.tmsp, 3.8533)
assert_equal(msg.storage_timestamp, 1498470705.539688)
assert_equal(msg.payload_decoded, "[connection_info ok] connected \x00\x00\x00\x00")
assert_equal(msg.payload_decoded, "[connection_info ok] connected ")

def test_from_bytes_log_multipayload(self):
msg = DLTMessage.from_bytes(b"DLT\x011\xd9PYfI\x08\x00MGHS=\x00\x000MGHS\x00\x00\x03\x1e\x00\x00\x94\xc8A"
Expand All @@ -146,7 +146,7 @@ def test_from_bytes_log_multipayload(self):
assert_equal(msg.ctid, "CPUS")
assert_equal(msg.ecuid, "MGHS")
assert_equal(msg.tmsp, 3.8088)
assert_equal(msg.payload_decoded, "4 online cores ")
assert_equal(msg.payload_decoded, "4 online cores")

def test_sort_data_control(self):
data = (
Expand Down