mirror of https://github.com/ArduPilot/ardupilot
AP_HAL_Linux: Add support for setting uart parity on Linux boards
Pass set_parity down through UART class so that set_parity actually works for Linux boards.
This commit is contained in:
parent
5e683261a4
commit
100f06614c
|
@ -20,4 +20,7 @@ public:
|
|||
{
|
||||
/* most devices simply ignore this setting */
|
||||
};
|
||||
|
||||
/* Depends on lower level to implement, most devices are fine with defaults */
|
||||
virtual void set_parity(int v) { }
|
||||
};
|
||||
|
|
|
@ -130,3 +130,23 @@ void UARTDevice::set_flow_control(AP_HAL::UARTDriver::flow_control flow_control_
|
|||
|
||||
_flow_control = flow_control_setting;
|
||||
}
|
||||
|
||||
void UARTDevice::set_parity(int v)
|
||||
{
|
||||
struct termios t;
|
||||
tcgetattr(_fd, &t);
|
||||
if (v != 0) {
|
||||
// enable parity
|
||||
t.c_cflag |= PARENB;
|
||||
if (v == 1) {
|
||||
t.c_cflag |= PARODD;
|
||||
} else {
|
||||
t.c_cflag &= ~PARODD;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// disable parity
|
||||
t.c_cflag &= ~PARENB;
|
||||
}
|
||||
tcsetattr(_fd, TCSANOW, &t);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
{
|
||||
return _flow_control;
|
||||
}
|
||||
virtual void set_parity(int v) override;
|
||||
|
||||
private:
|
||||
void _disable_crlf();
|
||||
|
|
|
@ -457,6 +457,10 @@ void UARTDriver::_timer_tick(void)
|
|||
_in_timer = false;
|
||||
}
|
||||
|
||||
void UARTDriver::configure_parity(uint8_t v) {
|
||||
_device->set_parity(v);
|
||||
}
|
||||
|
||||
/*
|
||||
return timestamp estimate in microseconds for when the start of
|
||||
a nbytes packet arrived on the uart. This should be treated as a
|
||||
|
|
|
@ -45,6 +45,8 @@ public:
|
|||
return _device->get_flow_control();
|
||||
}
|
||||
|
||||
virtual void configure_parity(uint8_t v);
|
||||
|
||||
virtual void set_flow_control(enum flow_control flow_control_setting) override
|
||||
{
|
||||
_device->set_flow_control(flow_control_setting);
|
||||
|
|
Loading…
Reference in New Issue