- add ability for openocd to communicate to gdb using pipes (stdin/stdout).
[fw/openocd] / src / server / telnet_server.c
index 2d779ec56e054a997434c3a56ebf4fdbc137dbfe..dc555214e07c0c6aa9293e917bbe0e5e760dac26 100644 (file)
@@ -188,8 +188,6 @@ int telnet_new_connection(connection_t *connection)
 
        log_add_callback(telnet_log_callback, connection);
 
-
-
        return ERROR_OK;
 }
 
@@ -341,7 +339,9 @@ int telnet_input(connection_t *connection)
                                                        t_con->line_size = 0;
 
                                                        t_con->line_cursor = -1; /* to supress prompt in log callback during command execution */
+
                                                        retval = command_run_line(command_context, t_con->line);
+
                                                        t_con->line_cursor = 0;
 
                                                        if (retval == ERROR_COMMAND_CLOSE_CONNECTION)
@@ -615,7 +615,7 @@ int telnet_init(char *banner)
 
        telnet_service->banner = banner;
 
-       add_service("telnet", CONNECTION_TELNET, telnet_port, 1, telnet_new_connection, telnet_input, telnet_connection_closed, telnet_service);
+       add_service("telnet", CONNECTION_TCP, telnet_port, 1, telnet_new_connection, telnet_input, telnet_connection_closed, telnet_service);
 
        return ERROR_OK;
 }
@@ -626,7 +626,7 @@ int telnet_register_commands(command_context_t *command_context)
                                         COMMAND_EXEC, "exit telnet session");
 
        register_command(command_context, NULL, "telnet_port", handle_telnet_port_command,
-                                        COMMAND_CONFIG, "");
+                                        COMMAND_CONFIG, "port on which to listen for incoming telnet connections");
 
        return ERROR_OK;
 }
@@ -635,7 +635,10 @@ int telnet_register_commands(command_context_t *command_context)
 int handle_telnet_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        if (argc == 0)
+       {
+               command_print(cmd_ctx, "%d", telnet_port);
                return ERROR_OK;
+       }
 
        telnet_port = strtoul(args[0], NULL, 0);