AP_HAL_Linux: do not create ConsoleDevices for Replay or examples

Uusally problems evidence themsleves with stdin not working correctly -
for example, "git add -p" skipping through all queries as if the
user was just pressing enter.
This commit is contained in:
Peter Barker 2020-03-12 14:23:01 +11:00 committed by Andrew Tridgell
parent 21e93dae34
commit a3e2e156e7
2 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include "ConsoleDevice.h"
#include <AP_Vehicle/AP_Vehicle_Type.h>
ConsoleDevice::ConsoleDevice()
{
@ -27,6 +28,13 @@ bool ConsoleDevice::close()
bool ConsoleDevice::open()
{
#if APM_BUILD_TYPE(APM_BUILD_Replay) || APM_BUILD_TYPE(APM_BUILD_UNKNOWN)
// we do not want a ConsoleDevice for Replay or any examples. It
// screws up the terminal settings and creates all sorts of
// weirdnesses in Replay's output.
return false;
#endif
_rd_fd = STDIN_FILENO;
_wr_fd = STDOUT_FILENO;

View File

@ -79,7 +79,9 @@ void UARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
if (!_connected) {
_connected = _device->open();
_device->set_blocking(false);
if (_connected) {
_device->set_blocking(false);
}
}
_initialised = false;