[PATCH] 230.4Kbps support for serial port
Troy Curtiss
tcurtiss@qcpi.com
Fri Jan 10 02:20:00 GMT 2003
I'm thinking the error should be EINVAL - since the DCB parameter is
technically invalid for the given device. Note that the code should
probably always check the return of SetCommState() to guard against
possibly bad/invalid/incompatible information in the Win32 DCB. Let me
know if you'd like me to re-architect my patch to follow the old paradigm
(possible doing all the SetComm*() at the bottom of the function?) Thanks,
-Troy
At 04:45 PM 1/9/2003 -0500, you wrote:
>On Thu, Jan 09, 2003 at 11:18:31AM -0700, Troy Curtiss wrote:
> >Christopher,
> > I see in the latest fhandler_serial::tcsetattr(), the following part of
> >my patch wasn't applied. This piece is necessary in the event the serial
> >device doesn't actually support 230.4Kbps (so tcsetattr() will return an
> >error instead of simply not working.)
>
>This piece short circuits lots of subsequent code, however. It's a departure
>from the way this function used to work. And it does need to set an errno,
>as you'd indicated. I don't know what the errno would be, though.
>
>cgf
>
> >@@ -723,8 +726,12 @@ fhandler_serial::tcsetattr (int action,
> > state.fAbortOnError = TRUE;
> >
> > /* -------------- Set state and exit ------------------ */
> >- if (memcmp (&ostate, &state, sizeof (state)) != 0)
> >- SetCommState (get_handle (), &state);
> >+ if ((memcmp (&ostate, &state, sizeof (state)) != 0) &&
> >+ !SetCommState (get_handle (), &state))
> >+ {
> >+ /* Return now if any of the parameters in the DCB didn't take */
> >+ return -1;
> >+ }
> >
> > Thanks,
> >
> >-Troy
> >
> >
> >
> >At 03:21 AM 1/9/2003 -0500, you wrote:
> >>On Tue, Jan 07, 2003 at 03:48:51PM -0700, Troy Curtiss wrote:
> >>>Hi,
> >>> Attached is a patch that enables cygwin to talk at 230400 bps on serial
> >>>ports that support the higher rate. It also does the necessary
> >>>error-checking to confirm whether or not a given port is capable of
> >>>extended bitrates. I added B230400 (for Posix) and CBR_230400 (for Win32)
> >>>definitions to the appropriate header files (termios.h and winbase.h,
> >>>respectively). I've been testing for a couple days now and it appears to
> >>>work as designed. (We use a lot of extended bitrate devices at work,
> >>>mostly with Win32 code - so this simply brings the paradigm across to the
> >>>posix side of the house.)
> >>>
> >>>Question: Upon failure (ie. trying to configure a non-230.4K capable port
> >>>to talk 230.4K), I simply return -1... I'm not sure whether POSIX would
> >>>set errno = EINVAL or not... either way is fine.
> >>>
> >>> Let me know if you have any questions, otherwise it sure would be nice
> >>>to roll this in if possible :) Thanks,
> >>
> >>I'll apply this patch (with a reformatted changelog) to cygwin but not
> >>to winbase.h. I couldn't find any reference to a CBR_230400 anywhere so
> >>it wouldn't be technically correct to a windows header file.
> >>
> >>Thanks,
> >>cgf
> >>
> >>>2003-01-06 Troy Curtiss <troyc@usa.net>
> >>>
> >>> * fhandler_serial.cc (fhandler_serial::tcsetattr): Add support and
> >>> capability checking for B230400 bitrate.
> >>> * fhandler_serial.cc (fhandler_serial::tcgetattr): Add support for
> >>> B230400 bitrate.
> >>> * /cvs/src/src/winsup/w32api/include/winbase.h: Add CBR_230400
> >>> definition for Win32 support of 230.4Kbps.
> >>> * /cvs/src/src/winsup/cygwin/include/sys/termios.h: Add B230400
> >>> definition for Posix support of 230.4Kbps.
More information about the Cygwin-patches
mailing list