c++ - ZigBee Arduino, Incorrect parsed datas -


i've got trouble make communication between 2 arduinos uno work.

arduino1<>zigbee >---------- < zigbee < > arduino2

i'm trying make them understand each other. message going between 1st arduino zigbee second zigbee.

arduino1<>zigbee>----------< zigbee--x-- arduino2

the problem is: when try parse, on arduino2 payload of incoming packet arduino1, messages differents.

since i'm using zigbee api2, there's crc on message while travelling between zigbees (after investigations) i'm sure packet correct arriving on zigbee2 (if not, packet dropped).

so main event now:

memmove(received,xbee_rx.getdata(),24); 

when receive packet

xbee.readpacket(); if (xbee.getresponse().isavailable()) {   if (xbee.getresponse().getapiid() == zb_rx_response)     {         xbee.getresponse().getzbrxresponse(xbee_rx);         memmove(received,xbee_rx.getdata(),24);         (int = 0; < 24; i++) {                  serial.print(received[i],hex);         }     } } 

while send " 4144000000000000446b3ab4083e8484258 " in hex on arduino1

i received " 414400000000000008c201862419b5 " in hex on arduino2

it's example, datas wrong (apart maybe 2 first bytes). result kinda random , unusable me.

i tried parse

for (int = 0; < 24; i++) {     received[i] = xbee_rx.getdata()[i];     serial.print(received[i],hex);   } 

but result kinda same.

so question is: doing parsing wrong? there problem getdata() function?

thank :-)

edit: after research, i've found if

   (int = 0; < sizeof(xbee_rx.getdata()); i++) {       serial.print(xbee_rx.getdata()[i],hex);   }         serial.println();   (int = 0; < sizeof(received); i++) {          serial.print(received[i],hex);   } 

datas not same.

414400000000000008c201885358c80
414400000000000008c201862419e6

instead of 4144000000000000441a6e9b407ddd494258

so, guess while i'm reading data changing , that's maybe why f**k datas. so, there way "freeze" datas before read them?

i found going on: i'm using newsoftserial (because 1 serial not enough) , seems f**ck timers (long timeout) , using either timerone library or "thread.h" library kinda allow me use interrupt.

well, whole thing messed timeout on nss beware if use them in future. had switch timerone thread.h (which wasn't real threads of course), allowing me avoid problems.

i found normal serial, 1 bundled arduino, playing bad stuff aswell timer things.

so thank trying me, wasn't thought problem was.

venix


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -