UavcanNode::~UavcanNode() { fw_server(Stop); if (_task != -1) { /* tell the task we want it to go away */ _task_should_exit = true; unsigned i = 10; do { /* wait 5ms - it should wake every 10ms or so worst-case */ usleep(5000); /* if we have given up, kill it */ if (--i == 0) { task_delete(_task); break; } } while (_task != -1); } (void)::close(_armed_sub); (void)::close(_test_motor_sub); (void)::close(_actuator_direct_sub); // Removing the sensor bridges auto br = _sensor_bridges.getHead(); while (br != nullptr) { auto next = br->getSibling(); delete br; br = next; } _instance = nullptr; perf_free(_perfcnt_node_spin_elapsed); perf_free(_perfcnt_esc_mixer_output_elapsed); perf_free(_perfcnt_esc_mixer_total_elapsed); pthread_mutex_destroy(&_node_mutex); px4_sem_destroy(&_server_command_sem); // Is it allowed to delete it like that? if (_mixers != nullptr) { delete _mixers; } }
UavcanNode::~UavcanNode() { fw_server(Stop); if (_task != -1) { /* tell the task we want it to go away */ _task_should_exit = true; unsigned i = 10; do { /* wait 5ms - it should wake every 10ms or so worst-case */ usleep(5000); /* if we have given up, kill it */ if (--i == 0) { task_delete(_task); break; } } while (_task != -1); } /* clean up the alternate device node */ // unregister_driver(PWM_OUTPUT_DEVICE_PATH); ::close(_armed_sub); // Removing the sensor bridges auto br = _sensor_bridges.getHead(); while (br != nullptr) { auto next = br->getSibling(); delete br; br = next; } _instance = nullptr; perf_free(_perfcnt_node_spin_elapsed); perf_free(_perfcnt_esc_mixer_output_elapsed); perf_free(_perfcnt_esc_mixer_total_elapsed); pthread_mutex_destroy(&_node_mutex); sem_destroy(&_server_command_sem); }