Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback not called #28

Closed
wackazong opened this issue Oct 9, 2016 · 1 comment
Closed

Callback not called #28

wackazong opened this issue Oct 9, 2016 · 1 comment

Comments

@wackazong
Copy link

@wackazong wackazong commented Oct 9, 2016

Python newbie question: I try to wrap the xBee connection into a class. But the callback gets never called if it is a class method. If it is not in a class it works fine. What can I do?

class Receiver:
def enter(self):
self.serial_port = serial.Serial('/dev/ttyUSB0', 115200)
self.xbee = ZigBee(self.serial_port, escaped=True, callback=self.handlePackets)
Logger.info('Receiver: enter')
return self
def exit(self ,type, value, traceback):
Logger.info('Receiver: exit')
self.serial_port.close()
def handlePackets(data):
Logger.info('Receiver: packet incoming')

@hansmosh
Copy link
Contributor

@hansmosh hansmosh commented Oct 10, 2016

It's hard to say what is wrong since your comment doesn't have any indentation, but try adding self to def handlePackets(self, data):.

Questions like this are better asked on a site like stackoverflow.com. GitHub Issues are generally meant for reporting issues with the code in this repository, not with individual issues with using it.

@hansmosh hansmosh closed this Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants