3 Replies Latest reply on Mar 24, 2016 6:31 PM by CMata_Intel

    Multithread IO control on Edison.

    shadox

      Hi,I am building a small iot system using the intel Edison.There are a lot of loops in many threads in my system,such as the I2c loop which I use to run a 4*3 keypad. A Serial read loop thread which I use to get my sms message in the background. And other loop threads,most of which are using i2c.

      The problem is that sometimes I got a "i2c:Failed to Write" Error,all my thing are dead.I have no choice except power the board off/on to recover(reboot would not help).

      I am using the eclipse C++ tool to get full control of the linux system.

      This problem had bothered me for many days.I need you help!

      FA90DE42-4F26-4723-BF70-8AFC74396230.png

        • 1. Re: Multithread IO control on Edison.
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi shadox, 

          I’m sorry to hear that you have problems with your application. I would like to know some more information:
          1.    Which image are you using? Run configure_edison --version
          2.    Which MRAA version do you have? You can update the version by running the following commands:
          echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
          opkg update
          opkg install mraa

          3.    How are you debugging your code?

          You mentioned that you have different loops where you are using I2C functions, have you checked that there isn’t a conflict between those loops? The problem could be that one loop/process is asking for I2C resources that are being used in another loop/process so the communication fails.
          Have you tested the signals with a logic analyzer or an oscilloscope?

          Regards,
          Charlie
           

          • 2. Re: Multithread IO control on Edison.
            shadox

            Hi Charlie,

                Thanks for your help.

                1. configure_edison --version  returns "159.devkit"

                2.my MRAA version is 0.9.1

                3.I am using the  eclipse C++ IDE to run and debug my code.As my application is multithread, I prefer reading the log. Once All my went wrong,I goto the journalctl -f | grep libmraa to see      the log from mraa.

             

                As I have mentioned before, there are more than a  4*3 keypad in my system. I rewrite the code here http://playground.arduino.cc/Main/I2CPortExpanderAndKeypads so it could run on the  Edison using mraa .As you see, to using these i2c keypad ,I have to read/write i2c very frequently in my loop. Most importantly , one keypad need a loop.So there must be conflict between      those loops.I realize these after days struggle.So I add a lock to each of my calling to mraa_i2c_* functions using the C11 lock guard and the mutex is global.And my things just worked, how stupid I was before.

                 How ever , when it comes to another loop,things goes strange again. I have to check a gsm https://software.intel.com/en-us/iot/hardware/sensors/grove-gpsfrequently in a loop to get each new message. And this sensor actually use the Uart functions in mraa. When the Uart loop is running, the i2c went wrong again.That is really unbeliveable, as they use a quite different /dev/ file and they are in different Pins on the Board.

                 Mostly, I do not know how to recover form these issue, reboot the Edison will not reset the pins on the board.I have to pull the plug and back in.I need some code solution so my system can use in release.



            Regards,

            Shadox

            • 3. Re: Multithread IO control on Edison.
              CMata_Intel

              Hi shadox,

               

              I’m glad to hear that there are some improvements in your project.

              What happens if you run the loops separately? For example, running a code that only works with I2C and another that only works with the UART. If they run fine independently you can run both routines in parallel (if they are not using the same resources there shouldn’t be problems) I’m suggesting you this because the problem could be that your code get lost between the routines with the different interfaces (I2C & UART).

              Also, the lastest MRAA version is the 0.9.6, update it and check if you get better results.

               

              Have you tried with a cold boot before running the reboot command?

              echo 1 > /sys/module/intel_mid/parameters/force_cold_boot 

               

              Regards,

              Charlie