13 Replies Latest reply on Apr 8, 2015 6:49 PM by LVEdison

    Issue compiling with nRF24  Lib

    PranavSanghadia

      I am trying to compile nRF24 sample program using 1.5.3-Intel Edison(This code compiles and works without any issue with standard Arduino), but getting following errors: Any idea?

       

      Source code is attached. I followed this link to make the joystick work with standard arduino: arduino-info - Nrf24L01-2.4GHz-HowTo

       

      =========Error Message==============================

      Arduino: 1.5.3-Intel.1.0.4 (Windows 7), Board: "Intel® Edison"

       

       

      C:\arduino-1.5.3-Intel.1.0.4/hardware/tools/edison/sysroots/i686-pokysdk-mingw32/usr/bin/i586-poky-linux/i586-poky-linux-g++ -m32 -march=i586 --sysroot=C:\arduino-1.5.3-Intel.1.0.4/hardware/tools/edison/sysroots/core2-32-poky-linux -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -D__ARDUINO_X86__ -march=i686 -m32 -DARDUINO=153 -IC:\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\cores\arduino -IC:\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\variants\edison_fab_c -IC:\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\libraries\SPI -IC:\Users\pksangha\Documents\Arduino\libraries\RF24 C:\Users\pksangha\AppData\Local\Temp\build1200601735387649882.tmp\nRF24_Rx.cpp -o C:\Users\pksangha\AppData\Local\Temp\build1200601735387649882.tmp\nRF24_Rx.cpp.o

       

       

      nRF24_Rx.ino:31:16: error: 'const uint64_t pipe' redeclared as different kind of symbol

      In file included from C:\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\variants\edison_fab_c/variant.h:9:0,

                       from C:\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\cores\arduino/Arduino.h:33,

                       from C:\arduino-1.5.3-Intel.1.0.4\hardware\arduino\edison\libraries\SPI/SPI.h:15,

                       from nRF24_Rx.ino:23:

      C:\arduino-1.5.3-Intel.1.0.4/hardware/tools/edison/sysroots/core2-32-poky-linux/usr/include/unistd.h:417:12: error: previous declaration of 'int pipe(int*)'

      extern int pipe (int __pipedes[2]) __THROW __wur;

                  ^

      nRF24_Rx.ino: In function 'void setup()':

      nRF24_Rx.ino:45:31: error: invalid conversion from 'int (*)(int*)throw ()' to 'uint64_t {aka long long unsigned int}' [-fpermissive]

      In file included from nRF24_Rx.ino:25:0:

      C:\Users\pksangha\Documents\Arduino\libraries\RF24/RF24.h:350:8: error:   initializing argument 2 of 'void RF24::openReadingPipe(uint8_t, uint64_t)' [-fpermissive]

         void openReadingPipe(uint8_t number, uint64_t address);

              ^

      ===================================================

        • 1. Re: Issue compiling with nRF24  Lib
          CMata_Intel

          Hi PranavSanghadia

           

          Are you getting the libraries from here right?

          Also, the problem that you are getting is because, the Arduino it's different than the Edison with the Arduino Expansion Board, so there are libraries that are in the IDE-1.5.3 and others are not included yet.

          Could you verify with us that you are using those libraries?

          Take a look at this links, where they are using a nRF24:

          For Galileo Re: Wireless Encryption Between Galileo and MSP430

           

           

          Regards;

          CMata

          • 3. Re: Issue compiling with nRF24  Lib
            CMata_Intel

            Hi PranavSanghadia

             

            It seems that has been deleted.Could you check to us that you are getting the libraries from here: https://github.com/maniacbug/RF24.

            I think that just like in Adafruit motor shield lib sample program compilation error  we will need to do some changes in the libraries.

            So let us know if those are the libraries that you are using so we could try a couple of things

             

            Regards;

            CMata

            • 4. Re: Issue compiling with nRF24  Lib
              Monkey_Brand

              Hi CMata,

              Thanks for quick reply.

              I have tried RF24 from this source TMRh20/RF24 · GitHub in past when I bought Edison

              Which is actively maintained and I never had compilation issue. but some how nrf24 modules never got configured properly.

              It may be because register mappings and SPI level stuff as Edison is hugely different than Arduino at that point.

              I also have tried using Mirf from this source xdarklight/arduino-nrf24l01 · GitHub

              But it was not compiling due to SPI error

               

              I'll have another look on nrf and Edison this weekend will post the results.

               

               

              Again thanks for help.

              • 5. Re: Issue compiling with nRF24  Lib
                CMata_Intel

                Hi Monkey_Brand

                 

                Did you work with the rf-board this weekend? Let us know the outcome of it.

                 

                Regards;

                CMata

                • 6. Re: Issue compiling with nRF24  Lib
                  LVEdison

                  I have been trying to get the nRF2401 to work for the past few weekends as well and am seeing similar results.  The code from the TMRRh20 repo will compile but the transceiver does not appear to be configured correctly (ping transmit and receive tests do not work).

                  • 7. Re: Issue compiling with nRF24  Lib
                    CMata_Intel

                    Hi LVEdison

                     

                    I saw your other thread: Seeking help with Edison + NRF24L01 + upm/node.js are you using Node or the Arduino IDE, same result in both cases?

                     

                    Regards;

                    CMata

                    • 8. Re: Issue compiling with nRF24  Lib
                      LVEdison

                      I've been playing with both environments with slightly different results.

                       

                      The arduino IDE results are similar to what Monkey_Brand reported in this thread:  The code compiles but the transceiver never appears to be configured correctly.  No errors are thrown, but the ping-pair or GettingStarted examples provided with that RF24-master branch do not successfully send or receive data.

                       

                      As far as my other thread goes (I didn't want to cross-post issues) the progress is still at the same point.  The jsupm code doesn't appear to play well within the node envorinment for me but I haven't tried the C++ implementation directly as I am still brushing up on my C++ (it's been 12 years or so since I did my intro to c++ courses).

                       

                      The ultimate end goal would be to have the Edison as a base unit talking to a network of remote devices while providing a friendly web interface for interacting with those remote nodes and providing command and control functionality.

                      • 9. Re: Issue compiling with nRF24  Lib
                        CMata_Intel

                        Hi LVEdison

                         

                        Let's keep working in this thread with the Arduino IDE. Is there a possibility that the shield it's not working fine?

                        Could you post what you are receiving in the Serial Monitor of the IDE?

                         

                        Regards;

                        CMata

                        • 10. Re: Issue compiling with nRF24  Lib
                          LVEdison

                          Hi CMata_Intel, thanks - I just verified that the shield is functional when attached to an Arduino Pro Mini running the same GettingStarted Sketch from TMRh20/RF24 · GitHub

                           

                          watching the serial monitor on com 6 for arduino 1:

                          RF24/examples/GettingStarted
                          *** PRESS 'T' to begin transmitting to the other node
                          *** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
                          Now sending
                          Sent 7086104, Got response 7083544, Round-trip delay 2560 microseconds
                          Now sending
                          Sent 8092496, Got response 8090056, Round-trip delay 2440 microseconds
                          Now sending
                          Sent 9098888, Got response 9096448, Round-trip delay 2440 microseconds
                          Now sending
                          Sent 10105304, Got response 10102880, Round-trip delay 2424 microseconds
                          Now sending
                          Sent 11111912, Got response 11109472, Round-trip delay 2440 microseconds
                          Now sending
                          Sent 12118528, Got response 12116104, Round-trip delay 2424 microseconds
                          Now sending
                          Sent 13125128, Got response 13122688, Round-trip delay 2440 microseconds
                          Now sending
                          Sent 14131744, Got response 14129312, Round-trip delay 2432 microseconds
                          *** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK
                          

                           

                           

                          switching the serial monitor to com 9 arduino 2 (arduino 1 is still runnning):

                          RF24/examples/GettingStarted
                          *** PRESS 'T' to begin transmitting to the other node
                          Sent response 399236448
                          Sent response 400243320
                          Sent response 401250160
                          Sent response 402257000
                          Sent response 403263928
                          Sent response 404270832
                          Sent response 405277688
                          Sent response 406284560
                          Sent response 407291392
                          Sent response 408298240
                          Sent response 409305120
                          Sent response 410311952
                          Sent response 411318808
                          Sent response 412325656
                          Sent response 413332512
                          Sent response 414339368
                          Sent response 415346216
                          
                          

                           

                           

                           

                          when shield from arduino 1 is plugged into the Edison:

                          RF24/examples/GettingStarted
                          *** PRESS 'T' to begin transmitting to the other node
                          *** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
                          Now sending
                          failed
                          Failed, response timed out.
                          Now sending
                          failed
                          Failed, response timed out.
                          Now sending
                          failed
                          Failed, response timed out.
                          Now sending
                          failed
                          Failed, response timed out.
                          Now sending
                          failed
                          Failed, response timed out.
                          Now sending
                          failed
                          Failed, response timed out.
                          *** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK
                          

                           

                           

                          And switching to the receive roles on the edison doesn't print anything further

                          • 11. Re: Issue compiling with nRF24  Lib
                            LVEdison

                            Following up - I modified the GettingStarted.ino sketch from the repo I linked above slightly and now have the edison communicating with remote unit(s).

                             

                            The issue I described above was due to me not setting the SPI ss pinmode (lines 3 and 4 here):

                            void setup() {
                              Serial.begin(115200);
                              pinMode(10,OUTPUT);
                              digitalWrite(10,HIGH);
                            
                            
                            
                              delay(1000);
                            
                            
                            
                            
                            

                             

                             

                            This was a trivial code change but had eluded me for the past few weeks.  Thanks for the eyes on the CMata_Intel, and if there are any pointers for getting the jsupm version working (related to my other thread) I'd very much appreciate the help there!

                             

                            _L

                            • 12. Re: Issue compiling with nRF24  Lib
                              CMata_Intel

                              Hi LVEdison

                               

                              Can you post the changes you have made in the sketch? It would help other makers that may have the same issue in the future.

                               

                              Regards;

                              CMata

                              • 13. Re: Issue compiling with nRF24  Lib
                                LVEdison

                                Here is the full code (with minor edits) for the GettingStarted_HandlingData.ino sketch from RF24/examples/GettingStarted_HandlingData at master · TMRh20/RF24 · GitHub:

                                In this example there are also a couple of functions that I've added to log data to a text file in the /tmp/ directory so that I can access the sensor data from a node.js app (this approach seems cumbersome).

                                 

                                The relevant lines for enabling the rf24l01 connected directly to the Edison are:  61-63

                                 

                                
                                
                                /*
                                * Getting Started example sketch for nRF24L01+ radios
                                * This is an example of how to send data from one node to another using data structures
                                * Updated: Dec 2014 by TMRh20
                                */
                                
                                
                                #include <SPI.h>
                                #include "RF24.h"
                                #include <stdio.h>
                                #include <stdlib.h>
                                #include <string.h>
                                #include <malloc.h>
                                
                                
                                
                                
                                
                                
                                byte addresses[][6] = {"1Node","2Node"};
                                
                                
                                
                                
                                /****************** User Config ***************************/
                                /***      Set this radio as radio number 0 or 1        ***/
                                bool radioNumber = 1;
                                
                                
                                /* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
                                RF24 radio(7,8);
                                /**********************************************************/
                                
                                
                                
                                
                                // Used to control whether this node is sending or receiving
                                bool role = 0;
                                
                                
                                /**
                                * Create a data structure for transmitting and receiving data
                                * This allows many variables to be easily sent and received in a single transmission
                                * See http://www.cplusplus.com/doc/tutorial/structures/
                                */
                                struct dataStruct{
                                  unsigned long _micros;
                                  float value;
                                }myData;
                                
                                
                                void setup() {
                                  // delay for edison serial monitor
                                  delay(3000);
                                
                                  // begin serial:
                                  Serial.begin(115200);
                                
                                // needed for Edison w/ Arduino breakout board:
                                pinMode(10,OUTPUT);
                                digitalWrite(10,HIGH);
                                
                                  Serial.println(F("RF24/examples/GettingStarted"));
                                  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
                                
                                  radio.begin();
                                  // Set the PA Level low to prevent power supply related issues since this is a
                                  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
                                  radio.setPALevel(RF24_PA_LOW);
                                
                                  // Open a writing and reading pipe on each radio, with opposite addresses
                                  if(radioNumber){
                                    radio.openWritingPipe(addresses[1]);
                                    radio.openReadingPipe(1,addresses[0]);
                                  }else{
                                    radio.openWritingPipe(addresses[0]);
                                    radio.openReadingPipe(1,addresses[1]);
                                  }
                                
                                  myData.value = 1.22;
                                  // Start the radio listening for data
                                  radio.startListening();
                                }
                                
                                
                                
                                
                                
                                
                                
                                
                                void loop() {
                                
                                  //****************** Ping Out Role ***************************/  
                                if (role == 1)  {
                                
                                    radio.stopListening();                                    // First, stop listening so we can talk.
                                
                                
                                    Serial.println(F("Now sending"));
                                
                                
                                    myData._micros = micros();
                                    if (!radio.write( &myData, sizeof(myData) )){
                                      Serial.println(F("failed"));
                                    }
                                     
                                    radio.startListening();                                    // Now, continue listening
                                
                                    unsigned long started_waiting_at = micros();              // Set up a timeout period, get the current microseconds
                                    boolean timeout = false;                                  // Set up a variable to indicate if a response was received or not
                                
                                    while ( ! radio.available() ){                            // While nothing is received
                                      if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
                                          timeout = true;
                                          break;
                                      }   
                                    }
                                     
                                    if ( timeout ){                                            // Describe the results
                                        Serial.println(F("Failed, response timed out."));
                                    }else{
                                                                                                // Grab the response, compare, and send to debugging spew
                                        radio.read( &myData, sizeof(myData) );
                                        unsigned long time = micros();
                                     
                                        // Spew it
                                        Serial.print(F("Sent "));
                                        Serial.print(time);
                                        Serial.print(F(", Got response "));
                                        Serial.print(myData._micros);
                                        Serial.print(F(", Round-trip delay "));
                                        Serial.print(time-myData._micros);
                                        Serial.print(F(" microseconds Value "));
                                        Serial.println(myData.value);
                                    }
                                
                                
                                    // Try again 1s later
                                    delay(1000);
                                  }
                                
                                
                                
                                
                                
                                
                                /****************** Pong Back Role ***************************/
                                
                                
                                  if ( role == 0 )
                                  {
                                
                                    if( radio.available()){
                                                                                          // Variable for the received timestamp
                                      while (radio.available()) {                          // While there is data ready
                                        radio.read( &myData, sizeof(myData) );            // Get the payload
                                      }
                                
                                      radio.stopListening();                              // First, stop listening so we can talk
                                   
                                      myData.value += 0.01;                                // Increment the float value
                                      radio.write( &myData, sizeof(myData) );              // Send the final one back.   
                                   
                                      radio.startListening();                              // Now, resume listening so we catch the next packets. 
                                      Serial.print(F("Sent response "));
                                      Serial.print(myData._micros);
                                      Serial.print(" : ");
                                      Serial.println(myData.value);
                                      writeFile("some data to write to file: ",myData);
                                  }
                                }
                                
                                
                                
                                
                                
                                
                                
                                
                                /****************** Change Roles via Serial Commands ***************************/
                                
                                
                                  if ( Serial.available() )
                                  {
                                    char c = toupper(Serial.read());
                                    if ( c == 'T' && role == 0 ){   
                                      Serial.print(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
                                      role = 1;                  // Become the primary transmitter (ping out)
                                
                                  }else
                                    if ( c == 'R' && role == 1 ){
                                      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));   
                                      role = 0;                // Become the primary receiver (pong back)
                                      radio.startListening();
                                   
                                    }
                                  }
                                
                                
                                
                                
                                } // Loop
                                
                                
                                
                                
                                
                                
                                // text file handling:
                                char* readFile (){
                                  FILE *f = fopen("/tmp/arduino.txt", "rb");
                                  if (f != NULL) {
                                    fseek(f, 0, SEEK_END);
                                    long pos = ftell(f);
                                    fseek(f, 0, SEEK_SET);
                                    char *bytes = (char*)malloc(pos);
                                    fread(bytes, pos, 1, f);
                                    fclose(f);
                                
                                    return bytes;
                                  } else {
                                    return NULL;
                                  }
                                }
                                
                                
                                
                                
                                void writeFile(char* txtToWrite, struct dataStruct ds){
                                  FILE *f = fopen("/tmp/sensors.txt", "a");
                                  char* tmp = "";
                                  if (f == NULL)
                                  {
                                      printf("Error opening file!\n");
                                      exit(1);
                                  }
                                
                                Serial.println("writing data");
                                
                                  /* print some text */
                                  //const char *text = "Write this to the file";
                                  fprintf(f, "%s %lu : %f \n", txtToWrite, ds._micros,ds.value);
                                
                                  /* print integers and floats */
                                  //int i = 1;
                                  //float py = 3.1415927;
                                  //fprintf(f, "Integer: %d, float: %f\n", i, py);
                                
                                  /* printing single chatacters */
                                  //char c = 'A';
                                  //fprintf(f, "A character: %c\n", c);
                                
                                  fclose(f);
                                
                                
                                }
                                
                                
                                
                                
                                1 of 1 people found this helpful