Re: How to check activity of /dev/ttyS0 (or other serial ports)
- From: floyd@xxxxxxxxxx (Floyd L. Davidson)
- Date: Sun, 16 Apr 2006 17:22:45 -0800
"insomniux" <dispose01@xxxxxxxxxxxxxx> wrote:
Hi,
I'm working on some apps (in C) to communicate with a weather-station
(temp & humidity measurements) through one of the serial ports
(/dev/ttyS0). This device, however is very sensitive to communications
(if you read too much data at once, it may hang and needs a hard
reset).
Lets start at this point, and rethink what is needed (and just
sort of dump the rest of your post).
The device at the other end of a serial link cannot know how
much data you have tried to read. Therefore it *cannot* be
hanging because "you read too much data at once". If it is
indeed hanging, it is for some other reason. Or, it may not be
hanging at all... but the process of resetting it causes the
serial port on the computer to be "unhung"???
The most likely scenario is that your serial port configuration
is not right, and the way you are reading data probably hangs
your software. That is a relatively common part of the learning
curve for programming serial port comm links!
Sooo... if you haven't modularized your program, now is the
time. And then post the functions you use to open the port,
configure the port, read from the port, and write to the port.
You don't have to post a complete program, but each module
should pretty much stand alone as complete.
Here is an excellent tutorial on POSIX serial port programming,
http://www.easysw.com/~mike/serial/serial.html
Here are some coding examples on my own web page,
http://www.apaflo.com/floyd_davidson/code/terminal/
And be aware that the Linux HOWTO for serial port programming is
an interesting read, but unfortunately has far too many errors
in the text and bugs in the code to be used directly as an
example.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@xxxxxxxxxx
.
- References:
- How to check activity of /dev/ttyS0 (or other serial ports)
- From: insomniux
- How to check activity of /dev/ttyS0 (or other serial ports)
- Prev by Date: mallinfo
- Next by Date: Re: How to check activity of /dev/ttyS0 (or other serial ports)
- Previous by thread: How to check activity of /dev/ttyS0 (or other serial ports)
- Next by thread: Re: How to check activity of /dev/ttyS0 (or other serial ports)
- Index(es):
Relevant Pages
|