Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to know ioctl not detected chip address ?

How to know ioctl not detected chip address ?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 391 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by Qt embedded developer
    #1

    i have tested instrument it give correct data on i2c.

    But there is problem that when there is same slave address not found on bus it need to show -1 . but it always show fd = 0.

    bIsBatteryCheckOn = false;

    if((nI2CId= open("/dev/i2c-2", O_RDWR))<0)
    {
        qDebug() << "can not open I2C bus";
        return bIsBatteryCheckOn;
    }
    else
    {
        if(nI2CId > 0)
        {
            int fd;
    
            if(GAUGE_DEVICE_ADDRESS != 0x55)
                fd = -1;
            else
                fd = (ioctl(nI2CId, I2C_SLAVE,0x55)); 
            qDebug() << "-------------------------------fd"<<fd;
    
            if (fd < 0)
            {
                qDebug() << "Battery fuel gauge not found";
                return bIsBatteryCheckOn;
            }
            else
            {
                bIsBatteryCheckOn= true;
            }
        }
        else
        {
            qDebug() << "Battery fuel gauge not found";
            return bIsBatteryCheckOn;
        }
    }
    
    return bIsBatteryCheckOn;
    
    JonBJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      i have tested instrument it give correct data on i2c.

      But there is problem that when there is same slave address not found on bus it need to show -1 . but it always show fd = 0.

      bIsBatteryCheckOn = false;

      if((nI2CId= open("/dev/i2c-2", O_RDWR))<0)
      {
          qDebug() << "can not open I2C bus";
          return bIsBatteryCheckOn;
      }
      else
      {
          if(nI2CId > 0)
          {
              int fd;
      
              if(GAUGE_DEVICE_ADDRESS != 0x55)
                  fd = -1;
              else
                  fd = (ioctl(nI2CId, I2C_SLAVE,0x55)); 
              qDebug() << "-------------------------------fd"<<fd;
      
              if (fd < 0)
              {
                  qDebug() << "Battery fuel gauge not found";
                  return bIsBatteryCheckOn;
              }
              else
              {
                  bIsBatteryCheckOn= true;
              }
          }
          else
          {
              qDebug() << "Battery fuel gauge not found";
              return bIsBatteryCheckOn;
          }
      }
      
      return bIsBatteryCheckOn;
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Qt-embedded-developer
      I don't see anything Qt in your code.....

      Q 1 Reply Last reply
      0
      • JonBJ JonB

        @Qt-embedded-developer
        I don't see anything Qt in your code.....

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #3

        @JonB this is related to embedded if know then let me know

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved