Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTT_COMMAND: Allow no down-channels #1680

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pyocd/subcommands/rtt_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright (C) 2022 Johan Carlsson <[email protected]>
# Copyright (C) 2022 Samuel Dewan
# Copyright (C) 2022 Zhengji Li
# Copyright (C) 2024 Laurens Miers
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -117,12 +118,13 @@ def invoke(self) -> int:
kb = KBHit()

if self._args.log_file is None:
if len(control_block.down_channels) < 1:
LOG.error("No down channels.")
return 1
down_chan: RTTDownChannel = control_block.down_channels[self._args.down_channel_id]
down_name = down_chan.name if down_chan.name is not None else ""
LOG.info(f"Writing to down channel {self._args.down_channel_id} (\"{down_name}\")")
if control_block.down_channels:
down_chan: RTTDownChannel = control_block.down_channels[self._args.down_channel_id]
down_name = down_chan.name if down_chan.name is not None else ""
LOG.info(f"Writing to down channel {self._args.down_channel_id} (\"{down_name}\")")
else:
down_chan = None
LOG.info("No down channel, input will be ignored")

self.viewer_loop(up_chan, down_chan, kb)
else:
Expand Down Expand Up @@ -199,6 +201,10 @@ def viewer_loop(self, up_chan, down_chan, kb):
if not cmd:
continue

# If no channel, ignore command
if not down_chan:
continue

# write cmd buffer to down buffer 0 (host -> target)
bytes_out = down_chan.write(cmd)
cmd = cmd[bytes_out:]