which works fine, requiring minor syntax adjustments for member function calls and passing the object as an argument:
byte blockingReadByteFrom(NeoSWSerial * serialPort) {
int r;
serialPort->listen();
serialPort->write(B10100101); // or however you request data
do {
r = serialPort->read();
} while (r == -1);
serialPort->ignore();
return (byte) r;
}
void loop() {
for (int i=0; i<2; i++) {
Serial.print("serialArray[")
Serial.print(i);
Serial.print("]: ");
Serial.println(someFunction(serialArray[i]), HEX);
}
}
This doesn't really require a fix (maybe a readme addition), but since Arduino is geared towards beginners I thought I would share the alternative and working usage for those who would like multiple software serial ports within an iterable array and encounter this error when attempting to instantiate within the declaration.
Also thanks for creating and maintaining this. I haven't tried maxing it out (though I don't see why you couldn't have eight or nine with pins available), but I have four NeoSWSerial ports plus the hardware serial working just fine on atmega328p-based boards.
From NeoSWSerial.h:
This prevents using an array to store multiple objects, e.g.
NeoSWSerial serialArray[2] = { NeoSWSerial(3,4), NeoSWSerial(5,6) };
is not allowed.Of course, instead we can use pointers and even assign those within the global context:
which works fine, requiring minor syntax adjustments for member function calls and passing the object as an argument:
This doesn't really require a fix (maybe a readme addition), but since Arduino is geared towards beginners I thought I would share the alternative and working usage for those who would like multiple software serial ports within an iterable array and encounter this error when attempting to instantiate within the declaration.
Also thanks for creating and maintaining this. I haven't tried maxing it out (though I don't see why you couldn't have eight or nine with pins available), but I have four NeoSWSerial ports plus the hardware serial working just fine on atmega328p-based boards.