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

61 lines
849 B
C++
Raw Normal View History

2022-09-21 04:45:14 -04:00
//
// FILE: DEVNULL.cpp
// AUTHOR: Rob Tillaart
2022-10-31 14:46:02 -04:00
// VERSION: 0.1.5
2022-09-21 04:45:14 -04:00
// PURPOSE: Arduino library for a /dev/null stream - useful for testing
// URL: https://github.com/RobTillaart/DEVNULL
//
2022-10-31 14:46:02 -04:00
// HISTORY: see changelog.md
2022-09-21 04:45:14 -04:00
#include "DEVNULL.h"
DEVNULL::DEVNULL()
{
setTimeout(0); // no timeout.
_bottomLessPit = -1; // nothing in the pit
}
2022-10-31 14:46:02 -04:00
int DEVNULL::available()
{
return 0;
};
int DEVNULL::peek()
{
return EOF;
};
int DEVNULL::read()
{
return EOF;
};
2022-09-21 04:45:14 -04:00
// placeholder to keep CI happy
2022-10-31 14:46:02 -04:00
void DEVNULL::flush()
{
return;
};
2022-09-21 04:45:14 -04:00
size_t DEVNULL::write(const uint8_t data)
{
_bottomLessPit = data;
return 1;
}
size_t DEVNULL::write( const uint8_t *buffer, size_t size)
{
if (size > 0) _bottomLessPit = buffer[size - 1];
return size;
}
int DEVNULL::lastByte()
{
return _bottomLessPit;
}
// -- END OF FILE --