1 2 3 Previous Next 41 Replies Latest reply on Jul 28, 2016 10:20 AM by PandaBanda

    Help on using the iotkit-comm library in Eclipse

    ravija

      Hi!

      I am a novice in server programming and just been a few days working with Edison. (I have a Edison breakout board).

      I have been able to run the LED blink program in C on Eclipse and other simple C programs. I needed to send data from Edison to a database server that resides on my system and searching for the same landed me to the links for iotkit-comm library on Github "intel-iot-devkit/iotkit-comm-c · GitHub" and Amazonaws "Tutorials: cloud".

      I have been able to understand the basic flow of code but what I fail to understand is, how to install this library in Eclipse to be able to use it for programming.

      Thanks in advance.

        • 1. Re: Help on using the iotkit-comm library in Eclipse
          CMata_Intel

          Hi ravija,

           

          In Eclipse, you can see in the Project Explorer tab your project's folder, expand that folder and select the Includes folder too, you should see something similar to the picture below. You need to use the usr/include folder to include more libraries

           

          USRinclude.jpg

           

          Now, you have to download the iotkit-comm-c [Github: intel-iot-devkit/iotkit-comm-c] extract the files and put a copy of the folder iotkit-comm-c/src/lib/iotkit-comm/ in the respective folder. In my case would be:

          C:\Intel\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\include

           

          After this, you must restart Eclipse and try with the example from Tutorials: cloud:

          #include <stdio.h>
          #include <stdbool.h>
          #include <sys/types.h>
          #include "iotkit-comm/iotkit-comm.h"
          #include "iotkit-comm/util.h"
          
          ServiceSpec *srvSpec = NULL;
          int msgnumber = 13; // sensor value
          
          void callback(void *handle, int32_t error_code, void *serviceHandle) {
            Context context;
            char msg[256];
            int i = 0;
            CommHandle *commHandle = NULL;
          
            if(serviceHandle != NULL) {
            commHandle = (CommHandle *) serviceHandle;
          
            int (**publish) (char *message,Context context);
          
            publish = commInterfacesLookup(commHandle, "publish");
            if(publish == NULL) {
            fprintf(stderr, "Function \'publish\' is not available; please verify the Plugin documentation !!\n");
            return;
            }
          
            context.name = "topic";
            context.value = "data";
          
            while(i < 10) { // Event Loop
            sprintf(msg, "{\"name\": \"garage_sensor\", \"value\": %d}", msgnumber++);
            printf("Publishing msg:%s\n", msg);
          
            (*publish)(msg, context);
            sleep(2);
          
            i ++;
            }
            }
          
            // clean the objects
            cleanUpService(&srvSpec, &commHandle);
            exit(0);
          }
          
          int main(void) {
            puts("Sample program to publish data to IoT Cloud !!");
          
            srvSpec = (ServiceSpec *) parseServiceSpec("./serviceSpecs/temperatureServiceEnableIot.json");
          
            if (srvSpec){
            advertiseServiceBlocking(srvSpec, callback);
            }
          
            return 0;
          }
          

           

          Regards,

          Charlie

          • 2. Re: Help on using the iotkit-comm library in Eclipse
            ravija

            Thanks a lot for your help Charlie.

            I had downloaded the library and also located the iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\include folder, before asking the question on this forum, and saw that it housed the mraa and upm folder but was not able to figure out what needed to be placed where. Your reply was a great help.

            Thanks again for the apt reply.

            Looking forward to lots more help on my way to learning,

            Ravija

            • 3. Re: Help on using the iotkit-comm library in Eclipse
              ravija

              Looks like I am missing something.

              I placed just the "iotkit-comm" folder from the downloaded folder iotkit-comm-c-master (i.e. path iotkit-comm-c-master\src\lib)

              I copied the sketch from the website Tutorials: cloud and ran it but it showed an error saying :

              DescriptionResourcePathLocationType
              fatal error: cJSON.h: No such file or directorycloud_check_programline 35, external location: C:\Users\Ravija\Documents\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\include\iotkit-comm\util.hC/C++ Problem

               

              So I went back to the includes folder and placed the cJSON.h and cJSON.c files also in it. (copied from the folder cJSON "iotkit-comm-c-master\src\lib\cJSON")

              but then it showed more errors saying :

               

              errors.png

              Placing the lib folder from "iotkit-comm-c-master\src" and updating the respective paths for "iotkit-comm.h" and "util.h" was again not much of a help. The same error "cJSON.h not found" was seen.

              Please guide.

              Also, Does having the intel xdk also installed have any role in this?

              • 4. Re: Help on using the iotkit-comm library in Eclipse
                CMata_Intel

                Hi ravija,

                 

                Which files do you have inside of C:\Intel\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\include\iotkit-comm ?

                I have the following files and I ran the example above without problems:

                plugin-interfaces

                CMakeLists.txt

                config.json

                iotkit-comm.c

                iotkit-comm.h

                iotkit-comm_mdns.c

                iotkit-comm_mdns.h

                libiotkit-comm.md

                util.h

                 

                It seems that the issue is related with a location of a library so we may be missing something. If you look into the example the include's are calling to:

                "iotkit-comm/iotkit-comm.h" and "iotkit-comm/util.h" so you should have those in there.

                How are you opening the Eclipse environment? You must double click in C:\Intel\iotdk-ide-win\devkit-launcher.bat

                 

                Regards,

                Charlie

                • 5. Re: Help on using the iotkit-comm library in Eclipse
                  ravija

                  Hi Charlie,

                  1) I have the exact same contents in the iotkit-comm folder.

                  folder path.png

                  Though the contents are the same as yours I realize that my "iotdk-ide-win"  folder resides in Documents while yours is in C: drive. Could this be a problem?

                   

                  2) Also, I have an Edison breakout board so my Eclipse IDE does not show a Simple C/C++ sketch option as shown in the following link:

                  "https://software.intel.com/en-us/creating-a-new-project-in-the-eclipse-ide"

                  rather, mine looks like

                  Available sketches.png

                  So I had to use the "On board LED blink" sketch, erase all its contents and paste the cloud file contents as said before.

                   

                  3) I also figured out that the cJSON.h is a file that is required by the util.h file as an include

                   

                  4) And, yes I am double clicking on the batch file (in C:\Intel\iotdk-ide-win\devkit-launcher.bat) to launch Eclipse.

                   

                  Thanks again.

                  In hope of your valuable guidance

                  Ravija

                  • 6. Re: Help on using the iotkit-comm library in Eclipse
                    CMata_Intel

                    Hi ravija,

                     

                    I'm using the Eclipse IoT version Luna SR1 (4.4.1) from the Integrated Installer.

                    What is the location of your libraries? Could you attach another screenshot with the outcome of expanding cloud_check_program > Includes on the Project Explorer ?

                    Have you tried to add the cJSON.h in the include folder? iotkit-comm-c/cJSON.h at master | GitHub

                     

                    Regards,

                    Charlie

                    • 7. Re: Help on using the iotkit-comm library in Eclipse
                      ravija

                      Thanks again Charlie.

                      Downloading the integrated installer did solve my problem of edison interface but havent been able to check the cloud program as of now.

                      Would let you know as I do it.

                      • 8. Re: Help on using the iotkit-comm library in Eclipse
                        ravija

                        Hello Charlie

                        Haven't been able to solve the problem of unassigned reference even now.

                        So I have attached some snippets as directed by you.

                        1) The project explorer tab of my code:

                         

                        Includes.PNG

                         

                        2) Figure: The four errors and warnings that have remained from the previous installation.

                        errorsandwarnings.PNG

                         

                        3) Figure: New contents of the iotkit-comm folder which came within the integrated installer.

                        Newcontents of iotkit-comm folder.png

                         

                         

                        4)The project window:

                        4errorsagain_main window.png

                        Again in need of your valuable help

                        • 9. Re: Help on using the iotkit-comm library in Eclipse
                          ravija

                          Hi Charlie

                          Its been quite some time trying to figure as to why the program reads the "advertiseServiceBlocking" and "parsrserviceSpec" functions as implicit declarations when they are already declared in the iotkit-comm.h header file, but haven't had any luck.

                          Please guide me.

                          Eagerly awaiting your response,

                          Ravija

                          • 10. Re: Help on using the iotkit-comm library in Eclipse
                            CMata_Intel

                            Hi ravija,

                             

                            Right now I am having the same result, I'm going to do more tests and I will let you know.

                             

                            Regards,

                            Charlie

                            • 11. Re: Help on using the iotkit-comm library in Eclipse
                              ravija

                              Hi Charlie,

                              Thanks for your response.

                              Just had a little doubt,though. Are you having the same problem as mine or is the program running on your setup?

                              Regards

                              Ravija

                              • 12. Re: Help on using the iotkit-comm library in Eclipse
                                CMata_Intel

                                Hi ravija,

                                 

                                I'm sorry for the delay in my response. I did the following and I was able to have no problems with the example.

                                1.  Download and unzip the iotkik-comm-c library from intel-iot-devkit/iotkit-comm-c · GitHub

                                2. From the unzipped folder go to iotkit-comm-c-master>iotkit-comm-c-master>src>lib, copy the "cJSON" and "iotkit-comm" folders and paste them to Eclipse's /usr/include folder. The location of this folder should be something like:

                                C:\Intel\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\include.

                                3. From the copied folders, edit the "util.h" file inside "iotkit-comm" folder. Line 35 should look like this

                                #include "cJSON/cJSON.h"
                                

                                4. On Eclipse, select Project>Properties>C/C++ Build>Settings>Tool Settings>Cross GCC Linker>Miscellaneous. You will see a box that says "Other options (-Xlinker [option])", click on Add and add the linker flags: -iotkit-comm -cJSON

                                5. Click on Apply and Ok

                                 

                                Regards,

                                Charlie

                                • 13. Re: Help on using the iotkit-comm library in Eclipse
                                  ravija

                                  Hi Charlie @C_Mata,

                                  I know its been too long since your last reply but I was stuck in some other urgent work thus not being able to verify the solution posted.

                                  It might not be very good to know that the problem still remained.

                                  Adding rpath to Xlinker did not exactly help. When trying to build the program would list a error saying

                                  " bad -rpath option".

                                  However I was able to solve that issue with some trial and error. I added the folders as "libraries" to the Cross GCC Linker. Below is a snap of it.

                                  Adding_to_libraries.PNG

                                   

                                  So now the warnings that remain were concerning "Implicit declarations" of two functions as before - advertiseServiceBlocking and parseServiceSpec.

                                   

                                  So I did a little more research on tutorials cloud :service spec and query and on Github where I found the following issue that remains with iotkit-comm_mdns.h file in the iotkit-comm library. Below is the snap from there:

                                  Missing_functions.PNG

                                  Sorry for being so descriptive and long again

                                  Hope you will do the needful.

                                  Regards

                                  Ravija

                                  • 14. Re: Help on using the iotkit-comm library in Eclipse
                                    ravija

                                    P.S. I did add the declarations to my file could not get it running though.

                                    Trying to crack the other errors ...

                                    1 2 3 Previous Next