mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-21 16:18:29 -04:00
AP_HAL_Linux: implement HAL::run()
Added a note about the different ordering between setup callback and scheduler initialized call.
This commit is contained in:
parent
c6292ff097
commit
32dc822470
@ -6,11 +6,9 @@
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
#define AP_HAL_MAIN() extern "C" {\
|
||||
int main (int argc, char * const argv[]) { \
|
||||
hal.init(argc, argv); \
|
||||
hal.scheduler->system_initialized(); \
|
||||
setup();\
|
||||
for(;;) loop();\
|
||||
return 0;\
|
||||
AP_HAL::HAL::FunCallbacks callbacks(setup, loop); \
|
||||
hal.run(argc, argv, &callbacks); \
|
||||
return 0; \
|
||||
}\
|
||||
}
|
||||
#endif // HAL_BOARD_LINUX
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "HAL_Linux_Class.h"
|
||||
#include "AP_HAL_Linux_Private.h"
|
||||
|
||||
@ -236,6 +238,23 @@ void HAL_Linux::init(int argc,char* const argv[]) const
|
||||
utilInstance.init(argc+gopt.optind-1, &argv[gopt.optind-1]);
|
||||
}
|
||||
|
||||
void HAL_Linux::run(int argc, char* const argv[], Callbacks* callbacks) const
|
||||
{
|
||||
assert(callbacks);
|
||||
|
||||
init(argc, argv);
|
||||
|
||||
// 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();
|
||||
callbacks->setup();
|
||||
|
||||
for (;;) {
|
||||
callbacks->loop();
|
||||
}
|
||||
}
|
||||
|
||||
const AP_HAL::HAL& AP_HAL::get_HAL() {
|
||||
static const HAL_Linux hal;
|
||||
return hal;
|
||||
|
@ -10,6 +10,7 @@ class HAL_Linux : public AP_HAL::HAL {
|
||||
public:
|
||||
HAL_Linux();
|
||||
void init(int argc, char * const * argv) const;
|
||||
void run(int argc, char* const* argv, Callbacks* callbacks) const override;
|
||||
};
|
||||
|
||||
extern const HAL_Linux AP_HAL_Linux;
|
||||
|
Loading…
Reference in New Issue
Block a user