Same Function for different Serialports

Hello,

i'm on a Arduino Mega 2560 and want to use the four independent serial ports.

So is it possible, to use the same functions for each and pass over the serial port, which should be used?

Something like process_data(serial_2)?

thank you for your help.

Greets

Yes. The Serial objects are of type Stream. Make your function take a pointer to a Stream object.