diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-06-03 00:38:09 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-01-18 09:25:04 +0100 |
commit | bbdbda0a7442545ab9022f2ec78e45f1d6750f38 (patch) | |
tree | 24e8f59a3d4aa1bf7a126e41e38706bfbac7ea68 /include/ratp.h | |
parent | 51e97d11dc81e12c2d8bddc1e79f6d40de49f3de (diff) | |
download | barebox-bbdbda0a7442545ab9022f2ec78e45f1d6750f38.tar.gz |
Add Reliable Asynchronous Transfer Protocol
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 with one exception. RFC916 uses a plain checksum for the
transferred data. We decided to use CRC16 for greater robustness. Since
this is the only RFC916 implementation we currently know of interoperability
with other implementations should not matter.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Diffstat (limited to 'include/ratp.h')
-rw-r--r-- | include/ratp.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/ratp.h b/include/ratp.h new file mode 100644 index 0000000000..b91d305a22 --- /dev/null +++ b/include/ratp.h @@ -0,0 +1,22 @@ +#ifndef __RATP_H +#define __RATP_H + +struct ratp { + struct ratp_internal *internal; + int (*send)(struct ratp *, void *pkt, int len); + int (*recv)(struct ratp *, uint8_t *data); +}; + +int ratp_establish(struct ratp *ratp, bool active, int timeout_ms); +void ratp_close(struct ratp *ratp); +int ratp_recv(struct ratp *ratp, void **data, size_t *len); +int ratp_send(struct ratp *ratp, const void *data, size_t len); +int ratp_send_complete(struct ratp *ratp, const void *data, size_t len, + void (*complete)(void *ctx, int status), void *complete_ctx); +int ratp_poll(struct ratp *ratp); +bool ratp_closed(struct ratp *ratp); +bool ratp_busy(struct ratp *ratp); + +void ratp_run_command(void); + +#endif /* __RATP_H */ |