ElieNamias / xbee-arduino

Automatically exported from code.google.com/p/xbee-arduino
GNU General Public License v3.0
0 stars 0 forks source link

declare an xBee object in another class #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have used for a long time xBee libraries without problems. I always declared 
the xBee object in the main pde files. Now I need to declare the xBee as 
private or public object of another class. The program complie well but only 
the firs loop ends fine. On the second arduino crashes and restarts on this 
line:

"if (xbee.readPacket(500))"

any idea?
thanks

Original issue reported on code.google.com by paolo.ca...@gmail.com on 5 Aug 2011 at 9:45

GoogleCodeExporter commented 9 years ago
I suppose the problem in calling xbee-arduino library in another library 
concern this code in xBee.cpp

for (int i = 0; i < MAX_FRAME_DATA_SIZE; i++) {
        getFrameData()[i] = 0;

Removing it arduino does not reset but packets are not well receved from the 
Pan Coordinator

Original comment by paolo.ca...@gmail.com on 17 Nov 2011 at 9:00

GoogleCodeExporter commented 9 years ago
I have solved my problem but without understanding really the reason. If I do 
not declare the xbee object inside my class but I use inheritance everthing 
works fine. What I have changed is this:
from:
Code:

class nodoGenerico
{
public:
xBee myXBee;    

to:
Code:

class nodoGenerico: public XBee
{
private:

....
....

Considering that there were no problem whit privlegies (public, private etc...) 
do you have any idea on why the same library does not work declaring an object 
of that class but works using inheritance? thanks!

Original comment by paolo.ca...@gmail.com on 13 Dec 2011 at 3:39

GoogleCodeExporter commented 9 years ago
I'm having this issue too. Can't do a workaround like the OP did though since 
I'm already inheriting from another class.

A quick dig into the code brought me headaches; setFrameData() gets its 
argument from getFrameData() but within both functions, they are reading and 
setting the same variable. Probably something to do with passing the frame 
pointer between different classes, but it is really confusing.

Original comment by xieli...@gmail.com on 29 Jan 2012 at 1:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm having the same issue as well. I can't seem to get the posted workaround 
working though.

I'd like to see this issue have a higher priority, as the library as it is now 
is completely unusable for my current project.

I was wondering if this issue has anything to do with the HardwareSerial not 
being properly opened or something (because it is used from inside the library)?

Original comment by r.b.j.ja...@gmail.com on 27 Apr 2012 at 12:03

GoogleCodeExporter commented 9 years ago
I suggest you check this ticket. It worked for me: 
http://code.google.com/p/xbee-arduino/issues/detail?id=23

Original comment by jposun...@gmail.com on 9 Jul 2012 at 6:55

GoogleCodeExporter commented 9 years ago

Original comment by andrew.rapp@gmail.com on 2 Feb 2014 at 6:40