diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2015-11-05 13:54:49 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2015-11-05 13:54:49 +0900 |
commit | fd8aee3cb0f9243f600b9576863ad5c8457529b6 (patch) | |
tree | e45ff1440e32ca45c7dd5254d5ca49cb6b8b341d /example-cdc/stream.h | |
parent | a30a069ed8e75f14b520b407b07a3f137b87ef1c (diff) |
CDC to be echo service.
Diffstat (limited to 'example-cdc/stream.h')
-rw-r--r-- | example-cdc/stream.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/example-cdc/stream.h b/example-cdc/stream.h new file mode 100644 index 0000000..15cbe63 --- /dev/null +++ b/example-cdc/stream.h @@ -0,0 +1,24 @@ +#define BUFSIZE 128 +#define FLAG_CONNECTED (1 << 0) +#define FLAG_SEND_AVAIL (1 << 1) +#define FLAG_RECV_AVAIL (1 << 2) + +/* + * Current implementation is synchronous and buffers are not yet used. + */ +struct stream { + chopstx_mutex_t mtx; + chopstx_cond_t cnd; + uint8_t buf_send[BUFSIZE]; /* Not yet used. */ + uint8_t buf_recv[BUFSIZE]; /* Not yet used. */ + uint8_t cnt_send_head; /* Not yet used. */ + uint8_t cnt_send_tail; /* Not yet used. */ + uint8_t cnt_recv_head; /* Not yet used. */ + uint8_t cnt_recv_tail; /* Not yet used. */ + uint32_t flags; +}; + +struct stream *stream_open (void); +int stream_wait_connection (struct stream *st); +int stream_send (struct stream *st, uint8_t *buf, uint8_t count); +int stream_recv (struct stream *st, uint8_t *buf); |