32 size_t length,
void *user_data)
45 LOG_ERROR(
"Failed to write data to socket.");
90 unsigned char buffer[1024];
99 else if (bytes_read < 0) {
100 LOG_ERROR(
"error during read: %s", strerror(errno));
112 .new_connection_during_keep_alive_handler =
NULL,
116 .keep_client_alive_handler =
NULL,
124 if (CMD_ARGC < 2 || CMD_ARGC > 3)
138 service->hello_message = malloc(hello_length + 2);
145 service->hello_message[hello_length] =
'\n';
146 service->hello_message[hello_length + 1] =
'\0';
171 .handler = handle_rtt_start_command,
173 .help =
"Start a RTT server",
174 .usage =
"<port> <channel> [message]"
178 .handler = handle_rtt_stop_command,
180 .help =
"Stop a RTT server",
190 .help =
"RTT server",
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
int rtt_register_sink(unsigned int channel_index, rtt_sink_read read, void *user_data)
Register an RTT sink.
int rtt_unregister_sink(unsigned int channel_index, rtt_sink_read read, void *user_data)
Unregister an RTT sink.
int rtt_write_channel(unsigned int channel_index, const uint8_t *buffer, size_t *length)
Write to an RTT channel.
static int rtt_connection_closed(struct connection *connection)
static const struct command_registration rtt_command_handlers[]
static int rtt_new_connection(struct connection *connection)
static int rtt_input(struct connection *connection)
COMMAND_HANDLER(handle_rtt_start_command)
static int read_callback(unsigned int channel, const uint8_t *buffer, size_t length, void *user_data)
static const struct command_registration rtt_server_subcommand_handlers[]
int rtt_server_register_commands(struct command_context *ctx)
static const struct command_registration rtt_server_command_handlers[]
static const struct service_driver rtt_service_driver
int connection_write(struct connection *connection, const void *data, int len)
int connection_read(struct connection *connection, void *data, int len)
int remove_service(const char *name, const char *port)
int add_service(const struct service_driver *driver, const char *port, int max_connections, void *priv)
#define CONNECTION_LIMIT_UNLIMITED
#define ERROR_SERVER_REMOTE_CLOSED
const char * name
the name of the server