mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-02 14:13:42 -04:00
7ac51f60d0
This commit changes the way libraries headers are included in source files: - If the header is in the same directory the source belongs to, so the notation '#include ""' is used with the path relative to the directory containing the source. - If the header is outside the directory containing the source, then we use the notation '#include <>' with the path relative to libraries folder. Some of the advantages of such approach: - Only one search path for libraries headers. - OSs like Windows may have a better lookup time.
77 lines
1.5 KiB
C++
77 lines
1.5 KiB
C++
#include <AP_HAL/AP_HAL.h>
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <time.h>
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
#include "Util.h"
|
|
using namespace Linux;
|
|
|
|
|
|
static int state;
|
|
ToneAlarm LinuxUtil::_toneAlarm;
|
|
/**
|
|
return commandline arguments, if available
|
|
*/
|
|
void LinuxUtil::commandline_arguments(uint8_t &argc, char * const *&argv)
|
|
{
|
|
argc = saved_argc;
|
|
argv = saved_argv;
|
|
}
|
|
|
|
bool LinuxUtil::toneAlarm_init()
|
|
{
|
|
return _toneAlarm.init();
|
|
}
|
|
|
|
void LinuxUtil::toneAlarm_set_tune(uint8_t tone)
|
|
{
|
|
_toneAlarm.set_tune(tone);
|
|
}
|
|
|
|
void LinuxUtil::_toneAlarm_timer_tick(){
|
|
if(state == 0){
|
|
state = state + _toneAlarm.init_tune();
|
|
}else if(state == 1){
|
|
state = state + _toneAlarm.set_note();
|
|
}
|
|
if(state == 2){
|
|
state = state + _toneAlarm.play();
|
|
}else if(state == 3){
|
|
state = 1;
|
|
}
|
|
|
|
if(_toneAlarm.is_tune_comp()){
|
|
state = 0;
|
|
}
|
|
|
|
}
|
|
|
|
void LinuxUtil::set_system_clock(uint64_t time_utc_usec)
|
|
{
|
|
#if CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_NONE
|
|
timespec ts;
|
|
ts.tv_sec = time_utc_usec/1.0e6;
|
|
ts.tv_nsec = (time_utc_usec % 1000000) * 1000;
|
|
clock_settime(CLOCK_REALTIME, &ts);
|
|
#endif
|
|
}
|
|
|
|
bool LinuxUtil::is_chardev_node(const char *path)
|
|
{
|
|
struct stat st;
|
|
|
|
if (!path || lstat(path, &st) < 0)
|
|
return false;
|
|
|
|
return S_ISCHR(st.st_mode);
|
|
}
|
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|