diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt index 64f4775c33..4efaa2164a 100644 --- a/src/firmware/posix/CMakeLists.txt +++ b/src/firmware/posix/CMakeLists.txt @@ -14,6 +14,7 @@ if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR NOT APPLE) target_link_libraries(mainapp -Wl,--start-group ${module_libraries} + ${driver_framework_libraries} pthread m rt -Wl,--end-group ) diff --git a/src/platforms/posix/drivers/adcsim/adcsim.cpp b/src/platforms/posix/drivers/adcsim/adcsim.cpp index 6d725344bf..0efbc94225 100644 --- a/src/platforms/posix/drivers/adcsim/adcsim.cpp +++ b/src/platforms/posix/drivers/adcsim/adcsim.cpp @@ -199,7 +199,6 @@ ADCSIM *g_adc; int test(void) { - DriverHandle h = DriverMgr::getHandle(ADCSIM0_DEVICE_PATH); if (!h.isValid()) { @@ -245,7 +244,7 @@ adcsim_main(int argc, char *argv[]) } } - if (argc > 1) { + if (argc > 1 && g_adc) { if (!strcmp(argv[1], "test")) { ret = test(); } diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index 1b22627721..56301b603c 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -43,6 +43,9 @@ #include #include #include +#include "apps.h" +#include "px4_middleware.h" +#include "DriverFramework.hpp" namespace px4 { @@ -53,9 +56,6 @@ using namespace std; typedef int (*px4_main_t)(int argc, char *argv[]); -#include "apps.h" -#include "px4_middleware.h" - static bool _ExitFlag = false; extern "C" { void _SigIntHandler(int sig_num); @@ -184,6 +184,7 @@ int main(int argc, char **argv) } if (!error_detected) { + DriverFramework::Framework::initialize(); px4::init_once(); px4::init(argc, argv, "mainapp"); @@ -236,5 +237,6 @@ int main(int argc, char **argv) vector shutdown_cmd = { "shutdown" }; run_cmd(shutdown_cmd, true); + DriverFramework::Framework::shutdown(); } }