Skip to content

Commit 2dd02d1

Browse files
committed
Simplify virtual can a little bit
1 parent 15c8016 commit 2dd02d1

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

can/interfaces/virtual.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
and reside in the same process will receive the same messages.
99
"""
1010

11-
import copy
11+
from copy import deepcopy
1212
import logging
1313
import time
1414
try:
@@ -40,6 +40,8 @@ class VirtualBus(BusABC):
4040
Implements :meth:`can.BusABC._detect_available_configs`; see
4141
:meth:`can.VirtualBus._detect_available_configs` for how it
4242
behaves here.
43+
44+
The timeout when sending a message applies to each receiver.
4345
"""
4446

4547
def __init__(self, channel=None, receive_own_messages=False,
@@ -82,13 +84,12 @@ def _recv_internal(self, timeout):
8284

8385
def send(self, msg, timeout=None):
8486
self._check_if_open()
85-
# Create a shallow copy for this channel
86-
msg_copy = copy.copy(msg)
87+
88+
msg_copy = deepcopy(msg)
8789
msg_copy.timestamp = time.time()
88-
msg_copy.data = bytearray(msg.data)
89-
msg_copy.channel = self.channel_id
90-
all_sent = True
90+
9191
# Add message to all listening on this channel
92+
all_sent = True
9293
for bus_queue in self.channel:
9394
if bus_queue is not self.queue or self.receive_own_messages:
9495
try:

0 commit comments

Comments
 (0)