Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2311
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #45 on: January 29, 2013, 02:13:48 am » |
There are much simpler methods to change the length of a string than copying it... into a shorter array.. Set the Nth+1 byte to '/0' and you have shortened it's length. Co-incidentally it uses less ram and fewer instructions and that can only mean that the program will run faster so you have more time for other tasks, W/O copying that array an extra time. You Might try to 'single' step that array manipulation in your head, I think you'll find the required modification to make it perform (print) as you so desire.
Bob
|
|
|
|
« Last Edit: January 29, 2013, 02:15:21 am by Docedison »
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #46 on: January 29, 2013, 04:07:45 am » |
Set the Nth+1 byte to '/0' That's two bytes. Try '\0' instead.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35566
Seattle, WA USA
|
 |
« Reply #47 on: January 29, 2013, 05:50:37 am » |
You need a global array to hold the GPS data in, not a local array. You need a global index into that array.
Each time you read a character from the GPS, there are three possibilities. The character could be the start of a packet - a $. If it is, set index to 0 and store the character.
The character could be the end of a packet - a carriage return, most likely, but the data after the * is just a checksum, so you could ignore that data and treat the * as the end of the packet. Whichever option you choose, the arrival of the end of the packet means that it is time to broadcast some data, after you store the character.
The third option is that the character is neither a start marker or an end marker, so it needs to be stored in the array. Store the character in the index position, increment index, and store a NULL in the index position.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #48 on: January 29, 2013, 08:32:00 am » |
I read JHaskell's blog on arduino comm and it' sone of the best beginner guides i have seen for it. link here http://jhaskellsblog.blogspot.com/2011/05/serial-comm-fundamentals-on-arduino.htmlso now this is what it looks like. #include <nmea.h> #include "nRF24L01.h" #include "RF24.h" #include "printf.h" #include <nRF24L01.h> #include <SPI.h> NMEA gps(ALL); // GPS data connection to all sentence types RF24 radio(48,49); void setup() { Serial.begin(57600); Serial2.begin(57600); //**************Start Transiever (NRF24L01) config************** printf_begin(); printf("\n\rRadio Setup\n\r"); radio.begin(); radio.setDataRate(RF24_2MBPS); radio.setCRCLength(RF24_CRC_16); radio.setPayloadSize(4 * sizeof(byte)); radio.setChannel(2); radio.setAutoAck(true); radio.openReadingPipe(1,0xF0F0F0F0E1LL); radio.openWritingPipe(0xF0F0F0F0D2LL); radio.startListening(); radio.printDetails(); //**************End Transiever (NRF24L01) config************** } #define DBUFFSIZE 100 char gpsBuff[DBUFFSIZE+1]; //Add 1 for NULL terminator byte gpsBuffIndex = 0;
union inGps2byte_t { byte inGpsout[100]; char inGpsin; } inGps2byte;
void loop() { // start of loop
getSerialString(); radio.startListening(); Tchar2byte12(); } // go back to start of loop
boolean getSerialString(){
char startChar = '$'; // or '!', or whatever your start character is char endChar = '\10'; boolean storeString = false; //This will be our flag to put the data in our buffer
static byte gpsBuffIndex = 0; while(Serial2.available()>0){ char incomingbyte = Serial2.read(); if(incomingbyte==startChar){ gpsBuffIndex = 0; //Initialize our dataBufferIndex variable storeString = true; } if(storeString){ //Let's check our index here, and abort if we're outside our buffer size //We use our define here so our buffer size can be easily modified if(gpsBuffIndex==DBUFFSIZE){ //Oops, our index is pointing to an array element outside our buffer. gpsBuffIndex = 0; break; } if(incomingbyte==endChar){ gpsBuff[gpsBuffIndex] = 0; //null terminate the C string //Our data string is complete. return true return true; } else{ gpsBuff[gpsBuffIndex++] = incomingbyte; gpsBuff[gpsBuffIndex] = 0; //null terminate the C string } } else{ } } return false; } void Tchar2byte12(){ inGps2byte.inGpsin = *gpsBuff; byte output[100]; output[0] = inGps2byte.inGpsout[0]; output[1] = inGps2byte.inGpsout[1]; output[2] = inGps2byte.inGpsout[2]; output[3] = inGps2byte.inGpsout[3]; output[4] = inGps2byte.inGpsout[4]; output[5] = inGps2byte.inGpsout[5]; output[6] = inGps2byte.inGpsout[6]; output[7] = inGps2byte.inGpsout[7]; output[8] = inGps2byte.inGpsout[8]; output[9] = inGps2byte.inGpsout[9]; output[10] = inGps2byte.inGpsout[10]; output[11] = inGps2byte.inGpsout[11]; output[12] = inGps2byte.inGpsout[12]; output[13] = inGps2byte.inGpsout[13]; output[14] = inGps2byte.inGpsout[14]; output[15] = inGps2byte.inGpsout[15]; output[16] = inGps2byte.inGpsout[16]; output[17] = inGps2byte.inGpsout[17]; output[18] = inGps2byte.inGpsout[18]; output[19] = inGps2byte.inGpsout[19]; output[20] = inGps2byte.inGpsout[20]; output[21] = inGps2byte.inGpsout[21]; output[22] = inGps2byte.inGpsout[22]; output[23] = inGps2byte.inGpsout[23]; output[24] = inGps2byte.inGpsout[24]; output[25] = inGps2byte.inGpsout[25]; output[26] = inGps2byte.inGpsout[26]; output[27] = inGps2byte.inGpsout[27]; output[28] = inGps2byte.inGpsout[28]; output[29] = inGps2byte.inGpsout[29]; output[30] = inGps2byte.inGpsout[30]; output[31] = inGps2byte.inGpsout[31]; output[32] = inGps2byte.inGpsout[32]; output[33] = inGps2byte.inGpsout[33]; output[34] = inGps2byte.inGpsout[34]; output[35] = inGps2byte.inGpsout[35]; output[36] = inGps2byte.inGpsout[36]; output[37] = inGps2byte.inGpsout[37]; output[38] = inGps2byte.inGpsout[38]; output[39] = inGps2byte.inGpsout[39]; output[40] = inGps2byte.inGpsout[40]; output[41] = inGps2byte.inGpsout[41]; output[42] = inGps2byte.inGpsout[42]; output[43] = inGps2byte.inGpsout[43]; output[44] = inGps2byte.inGpsout[44]; output[45] = inGps2byte.inGpsout[45]; output[46] = inGps2byte.inGpsout[46]; output[47] = inGps2byte.inGpsout[47]; output[48] = inGps2byte.inGpsout[48]; output[49] = inGps2byte.inGpsout[49]; output[50] = inGps2byte.inGpsout[50]; output[51] = inGps2byte.inGpsout[51]; output[52] = inGps2byte.inGpsout[52]; output[53] = inGps2byte.inGpsout[53]; output[54] = inGps2byte.inGpsout[54]; output[55] = inGps2byte.inGpsout[55]; output[56] = inGps2byte.inGpsout[56]; output[57] = inGps2byte.inGpsout[57]; output[58] = inGps2byte.inGpsout[58]; output[59] = inGps2byte.inGpsout[59]; output[60] = inGps2byte.inGpsout[60]; output[61] = inGps2byte.inGpsout[61]; output[62] = inGps2byte.inGpsout[62]; output[63] = inGps2byte.inGpsout[63]; output[64] = inGps2byte.inGpsout[64]; output[65] = inGps2byte.inGpsout[65]; output[66] = inGps2byte.inGpsout[66]; output[67] = inGps2byte.inGpsout[67]; output[68] = inGps2byte.inGpsout[68]; output[69] = inGps2byte.inGpsout[69]; output[70] = inGps2byte.inGpsout[70]; output[71] = inGps2byte.inGpsout[71]; output[72] = inGps2byte.inGpsout[72]; output[73] = inGps2byte.inGpsout[73]; output[74] = inGps2byte.inGpsout[74]; output[75] = inGps2byte.inGpsout[75]; output[76] = inGps2byte.inGpsout[76]; output[77] = inGps2byte.inGpsout[77]; output[78] = inGps2byte.inGpsout[78]; output[79] = inGps2byte.inGpsout[79]; output[80] = inGps2byte.inGpsout[80]; output[81] = inGps2byte.inGpsout[81]; output[82] = inGps2byte.inGpsout[82]; output[83] = inGps2byte.inGpsout[83]; output[84] = inGps2byte.inGpsout[84]; output[85] = inGps2byte.inGpsout[85]; output[86] = inGps2byte.inGpsout[86]; output[87] = inGps2byte.inGpsout[87]; output[88] = inGps2byte.inGpsout[88]; output[89] = inGps2byte.inGpsout[89]; output[90] = inGps2byte.inGpsout[90]; output[91] = inGps2byte.inGpsout[91]; output[92] = inGps2byte.inGpsout[92]; output[93] = inGps2byte.inGpsout[93]; output[94] = inGps2byte.inGpsout[94]; output[95] = inGps2byte.inGpsout[95]; output[96] = inGps2byte.inGpsout[96]; output[97] = inGps2byte.inGpsout[97]; output[98] = inGps2byte.inGpsout[98]; output[99] = inGps2byte.inGpsout[99]; /* radio.stopListening(); bool ok = radio.write(output,sizeof(byte)); if (ok) printf("ok...Tchar2byte12\n\r"); else printf("failed.Tchar2byte12\n\r"); delay(10); */ for (int i = 0; i < sizeof(inGps2byte.inGpsout); i++) { Serial.print(inGps2byte.inGpsout[i]); } Serial.println(); }
now the gpsBuff works fine i can scan it and print the bits in the array out. now im just having probs geting them stuffed into the union to convert to bytes for the radio to send. scanning inGps2byte.inGpsout shows 36 on - and 0 on the other [1]-[99].
i am guessing it's due to the fact im using a pointer (to my understanding pointers hold addresses to mem of the item your trying to actually access) therefor it's understandable the array is empty. so now i just need to learn pointers and how to reference them properly i guess. and if i do that then i can forgo all this and just use the NMEA lib and point it into a union for byte conversion or not even, have not got that far yet.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35566
Seattle, WA USA
|
 |
« Reply #49 on: January 29, 2013, 09:28:57 am » |
union inGps2byte_t { byte inGpsout[100]; char inGpsin; } inGps2byte; The reason for using a union is to have two types occupy the same space. This only works when the two types are the same size. A 4 byte float and a 4 element array of bytes are the same size. Setting the float populates the byte array. Populating the byte array sets the float. That is NOT what you want to be doing here. There is no reason for this union, and it is wrong anyway. The two parts are not the same size. You can just send gpsBuff. output[0] = inGps2byte.inGpsout[0]; output[1] = inGps2byte.inGpsout[1]; output[2] = inGps2byte.inGpsout[2]; output[3] = inGps2byte.inGpsout[3]; output[4] = inGps2byte.inGpsout[4]; output[5] = inGps2byte.inGpsout[5]; output[6] = inGps2byte.inGpsout[6]; output[7] = inGps2byte.inGpsout[7]; WTF? Use a for loop!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #50 on: January 29, 2013, 10:43:50 am » |
i did not use a loop because i was having to many problems keeping it all straight in my head trying to figure what was indexing what and calling and pointing etc. so i figured why not do them one by one then i could scan them and *know* what place on the 2 arrays i was looking in and what was there. anyhow i guess i mucked around with so many arrays i just never even considered sending gpsBuff lol! thanks everyone with the help so far. now i just need to figure out how to send all these types in some grand order and retrieve them on the RX side in order to sort and use the incoming data. does this basically say that radio.read can take any type of buffer so int char float etc? bool RF24::read ( void * buf, uint8_t len )
Read the payload.
Return the last payload received
The size of data read is the fixed payload size, see getPayloadSize()
Note: I specifically chose 'void*' as a data type to make it easier for beginners to use. No casting needed.
Parameters: buf Pointer to a buffer where the data should be written len Maximum number of bytes to read into the buffer
Returns: True if the payload was delivered successfully false if not
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35566
Seattle, WA USA
|
 |
« Reply #51 on: January 29, 2013, 11:38:03 am » |
does this basically say that radio.read can take any type of buffer so int char float etc? Yes, it does.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #52 on: January 29, 2013, 06:14:47 pm » |
thanks PaulS, so what method would be best for collecting all the data types from GPS (char)/IMU (float)/Ultra sonic (INT) and sending them in a constantly predictable order so on the RX end i can receive them and know what sensor they are from and type of data they are char float int. i was thinking structures because i could do like sensors{ char GPS float IMU1,2,3 int Ultrasonic int/byte/float/char other stuffs etc. }sensors; but how could i pack that all up and send it in one buffer? sensors.All i supose i could delimit the data with some odd strings like.
<(@#:dataID,GPS|DataType,char|DataBits,$GPRMC,140053.00,A,4454.1740,N,09325.0143,W,000.0,128.7,300508,001.1,E,A*2E|:~&!>
so find < is next ( next@ next #? yes= good start find next : now look at tag DataID wich RX will then have a var for it predefined with type so it can hold it. look for next | and get next tag id, DataType,type of data. would i not need to do it this way so the RX side knows how to parse each type?
or would it be simpler the make a char array and converts all types to it RF out the array rebuild it and convert back?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35566
Seattle, WA USA
|
 |
« Reply #53 on: January 30, 2013, 06:29:48 am » |
i was thinking structures because i could do like You could, and that would be the best way, if ALL the data is to be sent on the same schedule. (GPS is char[], not char).
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #54 on: January 31, 2013, 11:38:57 am » |
this ones has me stumped struct StructBuff_t { char GPS[100]; char imuRoll[6]; char imuPitch[6]; char imuYaw[6]; char UltS[3]; char SenBuffersAll[133]; } StructBuff;
void BuildTransBuffer(){ // Struct your Buffers here PString(StructBuff.GPS, sizeof(StructBuff.GPS), gps.sentence()); //+100 Buff //----------------------Delimitor------------------------------------------ PString(StructBuff.imuRoll, sizeof(StructBuff.imuRoll), ToDeg(roll)); //+6 Buff //----------------------Seperator------------------------------------------ PString(StructBuff.imuPitch, sizeof(StructBuff.imuPitch), ToDeg(pitch)); //+6 Buff //----------------------Seperator------------------------------------------ PString(StructBuff.imuYaw, sizeof(StructBuff.imuYaw), ToDeg(yaw)); //+6 Buff //----------------------Delimitor------------------------------------------ PString(StructBuff.UltS, sizeof(StructBuff.UltS), averagePing()); //+3 Buff = 124 //----------------------Delimitor------------------------------------------ // 132 point buffer String Prefix, Suffix, Seperator, Delimit, sGps, sRoll, sPitch, sYaw, sAP, SenBuff; Prefix = String('<'); Suffix = String('>'); Seperator = String('^'); Delimit = String('|'); sGps = gps.sentence(); // sGps = String(gps.sentence()); sRoll = StructBuff.imuRoll; // sRoll = String(StructBuff.imuRoll); sPitch = StructBuff.imuPitch; // sPitch = String(StructBuff.imuPitch); sYaw = StructBuff.imuYaw; // sYaw = String(StructBuff.imuYaw); // sAP = averagePing(); //cant use unsigned int as char string // sAP = String(averagePing());
SenBuff = String(""); //Start string append SenBuff += Prefix; SenBuff += Prefix; SenBuff += Prefix; SenBuff += Delimit; SenBuff += sGps; SenBuff += Delimit; SenBuff += sRoll; SenBuff += Seperator; SenBuff += sPitch; SenBuff += Seperator; SenBuff += sYaw; SenBuff += Delimit; SenBuff += sAP; SenBuff += Delimit; SenBuff += Suffix; SenBuff += Suffix; SenBuff += Suffix; //End string append PString(StructBuff.SenBuffersAll, sizeof(StructBuff.SenBuffersAll), SenBuff); Serial.println(SenBuff); }
SenBuff/StructBuff.SenBuffersAll contence of SenBuff <<<||0.00^0.00^0.00||>>> <<<||0.00^0.00^0.00||>>>
i can see there filling with my Trigger and Delimit and Separators but i guess it's just not that simple to stuff function output into strings? LOL cant blame a guy for trying. ill keep tinkering while i wait for your advice and witty slice and dice i am sure you will use to render my code impotent. till then. BTW thanks for all the help with this. i have been learning a lot i think
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35566
Seattle, WA USA
|
 |
« Reply #55 on: January 31, 2013, 11:52:33 am » |
You have a structure that contains each item individually PLUS all collected in a char array. Why?
Which Arduino are you using? Between the two String classes, duplicate data in the structures, etc. I'm guess that memory is a problem.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #56 on: January 31, 2013, 12:14:48 pm » |
Mega 2560's are what im using. im trying to format the output from the struct into the last array in the struct with my prefix and suffix data so when i send it i can parse it and stick them where they belong. so PStrings seemed to be a easy way to gather my data and input them into the StructBuff.GPS StructBuff.imu*** etc. i call them and push them into the struct one last time for fresh data and then pull each array and format it for the main StructBuff.SenBuffersAll past holding what should be something like <<<|$GPRMC,XXXXXX.00,A,4454.1740,N,XXXXX.0143,W,000.0,128.7,300508,001.1,E,A*2E|-3.87^34.01^0.13|33|>>>
it worked with dummy data in the strings sGps = String("blabalbla"); guess i cant just pass it gps.sencence(). at any rate, you know of a less memory eating method to format the output of 5 arrays of varying size inside a stuct and stuffing them into a main one holding all the parse data for the receiver to know what data bits belong where?.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #57 on: January 31, 2013, 12:33:23 pm » |
my understanding of strings are they are stored as arrays yes? so liking say sGPS = StructBuff.GPS even tho it's a char array strings should be able to read it? the compiler seems to think it's ok. commented best i could so show what my goal is. void BuildTransBuffer(){ ////////////////////////////////////////////////////////////////////////////////////////////////// //Collect data and fill StructBuff elements // Struct your Buffers here //+1 for \0 PString(StructBuff.GPS, sizeof(StructBuff.GPS), gps.sentence()); //+100 Buff //----------------------Delimitor------------------------------------------ PString(StructBuff.imuRoll, sizeof(StructBuff.imuRoll), ToDeg(roll)); //+6 Buff //----------------------Seperator------------------------------------------ PString(StructBuff.imuPitch, sizeof(StructBuff.imuPitch), ToDeg(pitch)); //+6 Buff //----------------------Seperator------------------------------------------ PString(StructBuff.imuYaw, sizeof(StructBuff.imuYaw), ToDeg(yaw)); //+6 Buff //----------------------Delimitor------------------------------------------ PString(StructBuff.UltS, sizeof(StructBuff.UltS), averagePing()); //+3 Buff = 122 //----------------------Delimitor------------------------------------------ //+12 for Pre Suf Del Sep //////////////////////////////////////////////////////////////////////////////////// 134 point buffer String Prefix, Suffix, Seperator, Delimit, sGps, sRoll, sPitch, sYaw, sAP, SenBuff; Prefix = String('<'); //////////////////////// Suffix = String('>'); // Seperator = String('^'); //Prefix/Sufix/Sep/Delim Delimit = String('|'); // sGps = StructBuff.GPS; //--------------------- sRoll = StructBuff.imuRoll; //char arrays with sensor sPitch = StructBuff.imuPitch;//data collected with PString sYaw = StructBuff.imuYaw; // sAP = StructBuff.UltS; //--------------------- SenBuff = String(""); //formatted string of sen data. /////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// // format the string for transmit array. //<<<|$GPRMC,XXXXXX.00,A,4454.1740,N,XXXXX.0143,W,000.0,128.7,300508,001.1,E,A*2E|-3.87^34.01^0.13|33|>>> //Start string append SenBuff += Prefix; SenBuff += Prefix; SenBuff += Prefix; SenBuff += Delimit; SenBuff += sGps; SenBuff += Delimit; SenBuff += sRoll; SenBuff += Seperator; SenBuff += sPitch; SenBuff += Seperator; SenBuff += sYaw; SenBuff += Delimit; SenBuff += sAP; SenBuff += Delimit; SenBuff += Suffix; SenBuff += Suffix; SenBuff += Suffix; //End string append //Formatting done. ///////////////////////////////////////////////////////////////////////////////////////////////////////// /////PString formatted senbuff string into SenBuffersAll array in StuctBuff struct PString(StructBuff.SenBuffersAll, sizeof(StructBuff.SenBuffersAll), SenBuff); ///Spew the String to local serial Serial.println(SenBuff); /////////////////////////////////// }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #58 on: January 31, 2013, 01:52:18 pm » |
Ok geting closer i think void BuildTransBuffer(){ ////////////////////////////////////////////////////////////////////////////////////////////////// //Collect data and fill StructBuff elements // Struct your Buffers here //+1 for \0 PString(StructBuff.GPS, sizeof(StructBuff.GPS), gps.sentence()); //+100 Buff //----------------------Delimitor------------------------------------------ PString(StructBuff.imuRoll, sizeof(StructBuff.imuRoll), ToDeg(roll)); //+6 Buff //----------------------Seperator------------------------------------------ PString(StructBuff.imuPitch, sizeof(StructBuff.imuPitch), ToDeg(pitch)); //+6 Buff //----------------------Seperator------------------------------------------ PString(StructBuff.imuYaw, sizeof(StructBuff.imuYaw), ToDeg(yaw)); //+6 Buff //----------------------Delimitor------------------------------------------ PString(StructBuff.AP, sizeof(StructBuff.AP), averagePing()); //+3 Buff = 122 //----------------------Delimitor------------------------------------------ //+12 for Pre Suf Del Sep //////////////////////////////////////////////////////////////////////////////////// 134 point buffer // format the string for transmit array. //<<<|$GPRMC,XXXXXX.00,A,4454.1740,N,XXXXX.0143,W,000.0,128.7,300508,001.1,E,A*2E|-3.87^34.01^0.13|33|>>> //Start string append strlcat(StructBuff.SenBuffersAll,"<<<|",sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,StructBuff.GPS,sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,"|",sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,StructBuff.imuRoll,sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,",",sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,StructBuff.imuPitch,sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,",",sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,StructBuff.imuYaw,sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,"|",sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,StructBuff.AP,sizeof(StructBuff.SenBuffersAll)); strlcat(StructBuff.SenBuffersAll,"|>>>",sizeof(StructBuff.SenBuffersAll)); //End string append //Formatting done. ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///Spew the String to local serial //for (int i = 0; i < sizeof(StructBuff.SenBuffersAll); i++){ // Serial.print(StructBuff.SenBuffersAll[i]); // } // Serial.println(); /////////////////////////////////// }
output is this tho <<<||0.00,0.00,0.00|3|>>> <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>> <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>> <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>> <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>> <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 <<<||0.00,0.00,0.00|3|>>><<<||0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<|| 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0 0.00,0.00,0.00|4|>>><<<||0.00,0.00,0.00|4|>>><<<||0.0
display code void DisplayTransBuffer(){ for (int i = 0; i < sizeof(StructBuff.SenBuffersAll); i++){ Serial.print(StructBuff.SenBuffersAll[i]); } Serial.println(); }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 103
Arduino rocks
|
 |
« Reply #59 on: February 01, 2013, 10:00:53 am » |
having problems geting my sensors to refresh. now i know in the StuffStructBuff function the data is being pulled and sent to the individual elements of the struct StructBuff because i can parse them out to the term from the function so i know there geting filled with constant fresh data streams. but the main "formatted" buffer seems to stop at 3 strings ( should be 1 but the GPS data is missing for some reason). so it seems strlcat is working and is making a full formatted string and it is making it into the SenBuffersAll array just fine? or not or seems to stop refreshing it. do i need to "flush it?" or some other trick? here is the output then i will post the code base so far ( might take a couple posts it's kinda big) <<<||0.00,0.01,0.00|0|>>><<<||-0.78,-0.69,-0.00|1|>>><<<||-0.75,-0.24,-0.00|2|>>><<<||-0.18,0.33,-0.01|3|>>><<<||-0.44,0.87,0.0 <<<||0.00,0.01,0.00|0|>>><<<||-0.78,-0.69,-0.00|1|>>><<<||-0.75,-0.24,-0.00|2|>>><<<||-0.18,0.33,-0.01|3|>>><<<||-0.44,0.87,0.0 <<<||0.00,0.01,0.00|0|>>><<<||-0.78,-0.69,-0.00|1|>>><<<||-0.75,-0.24,-0.00|2|>>><<<||-0.18,0.33,-0.01|3|>>><<<||-0.44,0.87,0.0 <<<||0.00,0.01,0.00|0|>>><<<||-0.78,-0.69,-0.00|1|>>><<<||-0.75,-0.24,-0.00|2|>>><<<||-0.18,0.33,-0.01|3|>>><<<||-0.44,0.87,0.0
now it is correct is size to the array but since the GPS is not parsing in it's bot full to the 128 chars so it fill with the new strings etc. "SHOULD" look like this IF the GPS was making it in. <<<|$GPRMC,XXXXXX.00,A,4454.1740,N,XXXXX.0143,W,000.0,128.7,300508,001.1,E,A*2E|-3.87,34.01,0.13|33|>>>
ill post the complete code next.
|
|
|
|
|
Logged
|
|
|
|
|
|