From: Joel Brobecker <brobecker@adacore.com>
To: Yurij Grechishhev <yurij.grechishhev@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Setting parity for remote serial
Date: Mon, 23 Mar 2015 13:11:00 -0000 [thread overview]
Message-ID: <20150323131147.GD5438@adacore.com> (raw)
In-Reply-To: <CAAyhtXQUqokKS8CvqwK063DmzG1=OY2KJxg25fZWUDH4_3tK3Q@mail.gmail.com>
> Unfortunately, now I don't have the ability to fully-test it with
> windows (but I was checking initial version one year ago, with real
> hardware). Now it has been compiled by using mingw with
> --host=i586-mingw32msvc.
No problem - the code looked about right to me, and we will let those
who do work on Windows take care of fixing any bugs if they use this
feature and encounter a bug.
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index ca8bbaf..02f9ddc 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,37 @@
> +2015-03-21 Yurij Grechishhev <yurij.grechishhev@gmail.com>
> +
> + * NEWS: Mention set/show serial parity command.
> + * monitor.c (monitor_open): Call serial_setparity.
> + * remote.c (remote_open_1): Likewise.
> + * ser-base.c (ser_base_serparity): New function.
> + * ser-base.h (ser_base_setparity): Add declaration.
> + * ser-go32.c (dos_ops): Add dos_noop field.
The name of the struct field is actually "setparity" (instead of
"dos_noop").
> + * ser-mingw.c (ser_windows_raw): Remove state.fParity and
> + state.Parity definitions.
"Do not set state.fParity and state.Parity". You remmoved assignments,
rather than definitions.
> + (ser_windows_setparity): New function.
> + (hardwire_ops): Add ser_windows_setparity.
> + (tty_ops): Add NULL for setparity field.
> + (pipe_ops): Add ser_base_setparity.
> + (tcp_ops): Likewise.
> + * ser-pipe.c (pipe_ops): Likewise.
> + * ser-tcp.c (tcp_ops): Likewise.
> + * ser-unix.c (hardwire_setparity): Add declaration.
> + (hardwire_raw): Don't reset PARENB flag.
> + (hardwire_setparity): New function.
> + (hardwire_ops): Add hardwire_setparity.
> + * serial.c (serial_setparity): New function.
> + (serial_parity): New global.
> + (parity_none, parity_odd, parity_even, parity_enums, parity):
> + New static globals.
Wrong indentation of "New static globals". I suspect that this is
because you used 8 spaces instead of a tab to indent that line?
> + (set_parity): New function.
> + (_initialize_serial): Add set/show serial parity commands.
> + * serial.h (GDBPARITY_NONE): Define.
> + (GDBPARITY_ODD): Define.
> + (GDBPARITY_EVEN): Define.
> + (serial_setparity) Add declaration.
> + (serial_ops): Add setparity entry.
Let's say...
(struct serial_ops): Add setparity field
... instead.
> + * target.h (serial_parity): Add declaration.
The rest are minor comments:
> + internal_warning (__FILE__, __LINE__, "Incorrect parity value:
> %d", parity);
This line is too long. It shouldn't exceed 79 characters.
internal_warning (__FILE__, __LINE__, "Incorrect parity value: %d", parity);
Use instead:
internal_warning (__FILE__, __LINE__,
"Incorrect parity value: %d", parity);
Also, watch out for the fact that your mailer appears to have wrapped
the line. I suggest you switch to sending the patch either using
"git send-email" (the recommended method), or else sending the patch
as an attachment ("git format-patch" + attach to email).
> @@ -409,7 +410,7 @@ hardwire_raw (struct serial *scb)
> state.termios.c_iflag = 0;
> state.termios.c_oflag = 0;
> state.termios.c_lflag = 0;
> - state.termios.c_cflag &= ~(CSIZE | PARENB);
> + state.termios.c_cflag &= ~(CSIZE);
You don't really need the parentheses anymore -> ~CSIZE
> state.termios.c_cflag |= CLOCAL | CS8;
> #ifdef CRTSCTS
> /* h/w flow control. */
> @@ -432,7 +433,7 @@ hardwire_raw (struct serial *scb)
> state.termio.c_iflag = 0;
> state.termio.c_oflag = 0;
> state.termio.c_lflag = 0;
> - state.termio.c_cflag &= ~(CSIZE | PARENB);
> + state.termio.c_cflag &= ~(CSIZE);
Likewise.
> @@ -893,6 +894,50 @@ hardwire_setstopbits (struct serial *scb, int num)
> return set_tty_state (scb, &state);
> }
>
> +/* Implement the "setparity" serial_ops callback. */
> +
> +static int
> +hardwire_setparity (struct serial *scb, int parity)
> +{
> + struct hardwire_ttystate state;
> + int newparity = 0;
> +
> + if (get_tty_state (scb, &state))
> + return -1;
> +
> + switch (parity)
> + {
> + case GDBPARITY_NONE:
> + newparity = 0;
> + break;
> + case GDBPARITY_ODD:
> + newparity = PARENB | PARODD;
> + break;
> + case GDBPARITY_EVEN:
> + newparity = PARENB;
> + break;
> + default:
> + internal_warning (__FILE__, __LINE__, "Incorrect parity value:
> %d", parity);
Same as above - line is too long.
> +/* See serial.h. */
> +
> +int
> +serial_setparity (struct serial *scb, int parity)
> +{
> + return scb->ops->setparity (scb, parity);
The indentation is wrong (we use a 2-space indentation). Hence:
int
serial_setparity (struct serial *scb, int parity)
{
return scb->ops->setparity (scb, parity);
}
--
Joel
next prev parent reply other threads:[~2015-03-23 13:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 14:29 Yurij Grechishhev
2013-07-24 16:53 ` Eli Zaretskii
2013-07-25 7:15 ` Yurij Grechishhev
2013-07-25 16:21 ` Eli Zaretskii
[not found] ` <CAAyhtXRJaoxvfm7FH06AXeATgscXn4SrY5=ZD_h=BBmPoUdTBQ@mail.gmail.com>
2013-07-29 18:34 ` Eli Zaretskii
2013-07-29 19:25 ` Pedro Alves
2013-07-29 20:14 ` Yurij Grechishhev
2013-07-29 19:04 ` Yurij Grechishhev
2013-09-26 17:00 ` Joel Brobecker
2013-10-02 21:59 ` Yurij Grechishhev
[not found] ` <CAAyhtXTmrJ04BVhziaFnogGyWLz7+G+Qwbc9UnHJkrEbDgTjFw@mail.gmail.com>
2013-10-04 7:34 ` Joel Brobecker
2013-10-09 4:11 ` Joel Brobecker
2015-02-25 15:16 ` Joel Brobecker
[not found] ` <CAAyhtXRC8DFk0SdfLoQvhWk_+h5AFZW2QmXQ6RcdCVC9Asx9Vw@mail.gmail.com>
2015-02-27 8:16 ` Joel Brobecker
2015-03-15 21:49 ` Yurij Grechishhev
2015-03-16 3:32 ` Eli Zaretskii
2015-03-17 14:56 ` Joel Brobecker
2015-03-22 22:52 ` Yurij Grechishhev
2015-03-23 13:11 ` Joel Brobecker [this message]
2015-03-23 15:36 ` Eli Zaretskii
2015-03-23 21:21 ` Yurij Grechishhev
2015-03-23 22:52 ` pushed: " Joel Brobecker
-- strict thread matches above, loose matches on Subject: below --
2013-07-10 15:18 Yurij Grechishhev
2013-07-10 18:10 ` Tom Tromey
[not found] ` <524ECCBB.5050307@gmail.com>
2013-10-07 18:33 ` Yurij Grechishhev
2013-10-08 3:56 ` Joel Brobecker
2013-10-08 12:03 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150323131147.GD5438@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=yurij.grechishhev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox