[PATCH 1/4] Add Reliable Asynchronous Transfer Protocol

Sascha Hauer s.hauer at pengutronix.de
Sun Jun 14 22:12:02 PDT 2015


On Fri, Jun 12, 2015 at 02:05:04PM +0200, Peter Korsgaard wrote:
> >>>>> "Sascha" == Sascha Hauer <s.hauer at pengutronix.de> writes:
> 
>  > This patch adds support for Reliable Asynchronous Transfer Protocol (RATP)
>  > as described in RFC916.
> 
>  > Communication over RS232 is often unreliable as characters are lost or
>  > misinterpreted. This protocol allows for a reliable packet based communication
>  > over serial lines.
> 
>  > The implementation simply follows the state machine described in the RFC text.
> 
> Almost ;)
> 
> > +static int ratp_recv_pkt_data(struct ratp *ratp, void *data, uint8_t len,
>  > +		int poll_timeout_ms)
>  > +{
>  > +	uint16_t crc_expect, crc_read;
>  > +	int ret, i;
>  > +
>  > +	for (i = 0; i < len + 2; i++) {
>  > +		ret = ratp_getc(ratp, data + i, poll_timeout_ms);
>  > +		if (ret < 0)
>  > +			return ret;
>  > +	}
>  > +
>  > +	crc_expect = cyg_crc16(data, len);
> 
> Why crc16? RFC916 states that the checksum is the inverted 1s complement
> 16bit sum, E.G. like TCP/UDP/IP header checksums:

Indeed CRC16 is not correct here according to RFC916. We can implement
the original checksum algorithm, I'm not sure if that's a good idea
though. Plain checksumming does not detect lost 0 characters.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list