Hello all, Why will arduino find '$' but not find '!' in my incoming data to trigger the print struct function?
TIA.
Arduino code.
void setup(){
Serial.begin(57600);
Serial3.begin(57600);
}
struct MyStruct_t{
float FloatValue01;
int IntValue01;
long int lIntValue01;
char* CharValue01[15];
}
MyStruct;
int PiData;
void loop()
{
if (Serial3.available() > 0){
PiData = Serial3.read();
if (PiData == '
RPI (Raspberry Pi) code.
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h>
#include <stdlib.h>
void serialSend();
char *ChVal = "Hello World";
struct MyStruct_t{
float FloatValue01;
int IntValue01;
long int lIntValue01;
char* CharValue01[15];
}MyStruct;
int fd;
int main ()
{
if ((fd = serialOpen ("/dev/ttyAMA0", 57600)) < 0)
{
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
return 1 ;
}
for (;;)
{
serialSend();
}
}//main
void serialSend(){
serialPutchar(fd, '
it finds $ just fine and triggers the while loop bit never seems to find !.){
Serial.println("SoS Found");
readSerial();
}
}
}
void readSerial(){
while (PiData != '!'){
if (Serial3.available() > 0){
Serial3.readBytes((char *)&MyStruct,sizeof(MyStruct));
}
}
if (PiData == '!'){
Serial.println("Found !, Now printing MyStuct");
prnStruct();
}
}
void prnStruct(){
Serial.print(MyStruct.FloatValue01);
Serial.print(" : ");
Serial.print(MyStruct.IntValue01);
Serial.print(" : ");
Serial.print(MyStruct.lIntValue01);
Serial.print(" : ");
for (int i=0;i < sizeof(MyStruct.CharValue01);i++){
Serial.print(MyStruct.CharValue01[i]);
}
Serial.println("");
}
RPI (Raspberry Pi) code.
§DISCOURSE_HOISTED_CODE_1§
it finds $ just fine and triggers the while loop bit never seems to find !.);
MyStruct.FloatValue01 = 33.999;
MyStruct.IntValue01 = -37000;
MyStruct.lIntValue01= 2000000000;
MyStruct.CharValue01[0] = ChVal;
serialPuts(fd,(char *)&MyStruct);
serialPutchar(fd, '!');
return;
}
it finds $ just fine and triggers the while loop bit never seems to find !.){
Serial.println("SoS Found");
readSerial();
}
}
}
void readSerial(){
while (PiData != '!'){
if (Serial3.available() > 0){
Serial3.readBytes((char *)&MyStruct,sizeof(MyStruct));
}
}
if (PiData == '!'){
Serial.println("Found !, Now printing MyStuct");
prnStruct();
}
}
void prnStruct(){
Serial.print(MyStruct.FloatValue01);
Serial.print(" : ");
Serial.print(MyStruct.IntValue01);
Serial.print(" : ");
Serial.print(MyStruct.lIntValue01);
Serial.print(" : ");
for (int i=0;i < sizeof(MyStruct.CharValue01);i++){
Serial.print(MyStruct.CharValue01[i]);
}
Serial.println("");
}
RPI (Raspberry Pi) code.
§DISCOURSE_HOISTED_CODE_1§
it finds $ just fine and triggers the while loop bit never seems to find !.