linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Serial Port (RS-232)
@ 2009-01-27 15:59 Jaime Garcia
  2009-01-27 16:20 ` Jai Sharma
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Jaime Garcia @ 2009-01-27 15:59 UTC (permalink / raw)
  To: linux-c-programming

Hi Friends,
I am pretty new to Linux programming, I want to start doing something
useful, so I was thinking to start programming the serial port (RS-232) of
my box, so I can read and write data from it, can someone of you give some
feedback about how to start this? I will appreciate so much all your help!

Best regards,
J.G.



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

* Re: Serial Port (RS-232)
  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
  2 siblings, 1 reply; 10+ messages in thread
From: Jai Sharma @ 2009-01-27 16:20 UTC (permalink / raw)
  To: Jaime Garcia; +Cc: linux-c-programming

hi

use following link
http://www.easysw.com/~mike/serial/serial.html



On Tue, Jan 27, 2009 at 9:29 PM, Jaime Garcia <jgarcia@vali.com.mx> wrote:
> Hi Friends,
> I am pretty new to Linux programming, I want to start doing something
> useful, so I was thinking to start programming the serial port (RS-232) of
> my box, so I can read and write data from it, can someone of you give some
> feedback about how to start this? I will appreciate so much all your help!
>
> Best regards,
> J.G.
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: Serial Port (RS-232)
  2009-01-27 15:59 Serial Port (RS-232) Jaime Garcia
  2009-01-27 16:20 ` Jai Sharma
@ 2009-01-27 16:35 ` Tiago Maluta
  2009-01-27 17:13 ` Michael Iatrou
  2 siblings, 0 replies; 10+ messages in thread
From: Tiago Maluta @ 2009-01-27 16:35 UTC (permalink / raw)
  To: linux-c-programming; +Cc: Jaime Garcia

> Hi Friends,
> I am pretty new to Linux programming, I want to start doing
> something
> useful, so I was thinking to start programming the serial
> port (RS-232) of
> my box, so I can read and write data from it, can someone
> of you give some

A good start is reading Michael R. Sweet's guide [1] on Serial Programming for POSIX Operating Systems 

[1] http://www.easysw.com/~mike/serial/serial.html

For a complete reference, I use The Linux Documentation Project (TLDP) section about Serial [2]  

[2] http://tldp.org/HOWTO/Serial-HOWTO.html


--
Tiago Maluta


      

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

* RE: Serial Port (RS-232)
  2009-01-27 16:20 ` Jai Sharma
@ 2009-01-27 16:46   ` Jaime Garcia
  0 siblings, 0 replies; 10+ messages in thread
From: Jaime Garcia @ 2009-01-27 16:46 UTC (permalink / raw)
  To: 'Jai Sharma'; +Cc: linux-c-programming

Thank you Jai, I think I will start from here!

Regards!

> -----Mensaje original-----
> De: linux-c-programming-owner@vger.kernel.org [mailto:linux-c-
> programming-owner@vger.kernel.org] En nombre de Jai Sharma
> Enviado el: Martes, 27 de Enero de 2009 10:20 a.m.
> Para: Jaime Garcia
> CC: linux-c-programming@vger.kernel.org
> Asunto: Re: Serial Port (RS-232)
> 
> hi
> 
> use following link
> http://www.easysw.com/~mike/serial/serial.html
> 
> 
> 
> On Tue, Jan 27, 2009 at 9:29 PM, Jaime Garcia <jgarcia@vali.com.mx>
> wrote:
> > Hi Friends,
> > I am pretty new to Linux programming, I want to start doing something
> > useful, so I was thinking to start programming the serial port (RS-
> 232) of
> > my box, so I can read and write data from it, can someone of you give
> some
> > feedback about how to start this? I will appreciate so much all your
> help!
> >
> > Best regards,
> > J.G.
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-c-
> programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-
> programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: Serial Port (RS-232)
  2009-01-27 15:59 Serial Port (RS-232) Jaime Garcia
  2009-01-27 16:20 ` Jai Sharma
  2009-01-27 16:35 ` Tiago Maluta
@ 2009-01-27 17:13 ` Michael Iatrou
  2009-01-27 17:33   ` Jaime Garcia
  2 siblings, 1 reply; 10+ messages in thread
From: Michael Iatrou @ 2009-01-27 17:13 UTC (permalink / raw)
  To: linux-c-programming; +Cc: Jaime Garcia

When the date was Tuesday 27 January 2009, Jaime Garcia wrote:

> Hi Friends,
> I am pretty new to Linux programming, I want to start doing something
> useful, so I was thinking to start programming the serial port (RS-232)
> of my box, so I can read and write data from it, can someone of you give
> some feedback about how to start this?

The keyword you are looking for is ``ioctl''.

-- 
 Michael Iatrou

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

