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

XBee receiving Junk bytes on Intel IoT Eclipse

I am trying to use eclipse and C in order to receive the UART data from the XBee connected to the galileo.

But I am receiving the packets which contain my message but are attached with some other junk "accomplices".

PLease check out the below:

frame:1--> 7e,0,18,ffffff92,0,13,ffffffa2,0,

40,ffffffe9,1b,ffffffc2,fffffff1,76,1,1,

0,0,f,2,8,0,0,2,

9,2,9,1a,

-------------------------------------------

frame:2--> 7e,0,18,ffffff92,0,13,ffffffa2,0,

40,ffffffe9,1b,ffffffc2,fffffff1,76,1,1,

0,0,f,3,ffffffff,3,ffffffff,3,

ffffffff,3,ffffffff,32,

Actually this is a IO sample indicator where the DIO are disabled and the all the ADC inputs are enabled.

The second ADC is attached to motion sensor which is why the two frames look dissimilar.(one -->no motion, two-->motion).

The C code is put below, pls check it:

# include

# include

# include "mraa.h"

int main() {

mraa_uart_context u0;

u0 = mraa_uart_init(0);

mraa_uart_set_baudrate(u0,9600);

char bytes[26];

for (;;) {

if(mraa_uart_data_available(u0,2000)){

int nbytes = mraa_uart_read(u0,bytes,26);

if(nbytes > 0){

int i=0;

for(;i

printf("%x,",bytes[i]);

}

//printf("%x",bytes[0]);

}

}

printf("\n");

}

return 0;

}

----------Sorry for the bad indentation-----------------

Any suggestions/inputs/solutions are most welcomed and heartily appreciated..

Thank you.

Nathan.

Tags (1)
5 Replies
Sergio_A_Intel
Employee
70 Views

Hi,

It seems that the junk values you describe are being read by the UART in a series of F's. This means the UART is receiving a high digital value in a determined period. This is most likely because there are moments where the xbee is inactive and not sending data and during these periods of time the UART is printing high values in the frame's output. If the values printed are correct, not taking into account the junk values, then you'd have to figure out a way to filter the data that comes to the UART or adapt your code to only print out the correct values.

Sergio

NK
New Contributor I
70 Views

The thing is that the 'ffff" was due to sign extension.I had used char for collecting the uart bytes, but when I used uint8_t it worked.

But my problem is that, the mraa_uart_read only reads 8 bytes in one cycle and prints them.So you can observe that there are only 8 bytes on any row or lesser in the last one.I donot know why this is happening.I even tried setting the mode of uart(mraa_uart_set_mode) in which you can set the bytes to be read but still it did not work.

Any help/suggestions would be appreciated.

Thnks.

Sergio_A_Intel
Employee
70 Views

How are you setting the mraa_uart_set_mode function? You're not using it in the code you shared in the original post. Adding this command to the code above gives the same result as above?

Just in case you haven't seen this, there's a document called shield testing report http://www.intel.com/content/www/us/en/support/boards-and-kits/000005913.html Shield Testing Report for Intel® Galileo Board and Intel® Edison Board . It includes some the tested shields and sensors. It also includes the xbee sensor in several sections, maybe you can find something useful here.

Sergio

NK
New Contributor I
70 Views

Like this

mraa_uart_set_mode(u0,29,MRAA_UART_PARITY_NONE,1);

Actually this was also not successful because I was still receiving the frame in the 8,8,8,4 format for the IO sample.

In a specific iteration the uart port is returning only 8 bytes max.And hence the pattern.

Any reasons as to why it is happening?

Sergio_A_Intel
Employee
70 Views

Hi,

Take a look at https://github.com/intel-iot-devkit/mraa/blob/master/src/uart/uart.c mraa/uart.c at master · intel-iot-devkit/mraa · GitHub . The mraa_uart_set_mode function is declared here. The maximum value you can use for the bytesize parameter is 8. So that's the reason why you're only receiving 8 bytes maximum.

Sergio

Reply