Hi Rob --
man cfgetispeed
man cfsetispeed
And similar for output speed: cf[sg]etospeed. The data stored in the
termios structure is not directly the baud rate; POSIX says you use
these functions to go between the termios data and the Bnnn baud rate
constants that Don mentions.
Also some (most?) systems return success from tcsetattr() if _any_ of
your requested changes are made, so you should double check with
tcgetattr to be sure your changes have taken.
Regards, ........ Charlie
--- In "Rob" <> wrote:
>
> Thanks for the info. It is a serial port because other routines in
the program read data off
> the GPS if I manually set the baud rate with "stty -F /dev/ttyAM1
speed 19200" (yes this
> GPS is not running 4800). The only two routines that fail are
configuration and
> read_configuration. On your suggestion to check for errors I added
>
> char err_str[256];
>
> result = tcgetattr (file_id, &options);
> if(result != 0)
> {
> printf("Error of %d calling tcgetattr\n", result);
> perror(err_str);
> }
>
> I get no reported error but the same bad values.
>
> Thanks for the suggestions so far.
> Rob
>
> --- In "Don W. Carr" <doncarr@> wrote:
> >
> > First, always check for errors. Capture the return value, and if
it is not 0
> > (success), then call perror(), to print the error. You must check
errors on
> > these types of functions and handle them, otherwise, the bigger
the program,
> > the more likely that you will have mysterious unknown errors at
times that
> > you can not figure out. For this particular call, you can not call
on any
> > old fd, it much be a serial port. You might get the error, not a
tty or
> > something like that as I recall. As I recall, I typically call
isatty() to
> > check to see if the fd is valid for setting baud rate, before
continuing.
> >
> > Hope that helps!
> >
> > Don.
> >
> >
> >
> >
> > --
> > Dr. Don W. Carr
> > J. G. Montenegro 2258
> > Guadalajara, Mexico
> > +52-333-630-0704
> > +52-333-836-4500 ext 2930
> >
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|