AP_HAL: remove unused peek() interface from UART drivers

this is a bit tricky to implement on some platforms, and is unused
anyway
This commit is contained in:
Andrew Tridgell 2013-01-16 14:43:18 +11:00
parent e852d6300f
commit 76092eb590
21 changed files with 1 additions and 81 deletions

View File

@ -15,10 +15,9 @@ public:
* FastSerial library. As far as concerns go, it belongs with available() */
virtual int16_t txspace() = 0;
/* return value for read() and peek() :
/* return value for read():
* -1 if nothing available, uint8_t value otherwise. */
virtual int16_t read() = 0;
virtual int16_t peek() = 0;
};

View File

@ -77,10 +77,6 @@ int16_t AVRConsoleDriver::read() {
return _base_uart->read();
}
int16_t AVRConsoleDriver::peek() {
return _base_uart->peek();
}
// Print method implementations /////////////////////////////////////////
size_t AVRConsoleDriver::write(uint8_t c) {

View File

@ -30,7 +30,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* Implementations of Print virtual methods */
size_t write(uint8_t c);

View File

@ -150,16 +150,6 @@ int16_t AVRUARTDriver::read(void) {
return (c);
}
int16_t AVRUARTDriver::peek(void) {
// if the head and tail are equal, the buffer is empty
if (!_open || (_rxBuffer->head == _rxBuffer->tail))
return (-1);
// pull character from tail
return (_rxBuffer->bytes[_rxBuffer->tail]);
}
void AVRUARTDriver::flush(void) {
// don't reverse this or there may be problems if the RX interrupt
// occurs after reading the value of _rxBuffer->head but before writing

View File

@ -55,7 +55,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* Implementations of Print virtual methods */
size_t write(uint8_t c);

View File

@ -95,11 +95,6 @@ int16_t SITLConsoleDriver::read()
return _base_uart->read();
}
int16_t SITLConsoleDriver::peek()
{
return _base_uart->peek();
}
// Print method implementations /////////////////////////////////////////
size_t SITLConsoleDriver::write(uint8_t c)

View File

@ -32,7 +32,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* Implementations of Print virtual methods */
size_t write(uint8_t c);

View File

@ -139,11 +139,6 @@ int16_t SITLUARTDriver::read(void)
return -1;
}
int16_t SITLUARTDriver::peek(void)
{
return -1;
}
void SITLUARTDriver::flush(void)
{
}

View File

@ -53,7 +53,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* Implementations of Print virtual methods */
size_t write(uint8_t c);

View File

@ -66,10 +66,6 @@ int16_t EmptyConsoleDriver::read() {
return _d->read();
}
int16_t EmptyConsoleDriver::peek() {
return _d->peek();
}
size_t EmptyConsoleDriver::write(uint8_t c) {
return _d->write(c);
}

View File

@ -23,7 +23,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
size_t write(uint8_t c);
private:

View File

@ -25,7 +25,6 @@ void EmptyUARTDriver::vprintf_P(const prog_char *pstr, va_list ap) {}
int16_t EmptyUARTDriver::available() { return 0; }
int16_t EmptyUARTDriver::txspace() { return 1; }
int16_t EmptyUARTDriver::read() { return -1; }
int16_t EmptyUARTDriver::peek() { return -1; }
/* Empty implementations of Print virtual methods */
size_t EmptyUARTDriver::write(uint8_t c) { return 0; }

View File

@ -29,7 +29,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* Empty implementations of Print virtual methods */
size_t write(uint8_t c);

View File

@ -71,10 +71,6 @@ int16_t PX4ConsoleDriver::read() {
return _uart->read();
}
int16_t PX4ConsoleDriver::peek() {
return _uart->peek();
}
size_t PX4ConsoleDriver::write(uint8_t c) {
return _uart->write(c);
}

View File

@ -24,7 +24,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
size_t write(uint8_t c);

View File

@ -130,10 +130,6 @@ int16_t PX4UARTDriver::read() {
return -1;
}
int16_t PX4UARTDriver::peek() {
return -1;
}
/* PX4 implementations of Print virtual methods */
size_t PX4UARTDriver::write(uint8_t c) {
if (!_initialised) {

View File

@ -29,7 +29,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* PX4 implementations of Print virtual methods */
size_t write(uint8_t c);

View File

@ -125,15 +125,6 @@ int16_t SMACCMConsoleDriver::read()
}
}
int16_t SMACCMConsoleDriver::peek()
{
if (_user_backend) {
return _rxbuf.peek();
} else {
return _d->peek();
}
}
size_t SMACCMConsoleDriver::write(uint8_t c)
{
if (_user_backend) {
@ -192,15 +183,6 @@ int16_t SMACCMConsoleDriver::Buffer::pop()
return (int16_t) b;
}
int16_t SMACCMConsoleDriver::Buffer::peek()
{
if ( _tail == _head ) {
return -1;
}
uint8_t b = _bytes[_tail];
return (int16_t) b;
}
uint16_t SMACCMConsoleDriver::Buffer::bytes_used()
{
return ((_head - _tail) & _mask);

View File

@ -32,7 +32,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
size_t write(uint8_t c);
private:
@ -44,7 +43,6 @@ private:
bool allocate(uint16_t size);
bool push(uint8_t b);
int16_t pop();
int16_t peek();
uint16_t bytes_free();
uint16_t bytes_used();

View File

@ -146,19 +146,6 @@ int16_t SMACCMUARTDriver::read()
return (int16_t)c;
}
int16_t SMACCMUARTDriver::peek()
{
uint8_t c;
if (m_dev == NULL)
return -1;
if (!usart_peek(m_dev, &c))
return -1;
return (int16_t)c;
}
/* SMACCM implementations of Print virtual methods */
size_t SMACCMUARTDriver::write(uint8_t c)
{

View File

@ -36,7 +36,6 @@ public:
int16_t available();
int16_t txspace();
int16_t read();
int16_t peek();
/* SMACCM implementations of Print virtual methods */
size_t write(uint8_t c);