tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: C tty/tcsetattrs question



On Thu, May 26, 2016 at 07:30:05PM +0200, Manuel Bouyer wrote:
> Hello,
> I have a GPS device connected to a serial port. It defaults to 9600bps
> NMEA messages, but I need to switch it to 4800bps. There are NMEA
> commands for this, and I can properly do this using cu(1).
> 
> Now I'm trying to write a program to do this at boot time.
> First I need to determine if the GPS is outputting at 4800 or 9600bps
> (the CPU may be rebooted, or even powered off wihout resetting the GPS
> module).
> I wrote the attached C program, but the cfsetspeed() doesn't seem
> to have any effect: with the GPS running at 9600bps,
> if I start with the tty set to 9600 (for example from a previous
> cu(1) run) I get proper NMEA sentences on both check_term() calls,
> and if I start with the tty set to 4800 (e.g. from a previous
> cu(1) run) I get either nothing or garbage (not getting anything
> from the tty is a valid case, as the tty is in canon mode select()
> will return a read event only if the serial port got something that
> looks like a line).
> 
> Does anyone see an obvious error or something I missed ?

Ops, I used = where I wanted &=. This resulted in non-wanted flags
in various place, with strange effects. With this fixed the
speed settings have more effects.

Now there are bugs in the driver itself (or in the allwiner serial port)
but this is another problem.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index