2 * Copyright (C) 2016-2017 by Marc Schink <dev@zapb.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "rtt_server.h"
29 * This server allows access to Real Time Transfer (RTT) channels via TCP
37 static int read_callback(unsigned int channel
, const uint8_t *buffer
,
38 size_t length
, void *user_data
)
41 struct connection
*connection
;
44 connection
= (struct connection
*)user_data
;
47 while (offset
< length
) {
48 ret
= connection_write(connection
, buffer
+ offset
, length
- offset
);
51 LOG_ERROR("Failed to write data to socket.");
61 static int rtt_new_connection(struct connection
*connection
)
64 struct rtt_service
*service
;
66 service
= connection
->service
->priv
;
68 LOG_DEBUG("rtt: New connection for channel %u", service
->channel
);
70 ret
= rtt_register_sink(service
->channel
, &read_callback
, connection
);
78 static int rtt_connection_closed(struct connection
*connection
)
80 struct rtt_service
*service
;
82 service
= (struct rtt_service
*)connection
->service
->priv
;
83 rtt_unregister_sink(service
->channel
, &read_callback
, connection
);
85 LOG_DEBUG("rtt: Connection for channel %u closed", service
->channel
);
90 static int rtt_input(struct connection
*connection
)
93 unsigned char buffer
[1024];
94 struct rtt_service
*service
;
97 service
= (struct rtt_service
*)connection
->service
->priv
;
98 bytes_read
= connection_read(connection
, buffer
, sizeof(buffer
));
101 return ERROR_SERVER_REMOTE_CLOSED
;
102 else if (bytes_read
< 0) {
103 LOG_ERROR("error during read: %s", strerror(errno
));
104 return ERROR_SERVER_REMOTE_CLOSED
;
108 rtt_write_channel(service
->channel
, buffer
, &length
);
113 static const struct service_driver rtt_service_driver
= {
115 .new_connection_during_keep_alive_handler
= NULL
,
116 .new_connection_handler
= rtt_new_connection
,
117 .input_handler
= rtt_input
,
118 .connection_closed_handler
= rtt_connection_closed
,
119 .keep_client_alive_handler
= NULL
,
122 COMMAND_HANDLER(handle_rtt_start_command
)
125 struct rtt_service
*service
;
128 return ERROR_COMMAND_SYNTAX_ERROR
;
130 service
= malloc(sizeof(struct rtt_service
));
135 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[1], service
->channel
);
137 ret
= add_service(&rtt_service_driver
, CMD_ARGV
[0], CONNECTION_LIMIT_UNLIMITED
, service
);
139 if (ret
!= ERROR_OK
) {
147 COMMAND_HANDLER(handle_rtt_stop_command
)
150 return ERROR_COMMAND_SYNTAX_ERROR
;
152 remove_service("rtt", CMD_ARGV
[0]);
157 static const struct command_registration rtt_server_subcommand_handlers
[] = {
160 .handler
= handle_rtt_start_command
,
162 .help
= "Start a RTT server",
163 .usage
= "<port> <channel>"
167 .handler
= handle_rtt_stop_command
,
169 .help
= "Stop a RTT server",
172 COMMAND_REGISTRATION_DONE
175 static const struct command_registration rtt_server_command_handlers
[] = {
179 .help
= "RTT server",
181 .chain
= rtt_server_subcommand_handlers
183 COMMAND_REGISTRATION_DONE
186 static const struct command_registration rtt_command_handlers
[] = {
192 .chain
= rtt_server_command_handlers
194 COMMAND_REGISTRATION_DONE
197 int rtt_server_register_commands(struct command_context
*ctx
)
199 return register_commands(ctx
, NULL
, rtt_command_handlers
);
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)