mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-26 17:53:59 -04:00
AP_HAL_Linux: made UARTDriver use ConsoleDevice
This commit is contained in:
parent
a9c9d91f09
commit
de6b2b4bce
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "UARTDevice.h"
|
#include "UARTDevice.h"
|
||||||
#include "UDPDevice.h"
|
#include "UDPDevice.h"
|
||||||
|
#include "ConsoleDevice.h"
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
@ -39,8 +40,8 @@ LinuxUARTDriver::LinuxUARTDriver(bool default_console) :
|
|||||||
_flow_control(FLOW_CONTROL_DISABLE)
|
_flow_control(FLOW_CONTROL_DISABLE)
|
||||||
{
|
{
|
||||||
if (default_console) {
|
if (default_console) {
|
||||||
_rd_fd = 0;
|
_device = new ConsoleDevice();
|
||||||
_wr_fd = 1;
|
_device->open();
|
||||||
_console = true;
|
_console = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,10 +65,9 @@ void LinuxUARTDriver::begin(uint32_t b)
|
|||||||
void LinuxUARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
void LinuxUARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
||||||
{
|
{
|
||||||
if (device_path == NULL && _console) {
|
if (device_path == NULL && _console) {
|
||||||
_rd_fd = STDIN_FILENO;
|
_device = new ConsoleDevice();
|
||||||
_wr_fd = STDOUT_FILENO;
|
_device->open();
|
||||||
fcntl(_rd_fd, F_SETFL, fcntl(_rd_fd, F_GETFL, 0) | O_NONBLOCK);
|
_device->set_blocking(false);
|
||||||
fcntl(_wr_fd, F_SETFL, fcntl(_wr_fd, F_GETFL, 0) | O_NONBLOCK);
|
|
||||||
} else if (!_initialised) {
|
} else if (!_initialised) {
|
||||||
if (device_path == NULL) {
|
if (device_path == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -114,10 +114,9 @@ void LinuxUARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
|||||||
// Notify that the option is not valid and select standart input and output
|
// Notify that the option is not valid and select standart input and output
|
||||||
::printf("LinuxUARTDriver parsing failed, using default\n");
|
::printf("LinuxUARTDriver parsing failed, using default\n");
|
||||||
|
|
||||||
_rd_fd = STDIN_FILENO;
|
_device = new ConsoleDevice();
|
||||||
_wr_fd = STDOUT_FILENO;
|
_device->open();
|
||||||
fcntl(_rd_fd, F_SETFL, fcntl(_rd_fd, F_GETFL, 0) | O_NONBLOCK);
|
_device->set_blocking(false);
|
||||||
fcntl(_wr_fd, F_SETFL, fcntl(_wr_fd, F_GETFL, 0) | O_NONBLOCK);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user