In the barometer and the imu nodes, add a named semaphore to prevent race conditions accessing the iic interface. In particular:
Create the semaphore with the starting value of 1.
The first node to run first should call sem_wait() and then init the iic interface.
After the initialization is done call sem_post() .
Whenever one node needs to access the iic interface ( critical section of the code ), it should call sem_wait() and then, after it’s done, give it back with sem_post().
In the barometer and the imu nodes, add a named semaphore to prevent race conditions accessing the iic interface. In particular: