px4_poll() on POSIX: Block execution in simulation if required

This commit is contained in:
Lorenz Meier
2016-02-05 00:53:58 +01:00
parent 8e62c9eb8d
commit 443a58cafe
2 changed files with 28 additions and 0 deletions

View File

@@ -53,6 +53,9 @@
using namespace device;
pthread_mutex_t filemutex = PTHREAD_MUTEX_INITIALIZER;
px4_sem_t lockstep_sem;
bool sim_lockstep = false;
bool sim_delay = false;
extern "C" {
@@ -270,6 +273,10 @@ extern "C" {
#endif
while (sim_delay) {
usleep(100);
}
PX4_DEBUG("Called px4_poll timeout = %d", timeout);
px4_sem_init(&sem, 0, 0);
@@ -398,6 +405,23 @@ extern "C" {
VDev::showFiles();
}
void px4_enable_sim_lockstep()
{
px4_sem_init(&lockstep_sem, 0, 0);
sim_lockstep = true;
sim_delay = false;
}
void px4_sim_start_delay()
{
sim_delay = true;
}
void px4_sim_stop_delay()
{
sim_delay = false;
}
const char *px4_get_device_names(unsigned int *handle)
{
return VDev::devList(handle);

View File

@@ -146,6 +146,10 @@ __EXPORT int px4_fsync(int fd);
__EXPORT int px4_access(const char *pathname, int mode);
__EXPORT unsigned long px4_getpid(void);
__EXPORT void px4_enable_sim_lockstep(void);
__EXPORT void px4_sim_start_delay(void);
__EXPORT void px4_sim_stop_delay(void);
__END_DECLS
#else
#error "No TARGET OS Provided"