GY-63_MS5611/libraries/DEVNULL/DEVNULL.h

54 lines
1.1 KiB
C
Raw Normal View History

2021-01-29 06:31:58 -05:00
#pragma once
//
// FILE: DEVNULL.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
2021-11-25 06:55:36 -05:00
// PURPOSE: Arduino library for a /dev/null stream - useful for testing
2021-01-29 06:31:58 -05:00
// URL: https://github.com/RobTillaart/DEVNULL
//
// HISTORY:
2021-11-25 06:55:36 -05:00
// 0.1.0 2020-06-23 initial version.
// 0.1.1 2020-12-18 add Arduino-CI.
// 0.1.2 2021-11-24 update build-CI, badges, etc.
// added write(data, length) + _timeOut.
// 0.1.3 2021-12-15 update library.json, license, minor edits
2021-11-25 06:55:36 -05:00
2021-01-29 06:31:58 -05:00
#include "Arduino.h"
#define DEVNULL_LIB_VERSION (F("0.1.3"))
2021-11-25 06:55:36 -05:00
2021-01-29 06:31:58 -05:00
class DEVNULL : public Stream
{
public:
2021-11-25 06:55:36 -05:00
DEVNULL()
{
setTimeout(0); // no timeout.
};
2021-01-29 06:31:58 -05:00
int available() { return 0; };
int peek() { return EOF; };
int read() { return EOF; };
void flush() { return; }; // placeholder to keep CI happy
2021-11-25 06:55:36 -05:00
size_t write(const uint8_t data)
{
_bottomLessPit = data;
return 1;
};
size_t write( const uint8_t *buffer, size_t size)
{
if (size > 0) _bottomLessPit = buffer[size - 1];
2021-11-25 06:55:36 -05:00
return size;
};
2021-01-29 06:31:58 -05:00
private:
uint8_t _bottomLessPit;
};
2021-11-25 06:55:36 -05:00
2021-01-29 06:31:58 -05:00
// -- END OF FILE --
2021-11-25 06:55:36 -05:00