0.1.1 DEVFULL

This commit is contained in:
rob tillaart 2022-07-02 12:50:15 +02:00
parent ad1bad2bdd
commit d4d2ed7e9f
6 changed files with 33 additions and 19 deletions

View File

@ -2,10 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
# - due
# - zero
# - leonardo
- due
- zero
- leonardo
- m4
- esp32
# - esp8266
# - mega2560
- esp8266
- mega2560

View File

@ -2,24 +2,33 @@
//
// FILE: DEVFULL.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// VERSION: 0.1.1
// PURPOSE: Arduino library for a /dev/full stream - useful for testing / debugging.
// URL: https://github.com/RobTillaart/DEVFULL
//
// HISTORY:
// 0.1.0 2022-03-11 initial version.
// 0.1.1 2022-07-01 add limits.h INT_MAX to support 32 bit int.
#include "Arduino.h"
#include "limits.h"
#define DEVFULL_LIB_VERSION (F("0.1.1"))
#define DEVFULL_LIB_VERSION (F("0.1.0"))
#ifndef ENOSPC
#define ENOSPC -28
#endif
#ifndef INT_MAX
#define INT_MAX 32767
#endif
class DEVFULL : public Stream
{
public:
@ -28,17 +37,18 @@ public:
setTimeout(0); // no timeout.
};
int available() { return 32767; };
int available() { return INT_MAX; };
int peek() { return 0; };
int read() { return 0; };
void flush() { return; }; // placeholder to keep CI happy
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)
size_t write( const uint8_t *buffer, size_t size)
{
dummy = buffer[size-1]; // keep compiler happy
return -28;

View File

@ -15,9 +15,7 @@ Arduino library for a /dev/full stream.
The experimental library implements a stream class that mimics the **/dev/full**
device of a Linux system. You can write nothing to it as it is always full.
Every read data will return the value zero, just like **/dev/zero**
The 0.1.0 version is a minimal implementation.
Every read data will return the value zero, just like **/dev/zero**.
Calls to **print()** and **println()** will be split up in multiple calls to **write()**.
This causes a return value of n x -28 ==> mostly a number in the 65xxx range
@ -25,10 +23,16 @@ This causes a return value of n x -28 ==> mostly a number in the 65xxx range
See - https://en.wikipedia.org/wiki//dev/full
## Versions
- 0.1.0 is a minimal implementation.
- 0.1.1 implements INT_MAX
## Interface
- **DEVFULL()** constructor, sets the timeout to zero.
- **int available()** always return 32767.
- **int available()** always return INT_MAX = platform dependant.
- **int peek()** always returns 0.
- **int read()** always returns 0.
- **void flush()** does nothing but keeps some compilers happy.

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/DEVFULL.git"
},
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=DEVFULL
version=0.1.0
version=0.1.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for a /dev/full stream

View File

@ -42,13 +42,13 @@ unittest(test_all)
{
DEVFULL df;
assertEqual(0x7FFF, df.available());
assertEqual(INT_MAX, df.available());
assertEqual(0x0000, df.peek());
assertEqual(0x0000, df.read());
assertEqual(-28, df.write('a'));
assertEqual(-28, df.write((const uint8_t*) "hello\n", 6));
assertEqual(-28, df.print("hello world"));
assertEqual(-56, df.println("hello world")); // -56 ==> two underlying write calls...
assertEqual(-28, df.print("hello world"));
assertEqual(-56, df.println("hello world")); // -56 ==> two underlying write calls...
}
unittest_main()