Ard <--> Pi serial data transfer(unsolved)

Surf: so funny i ended up mostly doing the same thing very very early this morning here is what it ended up looking like this

struct MyStruct_t {
    float yaw;
    float pitch;
    float roll;
    }MyStruct;
void setup(){
 Serial.begin(57600); 
 Serial3.begin(57600); 
}
char sendBuff[23], tmpbuff[6];
void loop() {
    fillStruct();
    makeString();
    sendStr();
}

void sendStr(){
   for (int i = 0; i < sizeof(sendBuff); i++){
   Serial.print(sendBuff[i]);
   Serial3.print(sendBuff[i]);
   }  
   Serial.println("");
   Serial3.println("");   
 }
void fillStruct(){
    MyStruct.yaw = 111.456;
    MyStruct.pitch = -222.679;
    MyStruct.roll = 333.012; 
}
void makeString(){
  strcpy(sendBuff, "<");
  dtostrf(MyStruct.yaw, 4,2, tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  dtostrf(MyStruct.pitch, 4,2, tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  dtostrf(MyStruct.roll, 4,2, tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ">");
  sendBuff[23] = '\0';
}

ill look at the sscanf right now.

Pauls: thanks for pointing those out. been driving me soooo nuts.
i will work in it now the way i have it just for the heck of it and then try and figure out the sscanf Surf mentions. here is what i looks like as of very very early this morning now that i got some sleep i prob can bang
some code out from both your help.

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>

void serialRead();
void parseBuff();

struct MyStruct_t {
    uint32_t yaw;
    uint32_t pitch;
    uint32_t roll;
}MyStruct;

int fd, i, b, C, x, z, sDA, gChar;

char recBuff[23], tmpBuff[6];

int main ()
{
  if ((fd = serialOpen ("/dev/ttyAMA0", 57600)) < 0)
  {
   fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
    return 1 ;
  }

 for (;;)
        {

         serialRead();
 }
}

void serialRead(){
        gChar = serialGetchar(fd);
        sDA = serialDataAvail(fd);
        x = 0;
        if (sDA > 0 ) {
        if (x < sizeof(recBuff)){
         recBuff[x] = gChar;
        x++;
        }
//       printf("%s\n",(char *)&recBuff);
         parseBuff();
         }
}
void parseBuff(){
     b = 0;
     C = recBuff[b];
     if (b < sizeof(recBuff)){
     if (C == '>'){
      recBuff[b] = '\0';
//      printf("%s\n", (char *)&recBuff);
        b++;
        }
    }
        for (z = 0; z < sizeof(recBuff); z++){
        printf("%c",recBuff[z]);
        }
        printf("\n");
    serialFlush(fd);
     return;
}

Surf/Paul: good call on the hex, thinking that's why i saw a lot of hex parsing out there when looking up how to get this done.

well time to get cracking. still would know how to send the dang struct maybe eth shield and tcp?.

Pauls: defined as ints as the uint32_t's i used or the MS.y = 87.96 <- that = the real data that comes off the IMU.

wonder what is going to hold out the longest. the code or my sanity? ]:smiley: