I've got some issues that might be an easy task to solve.
I want to read a serial data and check if there is a special character there or not.
If that special character is not present, it should send the data further on to another serial port.
The data I receive is in this format: ka 00 01
The code I'm just briefly testing with is this:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(19200);
while (!Serial) {
; // wait for serial port to connect. Needed for Native USB only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(19200);
}
void loop() //
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
This only gives me back the first byte "ka" and not the rest.
I guess I need to store these bytes into a variable and send them out again.
I think that will suffer from the same issue that the serial monitor won't render those characters. You could print them as ints though to confirm what was received:
if (mySerial.available()) {
int c = mySerial.read();
Serial.println(c);
}
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.