Hello. This is my first post in this forum . I'm novice in arduino programming, and have some troubles working with serial ports:
I want to use 2 serial ports: the standard one and a SoftwareSerial port attached to an HC12 transceiver
I don't know (yet) how to writting this code by mean of event driven methods, and at this moment polling is enought for me. So in my sketch I wrote something like:
....
#include <SoftwareSerial.h>
#include <Stream.h>
....
SoftwareSerial HC12(HC12TxdPin,HC12RxdPin);
.....
int getData( Stream channel, char buffer[],int offset) {
while (channel.available()) {
c =channel.read();
if (c=='
When trying to compile sketch I get this error:
cannot declare parameter 'channel' to be of abstract type 'Stream'
AFAIK, either Serial and SoftwareSerial inherits from Stream.
So what's the right way to write this code ?
Any (not so long ) explanation of how to dealing with theses issues will be appreciated
Thanks in advance
Juan Antonio) { // terminator mark
buffer[offset]=0; // null terminate buffer
return 0;
} else {
buffer[offset]=c;
offset++;
if (offset==64) { // at end of buffer
buffer[63]=0;
return 0;
} // end of buffer
} // not ending mark
} // while
// no more available data but not yet received end mark
return offset;
} // method
.....
void setup() {
Serial.begin(115200);
HC12.begin(9600);
....
}
void loop() {
...
serialInputOffset = getData(Serial,serialInputBuffer,serialInputOffset);
if (serialInputOffset == 0 ) serialInputData=String(serialInputBuffer);
...
hc12InputOffset = getData(HC12,hc12InputBuffer,hc12InputOffset);
if (hc12InputOffset == 0 ) hc12InputData= String(hc12InputBuffer);
...
When trying to compile sketch I get this error:
*cannot declare parameter 'channel' to be of abstract type 'Stream'*
AFAIK, either Serial and SoftwareSerial inherits from Stream.
So what's the right way to write this code ?
Any (not so long ) explanation of how to dealing with theses issues will be appreciated
Thanks in advance
Juan Antonio