* RE: Serial Port (RS-232)
  2009-01-27 17:13 ` Michael Iatrou
@ 2009-01-27 17:33   ` Jaime Garcia
  2009-01-28  0:56     ` Glynn Clements
  0 siblings, 1 reply; 10+ messages in thread
From: Jaime Garcia @ 2009-01-27 17:33 UTC (permalink / raw)
  To: linux-c-programming

Hello Michael,
Right now I opened man ioctl(2) to start looking for directions on this, I appreciate so much your tip, thanks a lot! =-)

Best regards!

> -----Mensaje original-----
> De: linux-c-programming-owner@vger.kernel.org [mailto:linux-c-
> programming-owner@vger.kernel.org] En nombre de Michael Iatrou
> Enviado el: Martes, 27 de Enero de 2009 11:14 a.m.
> Para: linux-c-programming@vger.kernel.org
> CC: Jaime Garcia
> Asunto: Re: Serial Port (RS-232)
> 
> When the date was Tuesday 27 January 2009, Jaime Garcia wrote:
> 
> > Hi Friends,
> > I am pretty new to Linux programming, I want to start doing something
> > useful, so I was thinking to start programming the serial port (RS-
> 232)
> > of my box, so I can read and write data from it, can someone of you
> give
> > some feedback about how to start this?
> 
> The keyword you are looking for is ``ioctl''.
> 
> --
>  Michael Iatrou
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-
> programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* RE: Serial Port (RS-232)
  2009-01-27 17:33   ` Jaime Garcia
@ 2009-01-28  0:56     ` Glynn Clements
  2009-01-28 15:16       ` Jaime Garcia
  0 siblings, 1 reply; 10+ messages in thread
From: Glynn Clements @ 2009-01-28  0:56 UTC (permalink / raw)
  To: Jaime Garcia; +Cc: linux-c-programming


Jaime Garcia wrote:

> > > I am pretty new to Linux programming, I want to start doing something
> > > useful, so I was thinking to start programming the serial port (RS-232)
> > > of my box, so I can read and write data from it, can someone of you give
> > > some feedback about how to start this?
> > 
> > The keyword you are looking for is ``ioctl''.
> 
> Right now I opened man ioctl(2) to start looking for directions on
> this, I appreciate so much your tip, thanks a lot! =-)

You probably don't need to use ioctl() unless you need to treat the
serial port as a general-purpose I/O port (e.g. manually setting the
control lines).

If you just want to talk to another serial device, open()ing one of
the /dev/ttyS* devices and using tcsetattr/tcgetattr will normally
suffice.

If you do need to use ioctl(), the ioctl(2) manpage won't help much,
as ioctl() is a generic interface to device-specific functionality. 
The tty_ioctl(4) manpage has details related to TTY (serial) ioctl()
commands.

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

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

* RE: Serial Port (RS-232)
  2009-01-28  0:56     ` Glynn Clements
@ 2009-01-28 15:16       ` Jaime Garcia
  2009-01-28 17:19         ` Glynn Clements
  0 siblings, 1 reply; 10+ messages in thread
From: Jaime Garcia @ 2009-01-28 15:16 UTC (permalink / raw)
  To: linux-c-programming

Hi Glynn,
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.

Best Regards!


> -----Mensaje original-----
> De: Glynn Clements [mailto:glynn@gclements.plus.com]
> Enviado el: Martes, 27 de Enero de 2009 06:57 p.m.
> Para: Jaime Garcia
> CC: linux-c-programming@vger.kernel.org
> Asunto: RE: Serial Port (RS-232)
> 
> 
> Jaime Garcia wrote:
> 
> > > > I am pretty new to Linux programming, I want to start doing
> something
> > > > useful, so I was thinking to start programming the serial port
> (RS-232)
> > > > of my box, so I can read and write data from it, can someone of
> you give
> > > > some feedback about how to start this?
> > >
> > > The keyword you are looking for is ``ioctl''.
> >
> > Right now I opened man ioctl(2) to start looking for directions on
> > this, I appreciate so much your tip, thanks a lot! =-)
> 
> You probably don't need to use ioctl() unless you need to treat the
> serial port as a general-purpose I/O port (e.g. manually setting the
> control lines).
> 
> If you just want to talk to another serial device, open()ing one of
> the /dev/ttyS* devices and using tcsetattr/tcgetattr will normally
> suffice.
> 
> If you do need to use ioctl(), the ioctl(2) manpage won't help much,
> as ioctl() is a generic interface to device-specific functionality.
> The tty_ioctl(4) manpage has details related to TTY (serial) ioctl()
> commands.
> 
> --
> Glynn Clements <glynn@gclements.plus.com>


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

* RE: Serial Port (RS-232)
  2009-01-28 15:16       ` Jaime Garcia
@ 2009-01-28 17:19         ` Glynn Clements
  2009-01-29  0:14           ` Jaime Garcia
  0 siblings, 1 reply; 10+ messages in thread
From: Glynn Clements @ 2009-01-28 17:19 UTC (permalink / raw)
  To: Jaime Garcia; +Cc: linux-c-programming


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>

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

* RE: Serial Port (RS-232)
  2009-01-28 17:19         ` Glynn Clements
@ 2009-01-29  0:14           ` Jaime Garcia
  0 siblings, 0 replies; 10+ messages in thread
From: Jaime Garcia @ 2009-01-29  0:14 UTC (permalink / raw)
  To: 'Glynn Clements'; +Cc: linux-c-programming

I'll give a try to this, thank you so much for the reply Glynn!

Regards!

> 
> 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>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-
> programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2009-01-29  0:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-01-29  0:14           ` Jaime Garcia

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).