mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 00:04:02 -04:00
AP_HAL_Linux: add function to check if path is chardev
Utility function to allow checking if a certain path is a character device.
This commit is contained in:
parent
a4c1b0d75f
commit
acc571c2c5
@ -2,6 +2,7 @@
|
|||||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -62,4 +63,14 @@ void LinuxUtil::set_system_clock(uint64_t time_utc_usec)
|
|||||||
#endif
|
#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
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||||
|
@ -31,6 +31,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void set_system_clock(uint64_t time_utc_usec);
|
void set_system_clock(uint64_t time_utc_usec);
|
||||||
|
|
||||||
|
bool is_chardev_node(const char *path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Linux::ToneAlarm _toneAlarm;
|
static Linux::ToneAlarm _toneAlarm;
|
||||||
int saved_argc;
|
int saved_argc;
|
||||||
|
Loading…
Reference in New Issue
Block a user