Re: serial ports: how do I know data has been sent?
- From: James Carlson <james.d.carlson@xxxxxxx>
- Date: 18 Jan 2006 08:16:17 -0500
"Simon Elliott" <Simon at ctsn.co.uk> writes:
> A couple of examples from real life, where luckily I was using DOS and
> could therefore do whatever I wanted with the serial ports:
>
> 1/ Controlling a network of pressure transducers which used RS485, from
> a PC serial port via a RS232-485 converter which IIRC used RTS to grab
> the bus. It was fairly important to drop RTS _after_ the last character
> had been sent, but not too long after.
That's a line discipline. Having an RTS envelope on the data (and
presumably listening to CTS in response to RTS) is a well-known
standard RS-232 behavior. It's _not_ the default way that modems are
typically used -- which is more of an industry standard than an actual
standard -- but it's defined by the written standards themselves.
It should be selectable and, in my opinion, implemented as a part of
the system itself. In other words, likely in the kernel, and
certainly not part of an application program. It's an architectural
issue.
> 2/ Controlling a data collection device which continously transmitted
> garbage till it had been sent a "wake up" command.
I think the best you can do is send the special command, drain, then
flush pending input. Even then, it's possible that you could get
confused by timing elements that don't work out well.
Assuming that the "good" data has some pattern to it, you might be
able to repeat that command (or some "no-op" type command) until
you're in sync. That should cover most of the important cases of
confusion. If it has no usable pattern, then I think you may be sunk.
A separate but related issue here is what to do if the data you
receive some time *after* that "wake up" sequence are garbled.
Hardware isn't perfect, and errors do happen. You need a scheme that
will allow you to detect this problem and recover from it. I suspect
it's likely that this scheme, if it's robust at all, would cover for
the start-up confusion problem as well.
(This sounds a bit like a typical mouse or keyboard. They can be hard
to deal with at times.)
--
James Carlson, KISS Network <james.d.carlson@xxxxxxx>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
.
- Follow-Ups:
- Re: serial ports: how do I know data has been sent?
- From: Simon Elliott
- Re: serial ports: how do I know data has been sent?
- References:
- serial ports: how do I know data has been sent?
- From: Simon Elliott
- Re: serial ports: how do I know data has been sent?
- From: David Schwartz
- Re: serial ports: how do I know data has been sent?
- From: Simon Elliott
- serial ports: how do I know data has been sent?
- Prev by Date: argp error during include
- Next by Date: Re: How to implement a function to copy file on LINUX ?
- Previous by thread: Re: serial ports: how do I know data has been sent?
- Next by thread: Re: serial ports: how do I know data has been sent?
- Index(es):
Relevant Pages
|