2016-07-07 05:26:11 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
support for external modules
|
|
|
|
|
|
|
|
******************************************************************
|
|
|
|
PLEASE NOTE: module hooks are called synchronously from
|
|
|
|
ArduPilot. They must not block or make any IO calls. If anything
|
|
|
|
could take more than a few 10s of microseconds then you must defer
|
|
|
|
it to another thread. Modules are responsible for their own thread
|
|
|
|
handling
|
|
|
|
******************************************************************
|
|
|
|
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-02-09 19:08:54 -04:00
|
|
|
#if AP_MODULE_SUPPORTED
|
|
|
|
|
2024-08-30 23:01:02 -03:00
|
|
|
#include <AP_Math/vector3.h>
|
2016-07-07 06:57:03 -03:00
|
|
|
|
2016-07-13 20:24:00 -03:00
|
|
|
#ifndef AP_MODULE_DEFAULT_DIRECTORY
|
|
|
|
#define AP_MODULE_DEFAULT_DIRECTORY "/usr/lib/ardupilot/modules"
|
|
|
|
#endif
|
2016-07-07 05:26:11 -03:00
|
|
|
|
|
|
|
class AP_Module {
|
|
|
|
public:
|
|
|
|
|
|
|
|
// initialise AP_Module, looking for shared libraries in the given module path
|
|
|
|
static void init(const char *module_path);
|
|
|
|
|
|
|
|
// call any setup_start hooks
|
|
|
|
static void call_hook_setup_start(void);
|
|
|
|
|
|
|
|
// call any setup_complete hooks
|
|
|
|
static void call_hook_setup_complete(void);
|
|
|
|
|
|
|
|
// call any AHRS_update hooks
|
2024-08-30 23:01:02 -03:00
|
|
|
static void call_hook_AHRS_update(const class AP_AHRS &ahrs);
|
2016-07-07 05:26:11 -03:00
|
|
|
|
2016-07-12 08:50:25 -03:00
|
|
|
// call any gyro_sample hooks
|
|
|
|
static void call_hook_gyro_sample(uint8_t instance, float dt, const Vector3f &gyro);
|
|
|
|
|
|
|
|
// call any accel_sample hooks
|
2016-08-31 01:56:44 -03:00
|
|
|
static void call_hook_accel_sample(uint8_t instance, float dt, const Vector3f &accel, bool fsync_set);
|
2016-07-12 08:50:25 -03:00
|
|
|
|
2016-07-07 05:26:11 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
enum ModuleHooks {
|
|
|
|
HOOK_SETUP_START = 0,
|
|
|
|
HOOK_SETUP_COMPLETE,
|
|
|
|
HOOK_AHRS_UPDATE,
|
2016-07-12 08:50:25 -03:00
|
|
|
HOOK_GYRO_SAMPLE,
|
|
|
|
HOOK_ACCEL_SAMPLE,
|
2016-07-07 05:26:11 -03:00
|
|
|
NUM_HOOKS
|
|
|
|
};
|
|
|
|
|
|
|
|
// singly linked list per hook
|
|
|
|
struct hook_list {
|
|
|
|
struct hook_list *next;
|
|
|
|
void *symbol; // from dlsym()
|
|
|
|
};
|
|
|
|
|
|
|
|
// currently installed hooks
|
|
|
|
static struct hook_list *hooks[NUM_HOOKS];
|
|
|
|
|
|
|
|
// table giving the name of the hooks in the external
|
|
|
|
// modules. These are passed to dlsym(). The table order must
|
|
|
|
// match the ModuleHooks enum
|
|
|
|
static const char *hook_names[NUM_HOOKS];
|
|
|
|
|
|
|
|
// scan a module for hooks
|
|
|
|
static void module_scan(const char *path);
|
|
|
|
};
|
2018-02-09 19:08:54 -04:00
|
|
|
|
|
|
|
#endif // AP_MODULE_SUPPORTED
|