def read_message(self, verbose=False): """Read new message :param bool verbose: Log every dlt_message_read(). Set True only for debugging. :returns: A new DLTMessage on successful read, None otherwise :rtype: DLTMessage|None """ msg = DLTMessage(verbose=verbose) res = dltlib.dlt_message_read( ctypes.byref(msg), ctypes.cast(self.receiver.buf, ctypes.POINTER(ctypes.c_uint8)), ctypes.c_uint(self.receiver.bytesRcvd), # length ctypes.c_int(0), # resync ctypes.c_int(verbose)) # verbose if res != DLT_MESSAGE_ERROR_OK: # - failed to read a complete message, possibly read an incomplete # message return None # prepare storage header if msg.standardheader.htyp & DLT_HTYP_WEID: dltlib.dlt_set_storageheader(msg.p_storageheader, msg.headerextra.ecu) else: dltlib.dlt_set_storageheader(msg.p_storageheader, ctypes.c_char_p("")) return msg
def msg_callback(msg, data): if msg == None: print("NULL message in callback") return -1 if msg.contents.p_standardheader.contents.htyp & DLT_HTYP_WEID: dltlib.dlt_set_storageheader(msg.contents.p_storageheader, msg.contents.headerextra.ecu) else: dltlib.dlt_set_storageheader(msg.contents.p_storageheader, ctypes.c_char_p("")) print(msg.contents) return 0
def msg_callback(msg, data): # pylint: disable=no-self-argument """Implements a simple callback that prints a dlt message received""" if msg is None: print("NULL message in callback") return -1 if msg.contents.p_standardheader.contents.htyp & DLT_HTYP_WEID: dltlib.dlt_set_storageheader(msg.contents.p_storageheader, msg.contents.headerextra.ecu) else: dltlib.dlt_set_storageheader(msg.contents.p_storageheader, ctypes.c_char_p("")) print(msg.contents) return 0