HAL_SITL: implement a dummy buffered write

This commit is contained in:
Andrew Tridgell 2013-10-02 17:36:54 +10:00
parent a59f505d25
commit c035eef845
4 changed files with 14 additions and 0 deletions

View File

@ -59,5 +59,8 @@ size_t SITLConsoleDriver::write(uint8_t c)
return _base_uart->write(c);
}
size_t SITLConsoleDriver::write(const uint8_t *buffer, size_t size) {
return _base_uart->write(buffer, size);
}
#endif

View File

@ -24,6 +24,7 @@ public:
/* Implementations of Print virtual methods */
size_t write(uint8_t c);
size_t write(const uint8_t *buffer, size_t size);
private:
AP_HAL::UARTDriver* _base_uart;

View File

@ -174,6 +174,15 @@ size_t SITLUARTDriver::write(uint8_t c)
return send(_fd, &c, 1, flags);
}
size_t SITLUARTDriver::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
n += write(*buffer++);
}
return n;
}
/*
start a TCP connection for the serial port. If wait_for_connection
is true then block until a client connects

View File

@ -46,6 +46,7 @@ public:
/* Implementations of Print virtual methods */
size_t write(uint8_t c);
size_t write(const uint8_t *buffer, size_t size);
// file descriptor, exposed so SITL_State::loop_hook() can use it
int _fd;