basic serial programming example

Hi – Does anyone have some sample code for using the /dev/sern devices?
Really, I just need to be able to set the operating parameters (4800 8 n
1 or whatever) and then read incoming data.

if there isn’t any sample code that illustrates this, are there any
helpfiles or good .h’s to look at? seems like the process is pretty
simple: open “/dev/ser1”, set required values in a data structure and
dev-ctl it over, read, read, read… the main question is what is that
datastructure and where is the .h that defines it?

Thanks!
Jason

The termios structure is what you are looking for.

Have a look in the helpviewer for termios, tcgetattr() amd tcsetattr().
The tcsetattr() docs have a brief example included

Rob Rutherford

“Jason Ahmad” <jason.ahmad@bmw.de> wrote in message
news:3D6BF3D1.75CCB773@bmw.de

Hi – Does anyone have some sample code for using the /dev/sern devices?
Really, I just need to be able to set the operating parameters (4800 8 n
1 or whatever) and then read incoming data.

if there isn’t any sample code that illustrates this, are there any
helpfiles or good .h’s to look at? seems like the process is pretty
simple: open “/dev/ser1”, set required values in a data structure and
dev-ctl it over, read, read, read… the main question is what is that
datastructure and where is the .h that defines it?

Thanks!
Jason

Robert Rutherford <ruzz@nospamplease.ruzz.com> wrote:

The termios structure is what you are looking for.

Have a look in the helpviewer for termios, tcgetattr() amd tcsetattr().
The tcsetattr() docs have a brief example included

THis is also pretty standard Unix/Posix stuff – most decent Unix
programming books will have a chapter on how to do this sort of
stuff.

e.g. Advanced Programming in the Unix Environment by W. Richard
Stevens.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.