9 Replies Latest reply on Jan 20, 2017 12:11 PM by Intel Corporation

    Error handling for MRAA::I2C

    Thomas Kirven

      I am currently using a few i2c devices on a quadrotor which is being developed, so quite often an i2c line comes unplugged during a rough flight. Currently when this happens the program quits with the error


      terminate called after throwing an instance of 'std::runtime_error'

        what():  writeWord: mraa_i2c_write_word_data() failed



      which leads to the quadrotor's props spinning uncontrolled. I need the program to recognize/handle this error and continue running, so that it may safely turn off the motors. I have tried the following if statement


      if( flow->readBytesReg(0x00,frame,22)==-1 || flow->readBytesReg(0x16,int_frame,25)==-1) {





      But it seems the program is aborted before the condition is even evaluated so this does not work.


      Is there a simple relatively simple way to do this?