Re: Need a simple protocol



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



Relevant Pages

  • Re: Implementing communication over RS-485
    ... as long as the master communicates with the same ... slave using multiple transactions. ... next command to slave 2, if slave 2 does not detect the pause between ... you would have to fiddle with the odd/even parity setting ...
    (comp.arch.embedded)
  • Re: Does a PIC16F628 Serial Port Go To Sleep?
    ... and the "F" is the command. ... The slave with that serial ... The master uses SERIN to receive the "FOK" and knows that the ... > The RF modems are serial RF modems running at 9600 baud, ...
    (comp.arch.embedded)
  • Re: project BIG AppleCrate
    ... request page "123.123.123.123/NADAOPEN FILE ... webserver gets command, recognizes it as being for NadaNet. ... It sends the command over a serial connection to the Master ... the webpage used to control this internet enabled NadaNet could ...
    (comp.sys.apple2)
  • Re: one Devicenet Question please
    ... > Your slave application should also know that it needs to send ... > the Poll Response after receiving the Poll command. ... ie master sends a grp2 command with msgID 101 along with slave's MAC ...
    (comp.arch.embedded)
  • Re: AARRRGGHHH! (was Re: TIMEOUT - WRITE_DMA errors in security output)
    ... > Master: no device present ... > Slave: no device present ... > ATA/ATAPI revision 6 ... that was definitely the wrong command. ...
    (freebsd-questions)