Skip to content

Commit d81a16b

Browse files
authored
Optimize PCAN send performance (#1640)
1 parent 631f7be commit d81a16b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

can/interfaces/pcan/pcan.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,7 @@ def send(self, msg, timeout=None):
608608
CANMsg.MSGTYPE = msgType
609609

610610
# copy data
611-
for i in range(msg.dlc):
612-
CANMsg.DATA[i] = msg.data[i]
611+
CANMsg.DATA[: msg.dlc] = msg.data[: msg.dlc]
613612

614613
log.debug("Data: %s", msg.data)
615614
log.debug("Type: %s", type(msg.data))
@@ -628,8 +627,7 @@ def send(self, msg, timeout=None):
628627
# if a remote frame will be sent, data bytes are not important.
629628
if not msg.is_remote_frame:
630629
# copy data
631-
for i in range(CANMsg.LEN):
632-
CANMsg.DATA[i] = msg.data[i]
630+
CANMsg.DATA[: CANMsg.LEN] = msg.data[: CANMsg.LEN]
633631

634632
log.debug("Data: %s", msg.data)
635633
log.debug("Type: %s", type(msg.data))

0 commit comments

Comments
 (0)