Eric Searle
unread,Mar 4, 2011, 12:57:40 PM3/4/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xbee-api
I am using an Arduino hooked to a coordinator Xbee and a remote Xbee
with two pushbuttons and LED's on DO 0 and DO 3. Xbees are Series 2
Arduino software is 2001.
I have used the short form of ZBxRequest (3 params) and the long form
(6 params). In both cases when I monitor the output from Arduino sent
to the Coordinator Xbee, the output is corrupted. Two consecutive
bytes (0x7D and 0x33) are appearing in the output, usually overwriting
the high order bytes of the 64-bit Destination address at position 7
and 8 of the output. The position of the two bytes varies with the
payload size and sometimes is appears twice at positions 3 and 4 and
pos. 8 and 9. With a payload size of 1, the whole of the output stream
is overwritten.
Instead of creating an object for the 64-bit address in the
ZBTxRequest call itried using a local variable of type uint64_t but
the compiler did not allow this. The values of unint_32
DestinationDevAddrMS, uint_32 DestinationDevAddrLS and uint_16
NetworkAddress were obtained from a previous ZBRxIoSampleResponse call
and subsequent xbee.readPacket(); and
xbee.getResponse().getZBRxIoSampleResponse(ioSample); This wors fine.
I have tried moving both the ZBTxRequest and XBeeAddress64
instantiations positions around in my code. Same results.
I have included my code for review if you need it. all the nss.println
displays show the correct values. Please note, I have commented out a
lo of alternatives that I have tried to solve the problem
#define OutputPayloadLength 12
#define MaxOutputPayloadLength 32
uint32_t Work32;
// uint64_t Work64; // Alternate storage for 64-bit DeviceAddress.
Cannot be used in ZBTxRequest even though needs uint64_t
// 64-bit Address for ZBTxRequest to use (cannot use a uint64_t
directly)
// XBeeAddress64 XBee_Addr64 = XBeeAddress64(DestinationDevAddrMS,
DestinationDevAddrLS);
void SendXbee()
{
nss.println("Addresses Prior to Send");
// Work32 = XBee_Addr64.getMsb();
// nss.print("Work:");
// nss.println(Work32,HEX);
// Work64 = Work32;
// Work64 = Work64 << 32;
// Work32 = XBee_Addr64.getLsb();
// Work64 = Work64 + Work32;
// nss.print("Work32 My 32-bit Address:");
// nss.println(Work32,HEX);
nss.print("DestAddr MS (32-bits) ");
nss.println(DestinationDevAddrMS,HEX);
nss.print("DestAddr LS (32-bits) ");
nss.println(DestinationDevAddrLS,HEX);
nss.print("NetworkAddr: ");
nss.println(NetworkAddress,HEX);
// Data Frame to be sent to Xbee
// uint8_t XBee_Data[OutputPayloadLength]; // Was char type but
uint8_t works fine
uint8_t XBee_Data[MaxOutputPayloadLength];
int OutputLength = OutputPayloadLength; // need a variable for
ZBTxRequest
// FrameID is incremented from 1 each time
int MyFrameID = xbee.getNextFrameId(); // For ZBTxRequest. Did this
to see if it affects the overwrite of packet (bug)
nss.print("FrameID:");
nss.println(MyFrameID,HEX);
// Not sure whether byte [0] is needed
// I believe the FrameType defines the following as an AT Command.
// XBee_Data[0] = 0x08; // API Frame Type AT_COMMAND_REQUEST 0x08
// XBee_Data[1] = 0x4D; // Frame ID, any non-zero Value
XBee_Data[0] = 0x44; // First Byte "D" AT Command (D0) Digital
Output Zero?
XBee_Data[1] = 0x30; // Second Byte "0" AT Command (D0)
XBee_Data[2] = 0x05; // Pin High Output
XBee_Data[3] = 0x44; // First Byte "D" AT Command (D1) Digital
Output 2?
XBee_Data[4] = 0x31; // Second Byte "0" AT Command (D1)
XBee_Data[5] = 0x00; // Pin High Output
XBee_Data[6] = 0x44; // First Byte "D" AT Command (D2) Digital
Output 2?
XBee_Data[7] = 0x32; // Second Byte "0" AT Command (D2)
XBee_Data[8] = 0x00; // Pin High Output
XBee_Data[9] = 0x44; // First Byte "D" AT Command (D3) Digital
Output 2?
XBee_Data[10] = 0x33; // Second Byte "0" AT Command (D3)
XBee_Data[11] = 0x00; // Pin High Output
// 64-bit Address for ZBTxRequest to use (cannot use a uint64_t
directly)
XBeeAddress64 XBee_Addr64 = XBeeAddress64(DestinationDevAddrMS,
DestinationDevAddrLS);
nss.print("XBee_Addr64: from Object:");
nss.print("MS: ");
nss.println(XBee_Addr64.getMsb(),HEX);
nss.print("MS: ");
nss.println(XBee_Addr64.getLsb(),HEX);
nss.print
// MS is getting corrupted on output to the Coordinator
// Ensure that MS is correct prior ro
XBee_Addr64.setMsb(DestinationDevAddrMS);
XBee_Addr64.setMsb(DestinationDevAddrMS);
nss.print("XBee_Addr64: from Object Again:");
nss.print("MS: ");
nss.println(XBee_Addr64.getMsb(),HEX);
nss.print("MS: ");
nss.println(XBee_Addr64.getLsb(),HEX);
// XBee_Addr64.setMsb() = DestinationDevAddrMS; //Does not
Compile
// Create a TX Request
// ZBTxRequest zbTx = ZBTxRequest(XBee_Addr64, XBee_Data,
sizeof(XBee_Data));
// ZBTxRequest zbTx = ZBTxRequest(XBee_Addr64, XBee_Data, 0);
// ZBTxRequest zbTx = ZBTxRequest(XBee_Addr64, NetworkAddress,
ZB_BROADCAST_RADIUS_MAX_HOPS, ZB_TX_UNICAST, (uint8_t*) XBee_Data,
OutputLength, xbee.getNextFrameId());
ZBTxRequest zbTx = ZBTxRequest(XBee_Addr64, NetworkAddress,
ZB_BROADCAST_RADIUS_MAX_HOPS, ZB_TX_UNICAST, (uint8_t*) XBee_Data,
OutputLength,MyFrameID);
// ZBTxRequest zbTx = ZBTxRequest(DestinationDevAddr,
NetworkAddress, ZB_BROADCAST_RADIUS_MAX_HOPS, ZB_TX_UNICAST,
(uint8_t*) XBee_Data, OutputLength,MyFrameID);
// ZBTxRequest zbTx = ZBTxRequest(DestinationDevAddr,
NetworkAddress, ZB_BROADCAST_RADIUS_MAX_HOPS, ZB_TX_UNICAST,
(uint8_t*) XBee_Data, OutputLength,MyFrameID);
//Send the packet
nss.print("PacketToSend: ");
for(int i=0; i<= OutputPayloadLength-1; i++)
{
nss.print(XBee_Data[i],HEX);
// nss.print(0xFF,HEX); // Separator
}
nss.println();
xbee.send(zbTx);
GetResponse();
}