-
Notifications
You must be signed in to change notification settings - Fork 2
/
wrStream.h
35 lines (30 loc) · 1.04 KB
/
wrStream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
// a wrapper over get/set functions into a stream - an 'interface' (?)
// uses a request/respond model to enable deferred access
// usage:
// the server should create a local wrStream_t
// server provides an 'init' function that returns wrStream_t*
// client accepts wrStream_t* and augments it with response & error fnptrs.
typedef enum{ DIR_READ
, DIR_WRITE
} wrStream_DIR_t;
typedef int (*wrStream_OC_t)( void );
typedef int (*wrStream_RR_t)( wrStream_DIR_t direction
, int location
, int size_in_bytes
, uint8_t* data );
typedef void (*wrStream_ER_t)( int errorcode, char* msg );
typedef struct{
wrStream_OC_t open;
wrStream_OC_t close;
wrStream_OC_t busy;
wrStream_RR_t request;
wrStream_RR_t response;
wrStream_ER_t error;
} wrStream_t;
typedef struct{
wrStream_DIR_t direction;
int location;
int size_in_bytes;
uint8_t* data;
} wrStream_PACKET_t;