I found a line of code that causes a reset problem, (doh it doesn't always reset when executing this line, it doesn't reset when I comment it). The place were it resets is random, so it's not like it reset when this line is executed, all I know is that it doesn't reset with these lines gone (very strange).
Reset causing code:
Serial.write(nul);
the null is declared by:
char nul = 0x00;
Is there anyone who knows how to replace this code, so it still writes the same thing?
Tried already:
Serial.print(0x00); //write(int) ambigious
Serial.print(0x00,HEX); //wrong values for 0
Serial.print(0,DEC); //wrong values for 0
Serial.write(null); // Not declared
The null is actually used as part of an adress. I'm using XBee modules. These require a frame adress for communication. I put my code in the attachement. The following part is used as adress:
It looks to me like you are using the serial port to talk to the XBee and the PC, and expecting the XBee to know what you are trying to get it to broadcast vs. what it should ignore.
Life will get a lot easier when you stop doing that.
When the debugging is finished, I was planning to remove all the extra serial writes, but I don't think that this is what causes the reset or is it? do you know another way for sending en HEX value of 00 in my adress?
MrSt0p:
When the debugging is finished, I was planning to remove all the extra serial writes, but I don't think that this is what causes the reset or is it? do you know another way for sending en HEX value of 00 in my adress?
I'd be more worried by the fact you apparently have the Arduino serial pins driven by the USB serial driver and the UART and the XBee. Each serial connection can (should) only have TWO end points. Setting up a three-way connection is asking for trouble, because you will have different output drivers fighting against each other. Perhaps one will tend to win and it will appear to work, but it's a fundamentally bad idea IMO. If your Arduino needs to talk to the PC and to an XBee module then you need a separate serial connection for each one.
The fact you're then sending binary data to the PC and debug messages to the XBee just adds insult to injury.
I tried it, but I don't understand how it works, and I thought that if I only had to send some small values, it would be eassier like this. Never worked with libraries :s is it hard to implement? how long would it approcimatly take for someone with let's say 0 knowledge to get it to work?
Ow and also, he starts working with processing, I don't get how to go to processing. I read the book from Faludi, Robert: Buidling Wireless Sensor Networks. He also works with XBee's, and I completely understand everything until processing comes in. :s