12#define MAX_FDBUFFER_FIFO_BUFFERS (20)
20 virtual int read(
char *buf,
int nbytes) = 0;
21 virtual int write(
const char *buf,
int nbytes) = 0;
22 virtual int close() = 0;
23 static int sread(
int fd,
char *buf,
int nbytes);
24 static int swrite(
int fd,
const char *buf,
int nbytes);
25 static int sclose(
int fd);
26 static fd_adapter *GetFromFD(
int fd);
29 fd_adapter() {my_fd=0; inDtor =
false;};
35 ~fd_adapter() { inDtor =
true;
if (my_fd) ::close(my_fd); };
36 operator int() {
if(my_fd==0) GetActiveFD();
return my_fd;};
41class FDCounter :
public fd_adapter
45 virtual int read(
char *buf,
int nbytes);
46 virtual int write(
const char *buf,
int nbytes);
50 FDCounter() { nwr = 0; };
51 ~FDCounter() {
if (my_fd) ::close(my_fd); }
53 int SpaceUsed() {
return nwr; };
56class FDFlash :
public fd_adapter
64 virtual int read(
char *buf,
int nbytes);
65 virtual int write(
const char *buf,
int nbytes);
80 uint32_t cs() {
return m_cs; };
82 uint32_t len() {
return m_len; };
85class FDBuffer :
public fd_adapter
87 fifo_buffer_storage bs{MAX_FDBUFFER_FIFO_BUFFERS, 0};
90 int read(
char *buf,
int nbytes)
override;
91 int write(
const char *buf,
int nbytes)
override;
97 bs.Reset(MAX_FDBUFFER_FIFO_BUFFERS);
101 bool StreamTo(
int fd);
103 FDBuffer() { nwr = 0; };
105 int SpaceUsed() {
return nwr; };
108class FDcBuf :
public fd_adapter
118 int read(
char *buf,
int nbytes)
override;
119 int write(
const char *buf,
int nbytes)
override;
120 int close()
override;
130 FDcBuf(uint8_t *buf,
int _bufLen,
int _blockWaitSkip = 1)
131 : cbuf(buf), rdIdx(0), wrIdx(0), bufLen(_bufLen),
132 blockWaitSkip(_blockWaitSkip), empty(true)
141 inline int SpaceUsed() {
return wrIdx - rdIdx + ((rdIdx > wrIdx)*bufLen); };
NetBurner I/O System Library API.
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition nbrtos.h:1084