ardupilot/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp

421 lines
15 KiB
C++
Raw Normal View History

#include "HAL_Linux_Class.h"
#include <assert.h>
#include <signal.h>
2013-09-22 03:01:24 -03:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
2013-09-22 03:01:24 -03:00
#include <AP_HAL/AP_HAL.h>
#include <AP_HAL/utility/RCOutput_Tap.h>
#include <AP_HAL/utility/getopt_cpp.h>
#include <AP_HAL_Empty/AP_HAL_Empty.h>
#include <AP_HAL_Empty/AP_HAL_Empty_Private.h>
2016-07-13 20:25:46 -03:00
#include <AP_Module/AP_Module.h>
#include "AnalogIn_ADS1115.h"
#include "AnalogIn_IIO.h"
#include "AnalogIn_Navio2.h"
#include "GPIO.h"
#include "I2CDevice.h"
#include "OpticalFlow_Onboard.h"
#include "RCInput.h"
#include "RCInput_AioPRU.h"
#include "RCInput_Navio2.h"
#include "RCInput_PRU.h"
#include "RCInput_RPI.h"
#include "RCInput_SoloLink.h"
#include "RCInput_UART.h"
#include "RCInput_UDP.h"
#include "RCInput_Multi.h"
#include "RCInput_ZYNQ.h"
#include "RCInput_RCProtocol.h"
#include "RCOutput_AioPRU.h"
#include "RCOutput_Bebop.h"
#include "RCOutput_Disco.h"
#include "RCOutput_PCA9685.h"
#include "RCOutput_PRU.h"
#include "RCOutput_Sysfs.h"
#include "RCOutput_ZYNQ.h"
#include "SPIDevice.h"
#include "SPIUARTDriver.h"
#include "Scheduler.h"
#include "Storage.h"
#include "UARTDriver.h"
#include "Util.h"
#include "Util_RPI.h"
2013-09-22 03:01:24 -03:00
using namespace Linux;
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
2016-01-20 09:14:48 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
2016-01-05 06:36:30 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
static UtilRPI utilInstance;
#else
static Util utilInstance;
#endif
2018-01-23 15:02:41 -04:00
// 5 serial ports on Linux
static UARTDriver uartADriver(true);
static UARTDriver uartCDriver(false);
2015-12-13 23:19:54 -04:00
static UARTDriver uartDDriver(false);
static UARTDriver uartEDriver(false);
2016-04-19 00:47:25 -03:00
static UARTDriver uartFDriver(false);
2018-06-27 08:34:24 -03:00
static UARTDriver uartGDriver(false);
2019-07-12 01:58:31 -03:00
static UARTDriver uartHDriver(false);
2013-09-22 03:01:24 -03:00
static I2CDeviceManager i2c_mgr_instance;
static SPIDeviceManager spi_mgr_instance;
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
static SPIUARTDriver uartBDriver;
#else
static UARTDriver uartBDriver(false);
#endif
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
2016-01-05 06:36:30 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
static AnalogIn_ADS1115 analogIn;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || \
2016-12-29 10:49:38 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
static AnalogIn_IIO analogIn;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
2016-01-20 09:14:48 -04:00
static AnalogIn_Navio2 analogIn;
2014-11-26 08:03:06 -04:00
#else
static Empty::AnalogIn analogIn;
2014-11-26 08:03:06 -04:00
#endif
static Storage storageDriver;
/*
use the BBB gpio driver on ERLE, PXF, BBBMINI, BLUE and PocketPilot
*/
2016-12-29 10:49:38 -04:00
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
static GPIO_BBB gpioDriver;
/*
use the RPI gpio driver on Navio
*/
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
2016-01-05 06:36:30 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
static GPIO_RPI gpioDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
2017-10-31 13:36:51 -03:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
static GPIO_Sysfs gpioDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_AERO
static GPIO_Sysfs gpioDriver;
#else
static Empty::GPIO gpioDriver;
#endif
/*
use the PRU based RCInput driver on ERLE and PXF
*/
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD
static RCInput_PRU rcinDriver;
2016-12-29 10:49:38 -04:00
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
static RCInput_AioPRU rcinDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE
static RCInput_Multi rcinDriver{2, new RCInput_AioPRU, new RCInput_RCProtocol(NULL, "/dev/ttyO4")};
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
2016-01-05 06:36:30 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
2016-01-05 06:36:30 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
static RCInput_RPI rcinDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ
static RCInput_ZYNQ rcinDriver;
2016-06-07 02:06:35 -03:00
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
static RCInput_UDP rcinDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
static RCInput_Multi rcinDriver{2, new RCInput_RCProtocol("/dev/uart-sbus", "/dev/uart-sumd"), new RCInput_UDP()};
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_AERO
static RCInput_SoloLink rcinDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
2016-01-20 09:14:48 -04:00
static RCInput_Navio2 rcinDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
static RCInput_RCProtocol rcinDriver{"/dev/ttyPS0", NULL};
#else
static RCInput rcinDriver;
#endif
/*
use the PRU based RCOutput driver on ERLE and PXF
*/
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD
static RCOutput_PRU rcoutDriver;
2016-12-29 10:49:38 -04:00
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
static RCOutput_AioPRU rcoutDriver;
/*
use the PCA9685 based RCOutput driver on Navio and Erle-Brain 2
*/
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
2016-01-05 06:36:30 -04:00
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), true, 3, RPI_GPIO_27);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), true, 3, NAVIO_GPIO_PCA_OE);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_QUATENARY_ADDRESS), false, 0, RPI_GPIO_4);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_QUINARY_ADDRESS), false, 0, RPI_GPIO_27);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), false, 0, RPI_GPIO_27);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ
static RCOutput_ZYNQ rcoutDriver;
2016-06-07 02:06:35 -03:00
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
static RCOutput_Bebop rcoutDriver(i2c_mgr_instance.get_device(HAL_RCOUT_BEBOP_BLDC_I2C_BUS, HAL_RCOUT_BEBOP_BLDC_I2C_ADDR));
2016-06-07 02:06:35 -03:00
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
static RCOutput_Disco rcoutDriver(i2c_mgr_instance.get_device(HAL_RCOUT_DISCO_BLDC_I2C_BUS, HAL_RCOUT_DISCO_BLDC_I2C_ADDR));
2016-01-20 09:14:48 -04:00
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
2016-06-07 02:06:35 -03:00
static RCOutput_Sysfs rcoutDriver(0, 0, 14);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_AERO
static ap::RCOutput_Tap rcoutDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
static RCOutput_Sysfs rcoutDriver(0, 0, 15);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
static RCOutput_Sysfs rcoutDriver(0, 0, 8);
#else
static Empty::RCOutput rcoutDriver;
#endif
static Scheduler schedulerInstance;
2013-09-22 03:01:24 -03:00
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
static OpticalFlow_Onboard opticalFlow;
#else
static Empty::OpticalFlow opticalFlow;
#endif
2019-03-25 21:14:17 -03:00
static Empty::Flash flashDriver;
2013-09-22 03:01:24 -03:00
HAL_Linux::HAL_Linux() :
AP_HAL::HAL(
&uartADriver,
&uartBDriver,
&uartCDriver,
2015-12-13 23:19:54 -04:00
&uartDDriver,
&uartEDriver,
2016-04-19 00:47:25 -03:00
&uartFDriver,
2018-06-27 08:34:24 -03:00
&uartGDriver,
2019-07-12 01:58:31 -03:00
&uartHDriver,
&i2c_mgr_instance,
&spi_mgr_instance,
2013-09-22 03:01:24 -03:00
&analogIn,
&storageDriver,
2013-10-05 05:32:57 -03:00
&uartADriver,
2013-09-22 03:01:24 -03:00
&gpioDriver,
&rcinDriver,
&rcoutDriver,
&schedulerInstance,
&utilInstance,
2017-04-02 11:55:29 -03:00
&opticalFlow,
2019-03-25 21:14:17 -03:00
&flashDriver,
2017-04-02 11:55:29 -03:00
nullptr)
2013-09-22 03:01:24 -03:00
{}
void _usage(void)
{
2019-07-12 01:58:31 -03:00
printf("Usage: -A uartAPath -B uartBPath -C uartCPath -D uartDPath -E uartEPath -F uartFPath -G uartGpath -H uartHpath\n");
printf("Options:\n");
2016-07-07 05:27:07 -03:00
printf("\tserial:\n");
printf(" -A /dev/ttyO4\n");
printf("\t -B /dev/ttyS1\n");
2016-07-07 05:27:07 -03:00
printf("\tnetworking tcp:\n");
printf("\t -C tcp:192.168.2.15:1243:wait\n");
printf("\t -A tcp:11.0.0.2:5678\n");
printf("\t -A udp:11.0.0.2:14550\n");
2016-07-07 05:27:07 -03:00
printf("\tnetworking UDP:\n");
printf("\t -A udp:11.0.0.255:14550:bcast\n");
printf("\t -A udpin:0.0.0.0:14550\n");
2016-07-07 05:27:07 -03:00
printf("\tcustom log path:\n");
printf("\t --log-directory /var/APM/logs\n");
printf("\t -l /var/APM/logs\n");
2016-07-07 05:27:07 -03:00
printf("\tcustom terrain path:\n");
printf("\t --terrain-directory /var/APM/terrain\n");
printf("\t -t /var/APM/terrain\n");
printf("\tcustom storage path:\n");
printf("\t --storage-directory /var/APM/storage\n");
printf("\t -s /var/APM/storage\n");
#if AP_MODULE_SUPPORTED
2016-07-07 05:27:07 -03:00
printf("\tmodule support:\n");
printf("\t --module-directory %s\n", AP_MODULE_DEFAULT_DIRECTORY);
printf("\t -M %s\n", AP_MODULE_DEFAULT_DIRECTORY);
#endif
}
2015-10-19 12:59:47 -03:00
void HAL_Linux::run(int argc, char* const argv[], Callbacks* callbacks) const
2013-09-22 03:01:24 -03:00
{
#if AP_MODULE_SUPPORTED
const char *module_path = AP_MODULE_DEFAULT_DIRECTORY;
#endif
2016-07-07 05:27:07 -03:00
2015-10-19 12:59:47 -03:00
assert(callbacks);
2013-09-22 03:01:24 -03:00
int opt;
const struct GetOptLong::option options[] = {
{"uartA", true, 0, 'A'},
{"uartB", true, 0, 'B'},
{"uartC", true, 0, 'C'},
2015-12-13 23:19:54 -04:00
{"uartD", true, 0, 'D'},
{"uartE", true, 0, 'E'},
2016-04-19 00:47:25 -03:00
{"uartF", true, 0, 'F'},
2018-06-27 08:34:24 -03:00
{"uartG", true, 0, 'G'},
2019-07-12 01:58:31 -03:00
{"uartH", true, 0, 'H'},
{"log-directory", true, 0, 'l'},
{"terrain-directory", true, 0, 't'},
{"storage-directory", true, 0, 's'},
2016-07-07 05:27:07 -03:00
{"module-directory", true, 0, 'M'},
{"help", false, 0, 'h'},
{0, false, 0, 0}
};
GetOptLong gopt(argc, argv, "A:B:C:D:E:F:l:t:s:he:SM:",
options);
2013-09-22 03:01:24 -03:00
/*
parse command line options
*/
while ((opt = gopt.getoption()) != -1) {
2013-09-22 03:01:24 -03:00
switch (opt) {
case 'A':
uartADriver.set_device_path(gopt.optarg);
2013-09-22 03:01:24 -03:00
break;
case 'B':
uartBDriver.set_device_path(gopt.optarg);
2013-09-22 03:01:24 -03:00
break;
2013-09-28 11:51:43 -03:00
case 'C':
uartCDriver.set_device_path(gopt.optarg);
2013-09-28 11:51:43 -03:00
break;
2015-12-13 23:19:54 -04:00
case 'D':
uartDDriver.set_device_path(gopt.optarg);
break;
case 'E':
uartEDriver.set_device_path(gopt.optarg);
break;
2016-04-19 00:47:25 -03:00
case 'F':
uartFDriver.set_device_path(gopt.optarg);
break;
2018-06-27 08:34:24 -03:00
case 'G':
uartGDriver.set_device_path(gopt.optarg);
break;
2019-07-12 01:58:31 -03:00
case 'H':
uartHDriver.set_device_path(gopt.optarg);
break;
case 'l':
utilInstance.set_custom_log_directory(gopt.optarg);
break;
case 't':
utilInstance.set_custom_terrain_directory(gopt.optarg);
break;
case 's':
utilInstance.set_custom_storage_directory(gopt.optarg);
break;
#if AP_MODULE_SUPPORTED
2016-07-07 05:27:07 -03:00
case 'M':
module_path = gopt.optarg;
break;
#endif
2013-09-22 03:01:24 -03:00
case 'h':
_usage();
2013-09-22 03:01:24 -03:00
exit(0);
default:
printf("Unknown option '%c'\n", (char)opt);
exit(1);
}
}
setup_signal_handlers();
scheduler->init();
2014-07-13 20:20:47 -03:00
gpio->init();
rcout->init();
rcin->init();
uartA->begin(115200);
uartE->begin(115200);
uartF->begin(115200);
2018-06-27 08:34:24 -03:00
uartG->begin(115200);
2019-07-12 01:58:31 -03:00
uartH->begin(115200);
analogin->init();
utilInstance.init(argc+gopt.optind-1, &argv[gopt.optind-1]);
// NOTE: See commit 9f5b4ffca ("AP_HAL_Linux_Class: Correct
// deadlock, and infinite loop in setup()") for details about the
// order of scheduler initialize and setup on Linux.
scheduler->system_initialized();
2016-07-07 05:27:07 -03:00
// possibly load external modules
#if AP_MODULE_SUPPORTED
2016-07-07 05:27:07 -03:00
if (module_path != nullptr) {
AP_Module::init(module_path);
}
#endif
2016-07-07 05:27:07 -03:00
#if AP_MODULE_SUPPORTED
2016-07-07 05:27:07 -03:00
AP_Module::call_hook_setup_start();
#endif
callbacks->setup();
#if AP_MODULE_SUPPORTED
2016-07-07 05:27:07 -03:00
AP_Module::call_hook_setup_complete();
#endif
while (!_should_exit) {
callbacks->loop();
}
rcin->teardown();
I2CDeviceManager::from(i2c_mgr)->teardown();
SPIDeviceManager::from(spi)->teardown();
Scheduler::from(scheduler)->teardown();
}
void HAL_Linux::setup_signal_handlers() const
{
struct sigaction sa = { };
sa.sa_flags = SA_NOCLDSTOP;
sa.sa_handler = HAL_Linux::exit_signal_handler;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
}
static HAL_Linux halInstance;
void HAL_Linux::exit_signal_handler(int signum)
{
halInstance._should_exit = true;
}
const AP_HAL::HAL &AP_HAL::get_HAL()
{
return halInstance;
}