Re: How to check activity of /dev/ttyS0 (or other serial ports)



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



Relevant Pages

  • Re: Reading serial ports
    ... >Also note that the serial port programming howto is filled ... Lot of thanks for the responses ...
    (comp.os.linux.development.apps)
  • Re: Serial port handling.
    ... file transfer protocols. ... > I am just learning serial port programming, so first i wrote a dumb ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Serial port handling.
    ... I am just learning serial port programming, so first i wrote a dumb ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: IR Libraries
    ... > Currently, .Net Framework did not have build-in support for this, what we ... > can do is P/invoke CreateFile Win32 API to communicate with IR Port, ... please refer to below article: ... > But, in .Net 2.0, Serial Port communication is added in, for more ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: What is Hyperterminal for?
    ... John, Hyperterminal is a useful little program that can be used to communicate directly with a modem, a serial port, to link two PCs together via serial ports etc. ... Also, FWIW, I've found that the versions of Hyperterminal that ship with Win2K/XP do not properly support F# key inputs on some terminal sessions, however the version that ships with Win9x runs and works fine under 2K/XP and supports all the F# key inputs. ...
    (microsoft.public.windowsxp.general)