I'm trying to send a RF data payload of 73 bytes between 2 Zigbee-Pro modules in AT Command Mode.
The two modules are equal configured:
ROUTER AT. Fmw 22A7 ID: 5555 DH: 0 DL: FFFF BD: 5
And they shows, NP: 54 (this is 84 bytes in decimal). So, it must be read perfectly, but instead of this the data frame is wrapped, and this makes me have errors at reading time of serial buffer.
How can I configure my modules to avoid this behaviour??
Where is the error (receiver or transmitter side)??
Do you have a clue what Serial.flush() does? Why are you using it all over the place? What version of the IDE are you using?
Do you have any idea how long an XBee stays in command mode? You are waiting for one second after getting a reply. Is that longer or shorter than the XBee stays in command mode in the absence of a command?
Are you using the serial port to talk to the XBee or to talk to the PC? It looks to me like the answer is both, which is the wrong answer.
I'm trying to answer your questions at the best way.
Serial.flush(). It's used to clean the Serial port. It's possible that I used it more than neccesary, but sometimes I get some garbage in Serial port (it could be for using '\t' or '\n').
IDE 1.0 Linux.
How long...? I don't have too much knowledge reading AT commands from MCU yet. So I can't read AT commands faster if I don't wait one second (also I have troubles with, if I set CTS FLOW CONTROL bit (DIO7). [I'll try to avoid Serial.flush in these functions also the 'delay', could you give any tip about?].
Serial port. It's used to talk with XBee but at my test, it's the way I can assure the communication is working fine.
For receiving data: an Arduino Mega with a Xbee Shield and the code post below (it switches on/off a led for a time). It shows Serial port data by Cutecom app.
** For transmitting data: an explorer usb and the X-CTU app, so I can send the message I want.
Serial.flush(). It's used to clean the Serial port. It's possible that I used it more than neccesary, but sometimes I get some garbage in Serial port (it could be for using '\t' or '\n').
IDE 1.0 Linux.
Starting with 1.0, Serial.flush() blocks until the outgoing serial buffer is empty. How is that necessary for you?
Prior to 1.0, Serial.flush() did NOT "clean the Serial port". It discard random amounts of unread data in the incoming serial buffer that had not been read yet. It did nothing about data that had not yet arrived in the buffer. Throwing away random amounts of unread data was not useful then.
What it does now is even less useful. So, get rid of ALL the Serial.flush() calls.
How long...? I don't have too much knowledge reading AT commands from MCU yet.
That has nothing to do with how long the XBee takes to enter command mode, or how long it remains in command mode if it does not receive a command.
You need to look at digi.com's site to find that answer.
AT Command Mode
To Enter AT Command Mode:
Default AT Command Mode Sequence (for transition to Command Mode):
• No characters sent for one second [GT (Guard Times) parameter = 0x3E8]
• Input three plus characters (“+++”) within one second [CC (Command Sequence Character)
parameter = 0x2B.]
• No characters sent for one second [GT (Guard Times) parameter = 0x3E8]
So, waiting 1.2 seconds after putting the XBee in command mode is going to find it back in relay mode.