/* Generic serial interface routines
- Copyright (C) 1992-2014 Free Software Foundation, Inc.
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include <ctype.h>
#include "serial.h"
-#include <string.h>
#include "gdbcmd.h"
#include "cli/cli-utils.h"
if (strcmp (name, "pc") == 0)
ops = serial_interface_lookup ("pc");
- else if (strncmp (name, "lpt", 3) == 0)
+ else if (startswith (name, "lpt"))
ops = serial_interface_lookup ("parallel");
- else if (strncmp (name, "|", 1) == 0)
+ else if (startswith (name, "|"))
{
ops = serial_interface_lookup ("pipe");
/* Discard ``|'' and any space before the command itself. */
{
if (serial_logfp != NULL)
{
- const char *str = buf;
+ const char *str = (const char *) buf;
size_t c;
for (c = 0; c < count; c++)
}
if (serial_debug_p (scb))
{
- const char *str = buf;
+ const char *str = (const char *) buf;
size_t c;
for (c = 0; c < count; c++)
{
fprintf_unfiltered (gdb_stdlog, "[");
- serial_logchar (gdb_stdlog, 'w', str[count] & 0xff, 0);
+ serial_logchar (gdb_stdlog, 'w', str[c] & 0xff, 0);
fprintf_unfiltered (gdb_stdlog, "]");
}
gdb_flush (gdb_stdlog);
return scb->ops->setstopbits (scb, num);
}
+/* See serial.h. */
+
+int
+serial_setparity (struct serial *scb, int parity)
+{
+ return scb->ops->setparity (scb, parity);
+}
+
int
serial_can_async_p (struct serial *scb)
{
{
printf_unfiltered ("\"set serial\" must be followed "
"by the name of a command.\n");
- help_list (serial_set_cmdlist, "set serial ", -1, gdb_stdout);
+ help_list (serial_set_cmdlist, "set serial ", all_commands, gdb_stdout);
}
static void
value);
}
+/* Parity for serial port. */
+
+int serial_parity = GDBPARITY_NONE;
+
+static const char parity_none[] = "none";
+static const char parity_odd[] = "odd";
+static const char parity_even[] = "even";
+static const char *const parity_enums[] =
+ {parity_none, parity_odd, parity_even, NULL};
+static const char *parity = parity_none;
+
+/* Set serial_parity value. */
+
+static void
+set_parity (char *ignore_args, int from_tty, struct cmd_list_element *c)
+{
+ if (parity == parity_odd)
+ serial_parity = GDBPARITY_ODD;
+ else if (parity == parity_even)
+ serial_parity = GDBPARITY_EVEN;
+ else
+ serial_parity = GDBPARITY_NONE;
+}
+
void
_initialize_serial (void)
{
serial_baud_show_cmd,
&serial_set_cmdlist, &serial_show_cmdlist);
- /* The commands "set/show serial baud" used to have a different name.
- Add aliases to those names to facilitate the transition, and mark
- them as deprecated, in order to make users aware of the fact that
- the command names have been changed. */
- {
- const char *cmd_name;
- struct cmd_list_element *cmd;
-
- /* FIXME: There is a limitation in the deprecation mechanism,
- and the warning ends up not being displayed for prefixed
- aliases. So use a real command instead of an alias. */
- add_setshow_zinteger_cmd ("remotebaud", class_alias, &baud_rate, _("\
-Set baud rate for remote serial I/O."), _("\
-Show baud rate for remote serial I/O."), _("\
-This value is used to set the speed of the serial port when debugging\n\
-using remote targets."),
- NULL,
- serial_baud_show_cmd,
- &setlist, &showlist);
- cmd_name = "remotebaud";
- cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1);
- deprecate_cmd (cmd, "set serial baud");
- cmd_name
- = "remotebaud"; /* needed because lookup_cmd updates the pointer */
- cmd = lookup_cmd (&cmd_name, showlist, "", -1, 1);
- deprecate_cmd (cmd, "show serial baud");
- }
+ add_setshow_enum_cmd ("parity", no_class, parity_enums,
+ &parity, _("\
+Set parity for remote serial I/O"), _("\
+Show parity for remote serial I/O"), NULL,
+ set_parity,
+ NULL, /* FIXME: i18n: */
+ &serial_set_cmdlist, &serial_show_cmdlist);
add_setshow_filename_cmd ("remotelogfile", no_class, &serial_logfile, _("\
Set filename for remote session recording."), _("\