Show Posts
Pages: [1] 2 3 ... 9
1  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 25, 2013, 11:22:57 am
Quote
now i need to "sync"? and better "start /stop" bits?
Syncing simply means that you start storing data when the start marker arrives and stop when the end marker arrives.

What's wrong with < and > as the markers?
was thinking it would be better is all but it seems simpler to use single char delimiters so i am good with that
Quote
You really should work on one side at a time. Get the Arduino sending data properly. Mixing types is a bad idea. Do it right. Once the Arduino sends the data correctly, reading and parsing it on the Pi should be trivial.
the data on the ard side is just junk data i mixed up to have stuff to send i scraped the bot and using the bits in other things at the moment. I just wanted to send the amount and various types of data being gathered the setup of gathering -> buffering -> printing. works so no need to worry about arduino sending side at the moment.
Quote
Code:
             read(fd,recBuff,sizeof(recBuff));
This will read whatever is there, not sizeof(recBuff) bytes, unless there are more than sizeof(recBuff) bytes available to read. Since you only sending (ssslllooowwwlllyyy) 80 characters or so, this function should never read 90 characters. If it does, it will have gobbled the end of one packet and part of the next packet.
Reading data ONE character at a time is the only way to ensure that you stop reading when the end of packet marker arrives.
i get that would be the best have been trying to trigger that to happen. so read after < and stop at >.
Quote
Code:
        while (cChar != '>'  ){
             cChar = serialGetchar(fd);
             printf("Getting data!\n ");
             read(fd,recBuff,sizeof(recBuff));
Read a character. If its not the end of packet marker, read an throw away a character. Then, read a whole bunch of stuff. Don't bother with how much was actually read.
well i cant tell read how many to read because it's going to very in size by a little under 13.34% +/- each packet ( the char width of IMU and UltraSonic data is dynamic not static + not all GPS data will be same size) so any ideas on how to know ahead of when i get's there how big the amount to read would be great
Quote
There is so much wrong there that I can't even begin to figure out where to start. Except over.
got an example i know that is not working because well it's not working  smiley-grin so how would you structure the read loop to trigger on < read a dynamic amount of data and stop at >.

 not to mention this only buffers the data i have not even tried to read these into actual variables to use yet cant wait to see how fun that is  smiley-twist. thanks for replying PaulS and thank you so much for you guidance in this and past projects.
2  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 25, 2013, 08:10:21 am
so im kind of reading it in now. here is the PI side output
Code:
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
End of data
30000>
<111.46,-222.68,333.01::43.000000,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000
Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
here is the Pi code
Code:
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h>

void serialRead();
void prntBuff();

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

 for (;;)
        {
        cChar = serialGetchar(fd);
        printf("Wating for data\n");
        if(cChar == '<') serialRead();
         serialRead();
 }
}

void serialRead(){
        sDA = serialDataAvail(fd);
        while (cChar != '>'  ){
             cChar = serialGetchar(fd);
             printf("Getting data!\n ");
             read(fd,recBuff,sizeof(recBuff));

        if(sDA == 0){
          printf("Got no Data\n");
          }
            break;
            }

        if(cChar == '>'){
        printf("End of data\n");
        serialFlush(fd);
        prntBuff();
    }
 }
