diff --git a/canopen/nmt.py b/canopen/nmt.py index 77d56910..ca95a30e 100644 --- a/canopen/nmt.py +++ b/canopen/nmt.py @@ -147,7 +147,7 @@ def send_command(self, code: int): super(NmtMaster, self).send_command(code) logger.info( "Sending NMT command 0x%X to node %d", code, self.id) - self.network.send_message(0, [code, self.id]) + self.network.send_message(0, bytes([code, self.id])) def wait_for_heartbeat(self, timeout: float = 10): """Wait until a heartbeat message is received.""" @@ -190,7 +190,7 @@ def start_node_guarding(self, period: float): """ if self._node_guarding_producer: self.stop_node_guarding() - self._node_guarding_producer = self.network.send_periodic(0x700 + self.id, None, period, True) + self._node_guarding_producer = self.network.send_periodic(0x700 + self.id, b'', period, True) def stop_node_guarding(self): """Stops the node guarding mechanism.""" @@ -225,7 +225,7 @@ def send_command(self, code: int) -> None: if self._state == 0: logger.info("Sending boot-up message") - self.network.send_message(0x700 + self.id, [0]) + self.network.send_message(0x700 + self.id, b'\x00') # The heartbeat service should start on the transition # between INITIALIZING and PRE-OPERATIONAL state @@ -259,7 +259,7 @@ def start_heartbeat(self, heartbeat_time_ms: int): if heartbeat_time_ms > 0: logger.info("Start the heartbeat timer, interval is %d ms", self._heartbeat_time_ms) self._send_task = self.network.send_periodic( - 0x700 + self.id, [self._state], heartbeat_time_ms / 1000.0) + 0x700 + self.id, bytes([self._state]), heartbeat_time_ms / 1000.0) def stop_heartbeat(self): """Stop the heartbeat service.""" @@ -270,7 +270,7 @@ def stop_heartbeat(self): def update_heartbeat(self): if self._send_task is not None: - self._send_task.update([self._state]) + self._send_task.update(bytes([self._state])) class NmtError(Exception):