GY-63_MS5611/libraries/DEVNULL/README.md

75 lines
2.7 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/DEVNULL/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-11-25 06:55:36 -05:00
[![Arduino-lint](https://github.com/RobTillaart/DEVNULL/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DEVNULL/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/DEVNULL/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DEVNULL/actions/workflows/jsoncheck.yml)
2021-01-29 06:31:58 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DEVNULL/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DEVNULL.svg?maxAge=3600)](https://github.com/RobTillaart/DEVNULL/releases)
2021-11-25 06:55:36 -05:00
2021-01-29 06:31:58 -05:00
# DEVNULL
Arduino library for a /dev/null stream.
2021-01-29 06:31:58 -05:00
2021-11-25 06:55:36 -05:00
2021-01-29 06:31:58 -05:00
## Description
2021-11-25 06:55:36 -05:00
The library implements a stream class that mimics the **/dev/null**
device of a Linux system. You can write everything to it.
You can never read data from it as it always returns EOF (end of file);
2021-01-29 06:31:58 -05:00
2021-11-25 06:55:36 -05:00
The 0.1.0 version is a minimal implementation that can be optimized.
it implements the **write(const uint8_t data)** call and e.g. a float is still
2021-01-29 06:31:58 -05:00
converted to individual characters that are send one after another.
Strings and text send every byte.
The advantage is that printing takes time and e.g. one can use it to measure
the **print** class performance.
Performance can be increased by implementing all methods of the print interface
2021-11-25 06:55:36 -05:00
with only a return 0; (or at least **print(Type)** as the **println(T)** would only
call once extra for the "\n".
## Interface
- **DEVNULL()** constructor, sets the timeout to zero.
- **int available()** always return zero.
- **int peek()** always returns EOF.
- **int read()** always return EOF.
- **void flush()** does nothing but keeps some compilers happy.
- **size_t write(const uint8_t data)** implements print interface. returns 1.
2022-09-21 04:45:14 -04:00
- **size_t write( const uint8_t \*buffer, size_t size)** implements print interface.
Returns size.
- **int lastByte()** returns last byte written (debug and test purpose).
Returns -1 if no byte has been written yet.
2021-11-25 06:55:36 -05:00
2021-01-29 06:31:58 -05:00
## Operation
2021-11-25 06:55:36 -05:00
Use with care.
See examples.
## Future
2022-09-21 04:45:14 -04:00
#### Could
2021-11-25 06:55:36 -05:00
- add byte counter (uint32_t)
2022-09-21 04:45:14 -04:00
- investigate if DEVNULL can be used to harvest entropy?
- sum xor of all data + timestamp?
- enable / disable flag (complex)
- => /dev/entropy class?
- **flush()** could reset bottomLessPit to -1?
#### Wont
2021-11-25 06:55:36 -05:00
2022-09-21 04:45:14 -04:00
- add delay to mimic pause / tune behaviour for simulating devices
- microseconds
- delay per byte, esp long arrays might need other performance
- out of scope for /dev/null => separate class?
- implement Print class to increase performance?
- derived class?
2021-01-29 06:31:58 -05:00