-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEVFULL.h
59 lines (41 loc) · 999 Bytes
/
DEVFULL.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
//
// FILE: DEVFULL.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// PURPOSE: Arduino library for a /dev/full stream - useful for testing / debugging.
// URL: https://github.com/RobTillaart/DEVFULL
#include "Arduino.h"
#include "limits.h"
#define DEVFULL_LIB_VERSION (F("0.1.3"))
#ifndef ENOSPC
#define ENOSPC -28
#endif
#ifndef INT_MAX
#define INT_MAX 32767
#endif
class DEVFULL : public Stream
{
public:
DEVFULL()
{
setTimeout(0); // no timeout.
};
int available() { return INT_MAX; };
int peek() { return 0; };
int read() { return 0; };
void flush() { return; }; // placeholder to keep build CI happy
size_t write(const uint8_t data)
{
dummy = data; // keep compiler happy
return -28;
};
size_t write( const uint8_t *buffer, size_t size)
{
dummy = buffer[size-1]; // keep compiler happy
return -28;
};
private:
uint8_t dummy;
};
// -- END OF FILE --