mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.1 DEVFULL
This commit is contained in:
parent
ad1bad2bdd
commit
d4d2ed7e9f
@ -2,10 +2,10 @@ compile:
|
|||||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||||
platforms:
|
platforms:
|
||||||
- uno
|
- uno
|
||||||
# - due
|
- due
|
||||||
# - zero
|
- zero
|
||||||
# - leonardo
|
- leonardo
|
||||||
- m4
|
- m4
|
||||||
- esp32
|
- esp32
|
||||||
# - esp8266
|
- esp8266
|
||||||
# - mega2560
|
- mega2560
|
@ -2,24 +2,33 @@
|
|||||||
//
|
//
|
||||||
// FILE: DEVFULL.h
|
// FILE: DEVFULL.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.1.0
|
// VERSION: 0.1.1
|
||||||
// PURPOSE: Arduino library for a /dev/full stream - useful for testing / debugging.
|
// PURPOSE: Arduino library for a /dev/full stream - useful for testing / debugging.
|
||||||
// URL: https://github.com/RobTillaart/DEVFULL
|
// URL: https://github.com/RobTillaart/DEVFULL
|
||||||
//
|
//
|
||||||
// HISTORY:
|
// HISTORY:
|
||||||
// 0.1.0 2022-03-11 initial version.
|
// 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 "Arduino.h"
|
||||||
|
#include "limits.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define DEVFULL_LIB_VERSION (F("0.1.1"))
|
||||||
|
|
||||||
#define DEVFULL_LIB_VERSION (F("0.1.0"))
|
|
||||||
|
|
||||||
#ifndef ENOSPC
|
#ifndef ENOSPC
|
||||||
#define ENOSPC -28
|
#define ENOSPC -28
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INT_MAX
|
||||||
|
#define INT_MAX 32767
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class DEVFULL : public Stream
|
class DEVFULL : public Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -28,17 +37,18 @@ public:
|
|||||||
setTimeout(0); // no timeout.
|
setTimeout(0); // no timeout.
|
||||||
};
|
};
|
||||||
|
|
||||||
int available() { return 32767; };
|
int available() { return INT_MAX; };
|
||||||
int peek() { return 0; };
|
int peek() { return 0; };
|
||||||
int read() { 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)
|
size_t write(const uint8_t data)
|
||||||
{
|
{
|
||||||
dummy = data; // keep compiler happy
|
dummy = data; // keep compiler happy
|
||||||
return -28;
|
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
|
dummy = buffer[size-1]; // keep compiler happy
|
||||||
return -28;
|
return -28;
|
||||||
|
@ -15,9 +15,7 @@ Arduino library for a /dev/full stream.
|
|||||||
|
|
||||||
The experimental library implements a stream class that mimics the **/dev/full**
|
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.
|
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**
|
Every read data will return the value zero, just like **/dev/zero**.
|
||||||
|
|
||||||
The 0.1.0 version is a minimal implementation.
|
|
||||||
|
|
||||||
Calls to **print()** and **println()** will be split up in multiple calls to **write()**.
|
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
|
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
|
See - https://en.wikipedia.org/wiki//dev/full
|
||||||
|
|
||||||
|
|
||||||
|
## Versions
|
||||||
|
|
||||||
|
- 0.1.0 is a minimal implementation.
|
||||||
|
- 0.1.1 implements INT_MAX
|
||||||
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
|
|
||||||
- **DEVFULL()** constructor, sets the timeout to zero.
|
- **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 peek()** always returns 0.
|
||||||
- **int read()** always returns 0.
|
- **int read()** always returns 0.
|
||||||
- **void flush()** does nothing but keeps some compilers happy.
|
- **void flush()** does nothing but keeps some compilers happy.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/DEVFULL.git"
|
"url": "https://github.com/RobTillaart/DEVFULL.git"
|
||||||
},
|
},
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=DEVFULL
|
name=DEVFULL
|
||||||
version=0.1.0
|
version=0.1.1
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino library for a /dev/full stream
|
sentence=Arduino library for a /dev/full stream
|
||||||
|
@ -42,13 +42,13 @@ unittest(test_all)
|
|||||||
{
|
{
|
||||||
DEVFULL df;
|
DEVFULL df;
|
||||||
|
|
||||||
assertEqual(0x7FFF, df.available());
|
assertEqual(INT_MAX, df.available());
|
||||||
assertEqual(0x0000, df.peek());
|
assertEqual(0x0000, df.peek());
|
||||||
assertEqual(0x0000, df.read());
|
assertEqual(0x0000, df.read());
|
||||||
assertEqual(-28, df.write('a'));
|
assertEqual(-28, df.write('a'));
|
||||||
assertEqual(-28, df.write((const uint8_t*) "hello\n", 6));
|
assertEqual(-28, df.write((const uint8_t*) "hello\n", 6));
|
||||||
assertEqual(-28, df.print("hello world"));
|
assertEqual(-28, df.print("hello world"));
|
||||||
assertEqual(-56, df.println("hello world")); // -56 ==> two underlying write calls...
|
assertEqual(-56, df.println("hello world")); // -56 ==> two underlying write calls...
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest_main()
|
unittest_main()
|
||||||
|
Loading…
Reference in New Issue
Block a user