Extracting data from the data I/O Data Format

Hi,

I am recieving the data using Xbee Series1 in the I/O Data Frame Format.I would like to extract the data from the frame.Can you please send me any sample code to do this.

Thanku very much

I am recieving the data using Xbee Series1 in the I/O Data Frame Format.

Receiving it from what?

I would like to extract the data from the frame.

Seems to me like it would simply be the inverse of putting the data into the frame on the sending end.

Hi,

I am recieving the data in this format
7E -Correct packet header byte

00 0A -Payload = Decimal 10 bytes. (Bytes 4-13 this example)

83 -Packet type=input line states, 16 bit source address

00 01 - 16 bit source address (MY setting) of transmitting XBee

1F - RSSI value, or rec'd signal strength (-31dBv, pretty good!)

00 -Broadcast options

01 -Sample count (decimal 1 in this example)

04 00 -Channel Indicator

03 FF - A/D output for DIO 1 ? (03FF is out of range)

55 -Checksum

I just want to display the A/D output .

Thank you

So the AD count is at offset 20 if I count correctly. You could read all the bytes into an array

7E,00,01,02,03,04,05,06,07,08,09,0A,83,00,01,1F,00,01,04,00,03,FF,55

You want the yellow bytes so

int adVal = (myArray[20] << 8 ) + myArray[21];

gives you the value.

Alternatively just count the characters as they come in and use the 20th and 21st bytes.


Rob

Hi,

I am using the following code now everything is displaying in decimal but i only want to display the exact value not call.Can you please let me know how to modify the following code to extract the exact data.

void loop()
{
if (Serial.available()) {
byte incomingByte = Serial.read();
//Serial.print(incomingByte, HEX);
myArray[20]=incomingByte;
int adVal = (myArray[20] << 8 ) + myArray[21];
Serial.print(adVal);

Serial.print(" , ");

}
}

Thanku very much

I am using the following code now everything is displaying in decimal but i only want to display the exact value not call.

No idea what this means. You need to collect the data in an array. Then, when there are 22 bytes, or more, in the array, then you can extract the data of interest.

Posting ALL of your code would help. The XBee library generally takes care of collecting the data in an array for you. All you need to do is check the payload size to determine the offset to the data of interest and extract that data, as Graynomad showed how (assuming a fixed payload size).