void prntBuff(){
            printf("%s\n",recBuff);
}
decided to try using read and write to the buffer now i need to "sync"? and better "start /stop" bits?any ideas would be great. ( thinking i need to flush my buffer, so like tmpbuff sizeof (recBuff) get the start bit to the stop bit parse the actual data into recBuff then NULL tempbuff and start over yes?. "maybe even set a value to tell the function how many chars to expect coming so like
 $tart[77]::bla bla bla::[77]$top ,using 2 of them to make sure i got the rite values and has not been corrupted?") any how now i need a better trigger and end system tho. but the read/write to fd should be good yes?
3  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 25, 2013, 02:38:52 am
Code:
  long flAt;  // GPS latitude
  long flOn; // GPS Longitude

and yet you are assigning float values to them and using dtostrf (in one case, anyway) to convert them to strings. Why?

Code:
  (MyStruct.flAt,3,6,tmpbuff);
What's this supposed to do?
LOL was in the middle of editing when i cut and pasted the code. as for the dtostrf it was in there from the cut and past for the fill buffer part and i passed it at this point -74.00000 is fine i am more interested in parsing the string back into values on the Pi side. ill look into fixing the dtostrf or what ever i need to use on the GPS data. prob just going to append the full GPRMC on anyhow or trans it every other send.
any who all moot when my RX code is failing.
4  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 24, 2013, 09:18:18 am
So this is my sending (arduino) side
Code:

struct MyStruct_t {
  double imuRoll;  //MinIMU-9 data
  double imuPitch;//MinIMU-9 data
  double imuYaw; //MinIMU-9 data
  long flAt;  // GPS latitude
  long flOn; // GPS Longitude
  //char GPSs{300]="";
  unsigned int FC_AP;     //Front Center Ultrasonic Avrage Ping
  unsigned int FL_AP;     //Front Left Ultrasonic Avrage Ping
  unsigned int FR_AP;     //Front Rgith Ultrasonic Avrage Ping
  unsigned int RC_AP;     //Rear Center Ultrasonic Avrage Ping
  int FCir;       //Front Center Infrared sen
  int FLir;       //Front Left Infrared sen
  int FRir;       //Front Right Infrared sen
  int RCir;       //Rear  Center Infrared sen
  double BSTempature;       //Barometric sen tempature
  int BSPressure;      //Barometric sen pressure
  int Heading;         //LM303 mag heading
}MyStruct;
void setup(){
 Serial.begin(57600);
 Serial3.begin(57600);
}
char sendBuff[90], tmpbuff[10];
void loop() {
    fillStruct();
    makeString();
    sendStr();
}

void sendStr(){
//   for (int i = 0; i < sizeof(sendBuff); i++){
   Serial.println(sendBuff);
   Serial3.println(sendBuff);
  // } 
// Serial.println("");
// Serial3.println("");   
 }
void fillStruct(){
    MyStruct.imuYaw = 111.456;
    MyStruct.imuPitch = -222.679;
    MyStruct.imuRoll = 333.012;
    MyStruct.flAt = 43.475743;
    MyStruct.flOn = -76.429243;
    MyStruct.FC_AP = 00;     //Front Center Ultrasonic Avrage Ping
    MyStruct.FL_AP = 11;     //Front Left Ultrasonic Avrage Ping
    MyStruct.FR_AP = 22;     //Front Rgith Ultrasonic Avrage Ping
    MyStruct.RC_AP = 33;     //Rear Center Ultrasonic Avrage Ping
    MyStruct.FCir = 1;       //Front Center Infrared sen
    MyStruct.FLir = 1;       //Front Left Infrared sen
    MyStruct.FRir = 0;       //Front Right Infrared sen
    MyStruct.RCir = 1;       //Rear  Center Infrared sen
    MyStruct.BSTempature = 99.1;       //Barometric sen tempature
    MyStruct.BSPressure = 30000;      //Barometric sen pressure
    MyStruct.Heading = 292;         //LM303 mag heading
   
}
void makeString(){
  strcpy(sendBuff, "<");
  dtostrf(MyStruct.imuYaw, 4,2, tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  dtostrf(MyStruct.imuPitch, 4,2, tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  dtostrf(MyStruct.imuRoll, 4,2, tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, "::");
  (MyStruct.flAt,3,6,tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  dtostrf(MyStruct.flOn,3,6,tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.Heading,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, "::");
  itoa(MyStruct.FC_AP,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.FL_AP,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.FR_AP,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.RC_AP,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, "::");
  itoa(MyStruct.FCir,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.FLir,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.FRir,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.RCir,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, "::");
  dtostrf(MyStruct.BSTempature,2,2,tmpbuff);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ",");
  itoa(MyStruct.BSPressure,tmpbuff,10);
  strcat(sendBuff, tmpbuff);
  strcat(sendBuff, ">");
  sendBuff[90] = '\0';

}
Arduino output is
Code:
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
<111.46,-222.68,333.01::333.01,-76.000000,292::0,11,22,33::1,1,0,1::99.10,30000>
dunno why lat and long are so empty after the dec but o well for now.
minicom on Pi shows the data the same at /dev/ttyAMA0 so i know it's hooked up right.


this is my PI side
Code:
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h>

void serialRead();
void prntBuff();

float yaw, pitch, roll;
int fd, z, x, sDA;
char cChar, recBuff[90];
int main ()
{
  if ((fd = serialOpen ("/dev/ttyAMA0", 57600)) < 0)
  {
   fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
    return 1 ;
  }

 for (;;)
        {
         x = 0;
         cChar = serialGetchar(fd);
        printf("Wating for data\n");
        if(cChar == '<') serialRead();
         serialRead();
 }
}

void serialRead(){
        sDA = serialDataAvail(fd);
        while (cChar != '>'  ){
           if (x < sizeof(recBuff)-1){
             printf("Getting data!\n ");
             cChar = serialGetchar(fd);
             recBuff[x] = cChar;
             x++;
             }
          else if(sDA == 0){
             printf("Got no Data\n");
             }
            break;
            }

        if(cChar == '>'){
        printf("End of data\n");
        x++;
        recBuff[x] = '0';
        serialFlush(fd);
        prntBuff();

    }
 }
void prntBuff(){
//          for(z = 0;z < sizeof(recBuff);z++){
            printf("%s\n",recBuff);
//              }
}

Pi output is this.
Code:
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 End of data
>00
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!
 Wating for data
Getting data!

am i filling the array wrong or printing it wrong?
5  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 18, 2013, 03:43:19 pm
nice idea but i seem to be having trouble sending any stuct to the Pi and reading it back into the stuct. think it has to do with how big the bytes for vars are on Pi and Arduino. int on arduino is 2 and 4 on PI but floats are both 4 bytes so it's very confusing to me at this point. was hoping some one had sent structs back and forth and had some code for it.
6  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 18, 2013, 01:18:46 pm
ok so one has even a little clue on sending structs that size to a Linux ARM system?
7  Using Arduino / Programming Questions / Re: GPS on arduino Uno on: September 17, 2013, 11:30:13 pm
still seems to me like 38400 is default baud rate. but i could be wrong
8  Using Arduino / Programming Questions / Re: How can I print GPS data in one line? on: September 17, 2013, 06:15:08 pm
lamers GPS lib is great and works for parsing GPRMC even has special functions for it.
GPRMC Routines

These routines provide easy access to 'GPRMC' type sentences. GPRMC type sentences are available from every GPS receiver, and for most applications they provide all the data you need. For example, they contain your exact position, speed, and direction of movement. For most projects, or if you are new to dealing with GPS data, these routines are all you need.

http://www.maartenlamers.com/nmea/

you can even make the lib only show them or all the sentences plus it has many functions other libs do not have.

as an after though i remember TinyGps did ok also.
http://arduiniana.org/libraries/tinygps/
9  Using Arduino / Programming Questions / Re: GPS on arduino Uno on: September 17, 2013, 01:02:38 pm
in the datasheet on Itead it shows the BPS rate for that shield being 38400. your code is at 4800.also the hardware is on the 0 1 pins so setting softserial to others wont help
unless you some how modified the shield or changed some jumpers etc. can you describe how you have it hooked up?
http://ftp://imall.iteadstudio.com/IM120417017_Arduino_GPS_shield/DS_IM120417017_ArduinoGPSshield.pdf is the shield in question yes?
10  Using Arduino / Networking, Protocols, and Devices / Re: GPS Not Working on: September 17, 2013, 09:34:19 am
i had the same prob come to find out mine was running at 57600bps. (LS20031) have you used the sketches to run the the mini gps config software at SFE's website? SFE also shows 57600 in there example sketch.
https://www.sparkfun.com/tutorials/176
NOTE: make sure to make a logic level shifter or use an IC for it if you plan on config the GPS as the GPS is 3.3v logic you will take the chance of frying it.Arduino seens 3.3v as logic HIGH so it can REC the data just fine at 3.3v.
got to Ebay and put in 5v 3.3v logic convert for some verry cost effective units.
i use TXB0108's i got from TI. http://www.ti.com/product/txb0108

11  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 17, 2013, 08:44:03 am
i still have my doubts on this being the best way to send data to the Pi for processing and back and in time for the bot not to drive off a cliff or into traffic or a wall.
but i guess ill try and see what the speed of data is this way.

FYI here is a sample of the REAL struct. it occurred to me you might be thinking to small

Code:
struct StructBuff_t {
  float imuRoll;  //MinIMU-9 data
  float imuPitch;//MinIMU-9 data
  float imuYaw; //MinIMU-9 data
  long flAt;  // GPS latitude
  long flOn; // GPS Longitude
  unsigned long Speed; //GPS speed
  unsigned long Date;  //GPS date
  unsigned long Course; //GPS curent course
  unsigned long Time;   //GPS Time
  unsigned long Fix_age; //GPS age of signal fix 
  unsigned int FC_AP;     //Front Center Ultrasonic Avrage Ping
  unsigned int FL_AP;     //Front Left Ultrasonic Avrage Ping
  unsigned int FR_AP;     //Front Rgith Ultrasonic Avrage Ping
  unsigned int RC_AP;     //Rear Center Ultrasonic Avrage Ping
  int FCir;       //Front Center Infrared sen
  int FLir;       //Front Left Infrared sen
  int FRir;       //Front Right Infrared sen
  int RCir;       //Rear  Center Infrared sen
  int BSTempature;       //Barometric sen tempature
  int BSPressure;      //Barometric sen pressure
  int Heading;         //LM303 mag heading
}
StructBuff;

so that is the struct as it stands there most certainly will be more data being processed back and forth i assure you.
BUT i do want to see this buffed and send over serial and parse it just to see how it's done. so lead on!  smiley-grin
12  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 17, 2013, 12:04:15 am
i understand the words you used i however do not see where exactly you want the count. should it be like
Code:
sDA = serialDataAvail(fd);
         while (cChar != '>' ){
           if (x <= sizeof(recBuff)-1){ // read only 22 then pass to end and get the \0 null for 23?
             printf("Getting data!\n ");
             cChar = serialGetchar(fd);
             recBuff[x] = cChar;
             x++;
             }
          else if(sDA == 0){
             printf("Got no Data\n");
             }
            break;
            }
13  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 16, 2013, 05:19:29 pm
"""think""" the sscanf is ok but i dont seem to be grabbing the serial data ok.
Code:
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h>

void serialRead();
void prntBuff();

float yaw, pitch, roll;
int fd, z, x, sDA, recBuff[23];
char cChar;
int main ()
{
  if ((fd = serialOpen ("/dev/ttyAMA0", 57600)) < 0)
  {
   fprintf (stderr, "Unable to open serial device: %s\n", strerror $
    return 1 ;
  }

 for (;;)
        {
         x = 0;
         cChar = serialGetchar(fd);
         if(cChar == '<') serialRead();
         serialRead();
 }
}

void serialRead(){
        sDA = serialDataAvail(fd);
         while (cChar != '>' ){
           if (sDA > 0){
             printf("Getting data!\n ");
             cChar = serialGetchar(fd);
             recBuff[x] = cChar;
             x++;
             }
          else if(sDA == 0){
             printf("Got no Data\n");
             }
            break;
            }

        if(cChar == '>'){
        printf("End of data\n");
        recBuff[x] = '\0';
        sscanf((char *)recBuff,"%f %f %f", &yaw, &pitch, &roll );
        printf("Yaw:%lf  :Pitch:%lf :Roll:%lf\n", yaw, pitch, roll);
//      serialFlush(fd);
//      prntBuff();

    }
 }
void prntBuff(){
        for (z = 0; z < sizeof(recBuff); z++){
            printf("%c",recBuff[z]);
            }
        printf("\n");
}
14  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 16, 2013, 10:05:40 am
new rpi code. getting odd result on printing the buff.
Code:
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h>

void serialRead();
void prntBuff();

int fd, z, x, sDA, cChar, recBuff[23];

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

 for (;;)
        {
         x = 0;
         cChar = serialGetchar(fd);
         if(cChar == '<') serialRead();
         serialRead();
 }
}

void serialRead(){
        sDA = serialDataAvail(fd);
         while (cChar != '>' ){
           if (sDA > 0){
             printf("Getting data!\n ");
             cChar = serialGetchar(fd);
             recBuff[x] = cChar;
             x++;
             }
          else if(sDA == 0){
             printf("Got no Data\n");
             }
            break;
            }

        if(cChar == '>'){
        printf("End of data");
        recBuff[x] = '\0';
        serialFlush(fd);
        prntBuff();

    }
 }
void prntBuff(){
        for (z = 0; z < sizeof(recBuff); z++){
            printf("%c",recBuff[z]);
            }
        printf("\n");
}

result
Code:
End of data>
Getting data!
 Getting data!
 End of data>>
Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!PuTTY
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 End of data>
Getting data!
 Getting data!
 Getting data!
 End of data>>
Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 Getting data!
 End of data>>
Getting data!
where in the world is Putty coming from and why >>'s? and where is my precious data  smiley-cry
output from minicom
Code:
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
<111.46,-222.68,333.01>
so dev/ttyAMA0 is geting the right format coming in.
15  Using Arduino / Networking, Protocols, and Devices / Re: Ard <--> Pi serial data transfer(unsolved) on: September 16, 2013, 08:53:33 am
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
Code:

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.
Code:
#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-twist

Pages: [1] 2 3 ... 9