Z4nna / nereo_rov_code

The code for the ROV Nereo made by PoliTOcean
MIT License
1 stars 1 forks source link

Semaphore to syncronize access to the I2C interface #10

Closed Z4nna closed 4 months ago

Z4nna commented 6 months ago

In the barometer and the imu nodes, add a named semaphore to prevent race conditions accessing the iic interface. In particular:

  1. Create the semaphore with the starting value of 1.
  2. The first node to run first should call sem_wait() and then init the iic interface.
  3. After the initialization is done call sem_post() .
  4. 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().