* C code - Dealing with a serial cable getting unplugged and plugged back in.
@ 2002-06-19 14:02 Harry Wilkinson
0 siblings, 0 replies; only message in thread
From: Harry Wilkinson @ 2002-06-19 14:02 UTC (permalink / raw)
To: linux-serial
Hi :)
A little intro to what I'm doing first:
I am writing some C functions that are wrapped up into a Python extension
module. The objective is just to read/write to/from a serial port in a very
simple way. I'm writing and testing this on Linux but it's probably going to
end up on Irix, and I'd like to be able to release this as open source when
it's all done, so I'm trying to keep it POSIX compatible. Everything is
working so far, the only thing left to fix (unless it's incredibly difficult
in which case we'll live with it) is that this program is going to be running
constantly, using the serial port a lot (this is for a phone system), and
there is a chance the serial port will get unplugged and plugged back in
sometimes.
Okay, on to the problem:
Currently, when I unplug the serial port, if the app is trying to send
something it will just send the data into a black hole and the data gets
lost. I was sort of hoping it would get buffered somewhere along the line
until the connection was back but I guess that isn't happening (I'm new to
this serial port stuff).
I'm using software flow control at the moment since that's all the cable I've
got at the moment will do. If necessary I can get a better cable and use
hardware flow control.
So, what I'd like to know is, how can I stop my data flowing out into the
abyss?
I can see two options at the moment, but I'm not sure how feasible either is,
at least in a POSIX-compatible way:
A) Set some settings on the serial port that tell it to wait until the
receiver is ready before it sends the data. This is good because I don't
have to change anything other than port settings when I call open() :)
B) Before I write data, make sure I wait until the connection is okay. I
don't know how to tell whether the connection is okay, however.
If anyone has any ideas on this I would really appreciate it :) This is my
first post to this list too, so I don't know if this is the right place to
ask. If not, please let me know where would be better :)
Thanks.
Harry Wilkinson
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-06-19 14:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-19 14:02 C code - Dealing with a serial cable getting unplugged and plugged back in Harry Wilkinson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox