examples/GetDistanceI2cRio/src/LIDARLiteRio.cpp
/*------------------------------------------------------------------------------
  Read

  Perform I2C read from device. The optional busy flag monitoring
  can be used to read registers that are updated at the end of a distance
  measurement to obtain the new data.

  Parameters
  ------------------------------------------------------------------------------
  myAddress: register address to read from.
  numOfBytes: numbers of bytes to read. Can be 1 or 2.
  arrayToSave: an array to store the read values.
  monitorBusyFlag: if true, the routine will repeatedly read the status
    register until the busy flag (LSB) is 0.
------------------------------------------------------------------------------*/
Read
Perform I2C read from device. The optional busy flag monitoring
can be used to read registers that are updated at the end of a distance
measurement to obtain the new data.

Parameters

register address to read from.
numOfBytes: numbers of bytes to read. Can be 1 or 2.
arrayToSave: an array to store the read values.
monitorBusyFlag: if true, the routine will repeatedly read the status
register until the busy flag (LSB) is 0.
Read Perform I2C read from device . The optional busy flag monitoring can be used to read registers that are updated at the end of a distance measurement to obtain the new data . Parameters register address to read from . numOfBytes : numbers of bytes to read . Can be 1 or 2 . arrayToSave : an array to store the read values . monitorBusyFlag : if true the routine will repeatedly read the status register until the busy flag ( LSB ) is 0 .
void LIDARLite_I2C::read(int myAddress, int numOfBytes, uint8_t * arrayToSave, bool monitorBusyFlag){
  int busyMonitor = 0; 
  if(monitorBusyFlag){
    busyMonitor = 9999; 
  }
  while(busyMonitor >= 0){
	lidar_read(LIDARLite_I2C::kStatusRegister, &status, 1);
    updateStatus();
    if(deviceBusy == 0){
      busyMonitor = 0;
    }
    busyMonitor--;
  }
  if(busyMonitor == -1){
	  lidar_read(myAddress, arrayToSave, numOfBytes);
  } else {
  }
  printf("t");
}
void LIDARLite_I2C :: read ( int myAddress , int numOfBytes , uint8_t * arrayToSave , bool monitorBusyFlag ) { int busyMonitor = 0 ; if ( monitorBusyFlag ) { busyMonitor = 9999 ; } while ( busyMonitor >= 0 ) { lidar_read ( LIDARLite_I2C :: kStatusRegister , & status , 1 ) ; updateStatus ( ) ; if ( deviceBusy == 0 ) { busyMonitor = 0 ; } busyMonitor -- ; } if ( busyMonitor == -1 ) { lidar_read ( myAddress , arrayToSave , numOfBytes ) ; } else { } printf ( " " ) ; }
Read
Perform I2C read from device.
Read Perform I2C read from device .
//Unlike the arduino library, busyMonitor will be used to monitor our state instead
 //of just whether we are or are not ready with results
 //busyFlag monitors for when the device is done with a measurement
 //pull in the status register
 //m_i2c.Read(LIDARLite_I2C::kStatusRegister, 1, &status);
 //if the LSB is 0, then the reading is correct
 //Subtract 1
 //    m_i2c.Read(myAddress, numOfBytes, arrayToSave);
 //	  printf("\tsensor reading fail\n");
 //  printf("\tbyte1:%x ", arrayToSave[0]);
 //  printf("byte2:%x\n", arrayToSave[1]);
