Community
cancel
Showing results for 
Search instead for 
Did you mean: 
TTony5
New Contributor I
1,523 Views

Question: Data Buffering using UPM XBee libraries

Hi!,

I am running a code where the Edison is alternating between retrieving/sending data on the XBee interface and reading from a database. The code is sequential so, while it is reading on the database some data may arrive on the XBee, that supposedly would be lost. The data buffer on the XBee module is 202 bytes long. The modules are it AT mode with no flow control activaded.

However, after testing to send data chunks over 202 bytes, up to 1024. The XBee listening function is using a 200ms timeout and capturing the data chunks up to 1024 bytes. it seems that it always catches the whole data stream without truncating the data chunk. This makes me wonder how this is happening, if there is actually some extra buffering going on or it is all due to the 200ms timeout in the ReadXBee function. (in the UPM example is 1000)

public static String ReadXBee (){

String response="";

if (sensor.dataAvailable(200)){

response=sensor.readDataStr(1024); //reads available data and puts it into string, the call blocks until data is available

}

return response;

}

Any ideas please?

4 Replies
idata
Community Manager
44 Views

Hello TonyMontes,

 

 

By taking a quick look at xbee.cxx ( https://github.com/intel-iot-devkit/upm/blob/master/src/xbee/xbee.cxx), I Found that the library's value for its max buffer is 1024, which makes sense when comparing it to what you're telling me. I believe what the library does is, it receives up to 1024 bytes until the timeout. I think what you'd have to do in order to truncate the data is to change the max buffer value.

 

 

I would also suggest you to contact the developer of the library, the contact information can be found in the source code ( https://github.com/intel-iot-devkit/upm/blob/master/src/xbee/xbee.cxx). I hope this helps.

 

-Peter.
TTony5
New Contributor I
44 Views

Thanks for the answer,

I played around with the timeout and the buffer size. I found that, dataavailable() returns the buffered data when it encounters the end of packet in the transmission. No matter how much data is sent. For example:

- If 1024 bytes are sent from XCTU at once, the function captures the 1024 bytes.

- If 1024 bytes are sent from another Edison, calling the XBee write() function two consecutive times. It will capture the first 512 byte packet and sometimes loses the second packet.

I believe that a second packet may be lost while the Edison is busy processing the first packet (accessing the database for example).. I guess that catching the second packet depends on the timings on both sides.

idata
Community Manager
44 Views

Hi TonyMontes,

 

 

I don't have access to an Xbee, therefore I can't try to replicate the behavior on my Edison. So, my best suggestion is that you open an issue on UPM's Github ( https://github.com/intel-iot-devkit/upm/issues), that way you will be able to contact the developers directly. I believe this might be the best option as there seems to be an issue with the Xbee library.

 

 

-Peter.
TTony5
New Contributor I
44 Views

Thank you very much for your help Peter, It is appreciated. I did not know that there was an issue section for the UPM libraries on Github.

Reply