linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: Jaime Garcia <jgarcia@vali.com.mx>
Cc: linux-c-programming@vger.kernel.org
Subject: RE: Serial Port (RS-232)
Date: Wed, 28 Jan 2009 17:19:29 +0000	[thread overview]
Message-ID: <18816.37793.803089.202815@cerise.gclements.plus.com> (raw)
In-Reply-To: <001501c9815b$6cbb6fc0$46324f40$@com.mx>


Jaime Garcia wrote:

> What I want to do is to read from another device that transmit a string of
> chars through serial connector, what do you recommend? I would like to know
> your approach for this. Thank you in advance for your help.

First, open() the device.

Then configure the line settings with e.g.:

	struct termios t;
	tcgetattr(fd, &t);
	t.c_lflag &= ~ICANON;
	tcsetattr(fd, TCSANOW, &t);

The ICANON flag controls the use of "canonical mode" (line buffering,
processing of control codes, etc). For a device other than a terminal,
you would normally disable this flag. Exactly how the line is
configured depends upon the device; see the termios(3) manpage for a
list of settings.

Finally, just read() data.

-- 
Glynn Clements <glynn@gclements.plus.com>

  reply	other threads:[~2009-01-28 17:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-27 15:59 Serial Port (RS-232) Jaime Garcia
2009-01-27 16:20 ` Jai Sharma
2009-01-27 16:46   ` Jaime Garcia
2009-01-27 16:35 ` Tiago Maluta
2009-01-27 17:13 ` Michael Iatrou
2009-01-27 17:33   ` Jaime Garcia
2009-01-28  0:56     ` Glynn Clements
2009-01-28 15:16       ` Jaime Garcia
2009-01-28 17:19         ` Glynn Clements [this message]
2009-01-29  0:14           ` Jaime Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18816.37793.803089.202815@cerise.gclements.plus.com \
    --to=glynn@gclements.plus.com \
    --cc=jgarcia@vali.com.mx \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).