Skip to content

Commit 7419978

Browse files
committed
defaults to the first channel
1 parent 18ebfe9 commit 7419978

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

candle/candle_bus.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,17 @@ def _recv_internal(self, timeout: Optional[float]) -> Tuple[Optional[can.Message
202202
def send(self, msg: can.Message, timeout: Optional[float] = None) -> None:
203203
# Parse channel.
204204
target_channels: Tuple[api.CandleChannel, ...]
205-
if len(self._channel_numbers) == 1:
206-
# There is only one channel.
205+
if msg.channel is None:
207206
target_channels = (self._channels[self._channel_numbers[0]],)
207+
elif isinstance(msg.channel, str):
208+
serial_number, channel_number = msg.channel.split(':')
209+
target_channels = (self._channels[int(channel_number)],)
210+
elif isinstance(msg.channel, int):
211+
target_channels = (self._channels[msg.channel],)
212+
elif isinstance(msg.channel, Sequence):
213+
target_channels = tuple(self._channels[i] for i in msg.channel)
208214
else:
209-
if isinstance(msg.channel, str):
210-
serial_number, channel_number = msg.channel.split(':')
211-
target_channels = (self._channels[int(channel_number)],)
212-
elif isinstance(msg.channel, int):
213-
target_channels = (self._channels[msg.channel],)
214-
elif isinstance(msg.channel, Sequence):
215-
target_channels = tuple(self._channels[i] for i in msg.channel)
216-
else:
217-
raise TypeError("Channel must be of type int, str or Sequence[int]")
215+
raise TypeError("Channel must be of type int, str or Sequence[int]")
218216

219217
if timeout is None:
220218
timeout = 1.0

0 commit comments

Comments
 (0)