void Serialcom()
{
byte inByte;
while(Serial1.available()>0)
{
inByte=Serial1.read();
switch (inByte)
case RPMN1:
RPMN1=Serial1.available();
break;
case RPMN2:
RPMN2=Serial1.available();
break;
case EGT:
EGT=Serial1.available();
break;
}
}
As you'd expect, it doesn't work...
In this case, RPMN1 and RPMN2 are 32bits values and EGT is a byte.
The ASCII code is sent over as many bytes as there are letters, right?
I guess the code won't ever detect anything since it has to combine different bytes... But since it's not always a UL, how can I get the code to check for the right "ASCII header" even though they do not have the same lengths etc....
I've used the below code to send from one arduino to another. Note that a LEONARDO requires a different serial startup sequence.
//zoomkat 3-5-12 simple delimited ',' string tx/rx
//from serial port input (via serial monitor)
//and print result out serial port
//Connect the sending arduino rx pin to the receiving arduino rx pin.
//Connect the arduino grounds together.
//What is sent to the tx arduino is received on the rx arduino.
//Open serial monitor on both arduinos to test
String readString;
void setup() {
Serial.begin(9600);
Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}
void loop() {
//expect a string like wer,qwe rty,123 456,hyre kjhg,
//or like hello world,who are you?,bye!,
if (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
if (c == ',') {
if (readString.length() >0) {
Serial.print(readString); //prints string to serial port out
Serial.println(','); //prints delimiting ","
//do stuff with the captured readString
readString=""; //clears variable for new input
}
}
else {
readString += c; //makes the string readString
}
}
}
marc426:
Also, \n being 10 and \r 13 in decimal, if I ever run into these values for the data I'm trying to log, isn't it going to make the whole thing bug?
Good question, and that is why I would not send in binary normally.