Pages: [1]   Go Down
Author Topic: How does one ignore a void value?  (Read 1233 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
what would i do without arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey there everybody,
I've been working with the parallax rfid reader/writer I just got  smiley 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");
}

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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:
   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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
what would i do without arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Pages: [1]   Go Up
Jump to: