i2c on linux: intterrupted system call

Based on DMP's Vortex processor / SoC this board is a full computer capable of running a standard Windows and Linux installation on the backpack of your robot.
2 postsPage 1 of 1
2 postsPage 1 of 1

i2c on linux: intterrupted system call

Post by maestro » Mon Nov 02, 2009 4:09 pm

Post by maestro
Mon Nov 02, 2009 4:09 pm

Hi,

I'm using roboard and the roblib to obtain some i2c values.

Sometimes reading values works just fine, but sometimes I get the following errors_
Can't open I2c
Interrupted system call
It means, that ii2c_Initialize() fails while initializing the i2c bus. Which system (which can be interrupted) are used in i2c_initialize()? Can I write a more reliable function to obtain the i2c_values?

Code: Select all
int ADin::MCP3221getADvalue() {
   unsigned char highByte, lowByte;

   if (i2c_Initialize(I2CIRQ_DISABLE) == false) {
      Logger::error << __func__ << ": Can't open I2c" << std::endl;
      Logger::error << strerror(errno) << std::endl;
      return -5;
   }

   if (i2c0_SetSpeed(I2CMODE_STANDARD, 100000L) == 0) {
      Logger::error << __func__ << ": Can't set speed: "
            << roboio_GetErrMsg() << std::endl;
   }

   //START with address 0x40 to write 1 byte
   if (!i2c0master_Start(MCP3221, I2C_READ)) {
      Logger::error << __func__ << ": START fail ( " << roboio_GetErrMsg()
            << ")... try again" << std::endl;
      if (!i2c0master_Start(MCP3221, I2C_READ)) {
         Logger::error << __func__ << ": START fail again ( "
               << roboio_GetErrMsg() << ")" << std::endl;
         i2c_Close();
         return -4;
      }
   }

   highByte = i2c0master_ReadSecondLast();

   lowByte = i2c0master_ReadLast();

   i2c_Close();
   return highByte * 256 + lowByte;

}


Thanks for any suggestions. [/list]
Hi,

I'm using roboard and the roblib to obtain some i2c values.

Sometimes reading values works just fine, but sometimes I get the following errors_
Can't open I2c
Interrupted system call
It means, that ii2c_Initialize() fails while initializing the i2c bus. Which system (which can be interrupted) are used in i2c_initialize()? Can I write a more reliable function to obtain the i2c_values?

Code: Select all
int ADin::MCP3221getADvalue() {
   unsigned char highByte, lowByte;

   if (i2c_Initialize(I2CIRQ_DISABLE) == false) {
      Logger::error << __func__ << ": Can't open I2c" << std::endl;
      Logger::error << strerror(errno) << std::endl;
      return -5;
   }

   if (i2c0_SetSpeed(I2CMODE_STANDARD, 100000L) == 0) {
      Logger::error << __func__ << ": Can't set speed: "
            << roboio_GetErrMsg() << std::endl;
   }

   //START with address 0x40 to write 1 byte
   if (!i2c0master_Start(MCP3221, I2C_READ)) {
      Logger::error << __func__ << ": START fail ( " << roboio_GetErrMsg()
            << ")... try again" << std::endl;
      if (!i2c0master_Start(MCP3221, I2C_READ)) {
         Logger::error << __func__ << ": START fail again ( "
               << roboio_GetErrMsg() << ")" << std::endl;
         i2c_Close();
         return -4;
      }
   }

   highByte = i2c0master_ReadSecondLast();

   lowByte = i2c0master_ReadLast();

   i2c_Close();
   return highByte * 256 + lowByte;

}


Thanks for any suggestions. [/list]
maestro offline
Newbie
Newbie
Posts: 3
Joined: Thu Aug 06, 2009 4:10 pm

Re: i2c on linux: intterrupted system call

Post by roboard » Tue Nov 03, 2009 9:38 am

Post by roboard
Tue Nov 03, 2009 9:38 am

i2c_Initialize() employs the linux times(...) call for time delays. You can call roboio_GetErrMsg() to see what error happens when i2c_Initialize() fails.
i2c_Initialize() employs the linux times(...) call for time delays. You can call roboio_GetErrMsg() to see what error happens when i2c_Initialize() fails.
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am


2 postsPage 1 of 1
2 postsPage 1 of 1
cron