Often, when I'm using an ethernet shield (W5100) for data acquisition, I like to allow more than 1 simultaneous incoming connection for remote debugging & configuration purposes. So I declare 4 EthernetClients to handle the 4 simultaneous connections that the W5100 supports. It's my understanding that the Serial & EthernetClient classes are both Stream sub-classes or something like that (not exactly sure what the lingo is).
Now at times, I like to know if the current data I'm processing is from Serial or one of the EthernetClients so in the past I've been using a function like this.
boolean comparePrintObj(Print *_item1, Print *_item2){
if (_item1 == _item2){ // for some reason this comparison does not work anymore
return true;
}
return false;
}
And call it like this where _dataSource is a Print* object.
for (byte i=0;i<4;i++){
if (comparePrintObj(_dataSource, &client[i])){
lastConnectionTime = millis();
}
}
It used to work but now lately is only returns false. I expect an Arduino core/IDE update broke it but I'm not smart enough to figure out how/why.
Am I missing something obvious? (It's always obvious once you know)