HAL_Empty: implement a dummy buffered write

This commit is contained in:
Andrew Tridgell 2013-10-02 17:37:11 +10:00
parent c035eef845
commit a8c97f99d1
4 changed files with 20 additions and 0 deletions

View File

@ -40,3 +40,12 @@ size_t EmptyConsoleDriver::write(uint8_t c) {
return _d->write(c);
}
size_t EmptyConsoleDriver::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
n += write(*buffer++);
}
return n;
}

View File

@ -18,6 +18,7 @@ public:
int16_t read();
size_t write(uint8_t c);
size_t write(const uint8_t *buffer, size_t size);
private:
AP_HAL::BetterStream *_d;
};

View File

@ -20,3 +20,12 @@ int16_t EmptyUARTDriver::read() { return -1; }
/* Empty implementations of Print virtual methods */
size_t EmptyUARTDriver::write(uint8_t c) { return 0; }
size_t EmptyUARTDriver::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
n += write(*buffer++);
}
return n;
}

View File

@ -23,6 +23,7 @@ public:
/* Empty implementations of Print virtual methods */
size_t write(uint8_t c);
size_t write(const uint8_t *buffer, size_t size);
};
#endif // __AP_HAL_EMPTY_UARTDRIVER_H__