ModalAI Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    I2C

    VOXL 2
    2
    5
    363
    Loading More Posts
    • 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.
    • Peter VWP
      Peter VW
      last edited by Peter VW

      Hello everyone,

      Currently I'm working on the I2C communication with some of our own hardware using the I2C lib from modalai.

      Sending data to our hardware works great and the hardware is acting correctly to it.

      But when we need to read from the hardware the following happens (debugged on hardware):

      • The first message, as expected, come in correctly. The message tells me what I want to read and I set a flag.
      • After the message was read successfully the microcontroller doesn't receive any data anymore.
      • In the terminal of the VOXL2 is an error telling me that it's expecting 12 bytes from slave but received -1 (so, the linux I2C program returns an -1 error)

      When I'm using a terminal program for sending en receiving data from the I2C bus, everything works correctly.

      I use the voxl_i2c_read_bytes library tool like the sourcecode explains.

      We open the I2C connection with voxl_i2c_init and we're using port 0.

      We're running the dev version of the software with the newest system image.

      1 Reply Last reply Reply Quote 0
      • modaltbM
        modaltb ModalAI Team
        last edited by

        Hi @Peter-VW ,

        I believe that voxl_i2c I2C library is VOXL1 specific and you should instead try use more standard open/read/write/close functionality likely.

        I'm assuming you are using the applications processor (i.e. one of the I2Cs from here

        Here's an example from VOXL2, where we are using FLIR Lepton I2C.

        open
        write
        read

        1 Reply Last reply Reply Quote 0
        • Peter VWP
          Peter VW
          last edited by

          Thank you for your awnser.

          Since some time there is an repo, and a package in dev, that should be working with the I2C.
          For now what I did last days:

          • Testen with i2cdump (and some other command line commands) the connection. It works perfectly
          • When using the write commando in C everything works correctly.
          • as soon i send the read commando i receive error 107: Transport endpoint is not connected

          Maybe you guys know a fix. I've tried everything I can think off and can find on the internet.

          A part of the read code:

          	ret = write(i2c[bus].fd, &regAddr, 1);
          	if(unlikely(ret!=1)){
          		fprintf(stderr,"ERROR: in corvus_i2c_read_bytes, failed to write to bus\n");
          		i2c[bus].lock = old_lock;
          		return -1;
          	}
              // uint8_t message[1] ;
          
          	ret = read(i2c[bus].fd, data, count);
          	if(unlikely((size_t)ret!=count)){
          		perror("ioctl(I2C_RDWR) in i2c_read");
          		// fprintf(stderr,"ERROR: in corvus_i2c_read_bytes, received %d bytes from device, expected %d\n", ret, (int)count);
          		i2c[bus].lock = old_lock;
          		return -1;
          	}
          

          I used your libio repo for implementation: https://gitlab.com/voxl-public/voxl-sdk/core-libs/libqrb5165-io/-/blob/master/library/src/i2c.c

          1 Reply Last reply Reply Quote 0
          • modaltbM
            modaltb ModalAI Team
            last edited by

            Hi @Peter-VW I believe thats a Work In Progress package (our dev package channel is very untested).

            The example I mentioned above is being used on a drone of ours (using I2C to talk to a FLIR Lepton) so I have more confidence in that approach at this time.

            1 Reply Last reply Reply Quote 0
            • Peter VWP
              Peter VW
              last edited by

              @modaltb thank you for your answer.

              For so far I can see my program is the same. I'll take some more indepth look when I'm at work again.

              Is there some .so file I've got to include in my cmakelist?

              I've already tried every possible combination that's out there. Hope we can fix this soon.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB | Contributors