ardupilot/libraries/AP_HAL_Linux/ConsoleDevice.h
Staroselskii Georgii 4ca1b58408 AP_HAL_Linux: add ConsoleDevice a handler for TTIN signal
In a case ArduPilot is launched as a background process without
detaching with *nohup* like this ./arduplane -C /dev/ttyAMA0 ConsoleDevice
is created and an attempt to read from it is made. This yields in a stopped
process. This is an endeavour to overcome this problem.
2016-07-27 21:30:19 +10:00

25 lines
609 B
C++

#pragma once
#include "SerialDevice.h"
#include <AP_HAL/utility/Socket.h>
class ConsoleDevice: public SerialDevice {
public:
ConsoleDevice();
virtual ~ConsoleDevice();
virtual bool open() override;
virtual bool close() override;
virtual ssize_t write(const uint8_t *buf, uint16_t n) override;
virtual ssize_t read(uint8_t *buf, uint16_t n) override;
virtual void set_blocking(bool blocking) override;
virtual void set_speed(uint32_t speed) override;
private:
int _rd_fd = -1;
int _wr_fd = -1;
bool _closed = true;
bool _set_signal_handlers(void) const;
};