LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* serial port programming question (newbie)
@ 2011-01-18  0:27 Donna Rigas
  2011-01-18  0:41 ` serial port programming second " Donna Rigas
  0 siblings, 1 reply; 3+ messages in thread
From: Donna Rigas @ 2011-01-18  0:27 UTC (permalink / raw)
  To: linux-kernel

I see lots of serial port programming examples where the
port settings are saved before being changed to the desired settings,
then restored to the original before exiting the program via
tcgetattr and tgsetattr. 

I see one example where someone comments that this is not necessary.

Can someone tell me whether or not it is necessary to save and restore the
old settings and if so, why?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* serial port programming second question (newbie)
  2011-01-18  0:27 serial port programming question (newbie) Donna Rigas
@ 2011-01-18  0:41 ` Donna Rigas
  2011-01-18 10:57   ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Donna Rigas @ 2011-01-18  0:41 UTC (permalink / raw)
  To: linux-kernel

Also, if your call to tcsetattr fails, or if  the ioctl call to
set the baud rate fails, does it matter if you restore the serial
port settings or not?
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: serial port programming second question (newbie)
  2011-01-18  0:41 ` serial port programming second " Donna Rigas
@ 2011-01-18 10:57   ` Alan Cox
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Cox @ 2011-01-18 10:57 UTC (permalink / raw)
  To: donna.rigas; +Cc: linux-kernel

On Mon, 17 Jan 2011 16:41:38 -0800
Donna Rigas <donna.rigas@gmail.com> wrote:

> Also, if your call to tcsetattr fails, or if  the ioctl call to
> set the baud rate fails, does it matter if you restore the serial
> port settings or not?

If they fail the returned struct contains the settings you ended up with,
eg the baud rate you actually got. Older kernels didn't get that detail
right but current ones do. Generally they will try and pick a nearest
suitable rate.

Alan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-18 10:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18  0:27 serial port programming question (newbie) Donna Rigas
2011-01-18  0:41 ` serial port programming second " Donna Rigas
2011-01-18 10:57   ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).