Re: Need a simple protocol
- From: Tilmann Reh <tilmannreh@xxxxxxxxxxxxx>
- Date: Fri, 21 Jul 2006 08:59:07 +0200
Antonio Pasini schrieb:
Something like: Master sends <STX> data <ETX>. Slave answers with
<ACK> or <NAK>, and then <STX> data <ETX> if needed. "Data"
should be only visible 7-bit ASCII characters for additional
range checking.
First byte(s) of master data contain a command code, and the last
bytes a checksum (CRC-8 or the like). If the master does not
receive an <ACK>, or receives nothing, or receives data that
doesn't match the CRC, it simply retries for a given number
before it reports an error.
After some not-so-good experiences, now I am much more cautious in
reinventing a new protocol each time I need one.
I think that *robust* protocol design requires a little more thought
than what many think.
What happens for example if the slave receives a correct packet,
sends back ACK, but the master never receives it (for whatever
reason... line noise, etc) ? Well, that's why we have timeouts. Okay,
but... on timeout, master will think the packet has not been received
correctly, so it will resend the message. This time also the packet
arrives correctly, and the masters receives back the ACK. So, master
is happy, slave is happy. But slave received TWO packets instead of
the single one.
Suppose this was a "move +100 steps" command for a stepper
controller... bad move.
Of course that method implies that only "absolute" commands are used,
that can be repeated without misfunctions.
That would be direct i/o status data, or absolute positioning commands
for your example of a stepper motor.
With these restrictions in mind, the above is the simplest "proven"
protocol (IMHO).
Tilmann
--
http://www.autometer.de - Elektronik nach Maß.
.
- References:
- Need a simple protocol
- From: Daveb
- Re: Need a simple protocol
- From: Tilmann Reh
- Re: Need a simple protocol
- From: Steve at fivetrees
- Re: Need a simple protocol
- From: Antonio Pasini
- Need a simple protocol
- Prev by Date: Re: Splitting bidirectional pins?
- Next by Date: Re: Davicom Ethernet PHY
- Previous by thread: Re: Need a simple protocol
- Next by thread: Re: Need a simple protocol
- Index(es):
Relevant Pages
|
|