DUE and Xbee [SOLVED]

Hi everyone,

I 'm working on a Xbee project and would like to make my own little library (for specific needs) and encounter a problem while using Serial1 where are my Xbee serial module.
I recently decided to switch from AT mode to API on Xbee and it doesn’t work since:

When I want to get some parameter from my Xbee module, the Serial1.write seems so freeze my whole program.

	uint8_t* ZigbeeStack::getPanID(){
		uint8_t command_id[] = { 0x7E, 0x00, 0x04, 0x08, 0x01, 0x49, 0x44, 0x69 };
		uint8_t panID[8] = { 0 };

		Serial1.write(command_buffer_id, sizeof(command_buffer_id));      // I tried with a loop and it block with the first byte

		//delay(2);	// Waiting for response

		uint8_t response_buffer[Serial1.available()];

		for(uint8_t i = 0; Serial1.available(); i++)
			response_buffer[i] = Serial1.read();

		for(uint8_t i = 0; i < 8; i++)			// Response payload frame start from position 8 to 15 (8 bytes).
			panID[i] = response_buffer[i+7];

		return panID;

I specify the wiring worked fine on AT mode and modules are correctly configured.

Any idea?

Thanks in advance!

Any idea?

Sure thing. Ask about your snippets at http://snippets-r-us.com. Most helpful folks, there.

I'm not sure to understand, should I give more precisions?

Edit: sorry I believed it was a signature and not an answer.
I'll have look :slight_smile:

Eh, I might specify I've call the begin function before calling the others Serial's methods ( Serial1.begin(115200)).
In fact it's in my default class construtor :confused:
I haven't my full class code on me now until tomorrow but by then if you have new suggestions.. thank you :smiley:

In fact it's in my default class construtor :confused:

Bad idea. You are assuming that the hardware is ready. But, your constructor is most likely called before init() is called to get the hardware ready. So, it's like you didn't call begin() at all.

Since you can't take a hint, even when applied with a clue by four, POST ALL OF YOUR CODE!

Thank you, indeed it was the right point.
I was creating the object globally at startup (out of the setup function)... a good thing to know..
Thank you again, next time I will post all my code first :smiley: