Go Down

Topic: How does one ignore a void value? (Read 1 time) previous topic - next topic

(the_downsmeister)

Hey there everybody,
I've been working with the parallax rfid reader/writer I just got  :) it's super awesome, and I can read data fine, but now I want to try to write it. I decided to write a function to do so (hooray for me!) but I can't get it to work - the error I keep getting is as follows:

rfid.cpp: In function 'void do_rfid_write(char*)':
rfid:125: error: void value not ignored as it ought to be
rfid:128: error: void value not ignored as it ought to be

Here's the code for the write function, and I can include the rest of the code if anyone's interested. How can I test to see if something is void, and then ignore it if so?

Quote

void do_rfid_write(char indata[]){
  for(int i = 0; i < sizeof(indata)/sizeof(char) && i < maxAddress*4; i++){
    sendWriteCommand(i/4); // this is because we can store 4 chars (or bytes) per address

    while(!mySerial.available()){
    }

    statusCode = mySerial.print(indata); // <- This is line 125, where it fails first
    while(statusCode != ERR_OK){
      sendWriteCommand(i);
      statusCode = mySerial.print(indata); // <- This is where it fails second
    }

    Serial.print("wrote address ");
    Serial.println(i);
  }
  Serial.println("Finished Write");
}


PaulS

Code: [Select]
statusCode = mySerial.print(indata[i]);
mySerial.print() does not return a value. You can't assign the return code from a function that does not return a value to a variable.

Code: [Select]
   while(statusCode != ERR_OK){
     sendWriteCommand(i);
     statusCode = mySerial.print(indata[i]); // <- This is where it fails second
   }

This makes no sense. Since mySerial.print() does not return a value, the value that it (doesn't) return can not possibly be ERR_OK. Or, anything else for that matter.

To answer your original question, one "ignores" nothing by not trying to save it.

(the_downsmeister)

Ah. Yeah, that would be the problem. Thanks for the quick (and correct) response! It's nice to get a fresh pair of eyes on a problem :)

Go Up