Go Down

Topic: Why im getting this error "void value not ignored as it ought to be" (Read 996 times) previous topic - next topic

shaikhhammadali

im trying to transfer sensor data from one arduino to another using nrf transmitter and reciever.
but im getting the error "void value not ignored as it ought to be"
the part of code is written below
im getting error in the line that says "done = radio.read(sensor,sizeof(sensor) );"

please help



if ( radio.available() )
  {
    // Read the data payload until we've received everything
    bool done = false;
    while (!done)
    {
      // Fetch the data payload
      done = radio.read(sensor,sizeof(sensor) );
      Serial.print("S1 = ");
      Serial.print(sensor[0]);
      Serial.print(" S2 = ");
      Serial.print(sensor[1]);
      Serial.print(" S3 = ");
      Serial.print(sensor[2]);
      Serial.print(" S4 = ");
      Serial.print(sensor[3]);
      Serial.println("");

groundFungus

What rf24 library are you using?  There seem to be 2 versions of that library.  In one version the read function returns a boolean value and the other returns nothing (delared void).  You need to use code that is written for the library that you have.  Refer to the examples that come with the library that you have installed.

From the RF24 library that I have:
Code: [Select]
void read( void* buf, uint8_t len );
The read function is declared void, returns nothing and will cause an error if asked to return a value.


shaikhhammadali

What rf24 library are you using?  There seem to be 2 versions of that library.  In one version the read function returns a boolean value and the other returns nothing (delared void).  You need to use code that is written for the library that you have.  Refer to the examples that come with the library that you have installed.

From the RF24 library that I have:
Code: [Select]
void read( void* buf, uint8_t len );
The read function is declared void, returns nothing and will cause an error if asked to return a value.


im using RF24.h

groundFungus

This version of RF24.h* has the read() function declared to return a bool data type. 
Code: [Select]
bool read( void* buf, uint8_t len );
Your code should run with that version of the RF24 library.

This version of the RF24 library** has the read() function declared as void.
Code: [Select]
void RF24::read(void * buf, uint8_t len);
Your code will not work with this version of the RF24 library.

Maybe you could read up on functions to under stand what the return type does.

* maniacbug
**Tmrh20

shaikhhammadali

This version of RF24.h* has the read() function declared to return a bool data type. 
Code: [Select]
bool read( void* buf, uint8_t len );
Your code should run with that version of the RF24 library.

This version of the RF24 library** has the read() function declared as void.
Code: [Select]
void RF24::read(void * buf, uint8_t len);
Your code will not work with this version of the RF24 library.

Maybe you could read up on functions to under stand what the return type does.

* maniacbug
**Tmrh20
thanks, but from where can i download this library?
the link that you gave doesnot contain a download link.



groundFungus

That file should be installed along with the rest of the files when the RF24 library is installed.
 
Did you proper.y install the library?  Installing an Adruino library.

Go Up