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

Fix timeouts to aid exit from sniffer mode #144

Merged
merged 2 commits into from Sep 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions killerbee/dev_sl_beehive.py
Expand Up @@ -76,10 +76,10 @@ def get_dev_info(self):
'''
return [self.dev, "BeeHive SG", ""]

def __send_cmd(self, cmdstr, arg=None, confirm= True, send_return= True, extra_delay= 0):
def __send_cmd(self, cmdstr, arg=None, confirm= True, send_return= True, extra_delay= 0, initial_read= 3):
# read any cruft
#time.sleep(0.1)
for x in range(3):
for x in range(initial_read):
self.handle.readline()

# some commands require us to be in idle, so do it always
Expand Down Expand Up @@ -176,10 +176,11 @@ def sniffer_off(self):
close().
@rtype: None
'''
self.__send_cmd("rx", "0", confirm= False)
for x in range(5):
# reset timeout as sniffer has made it long
self.handle.timeout= 0.2
self.__send_cmd("rx", "0", confirm= False, initial_read= 0)
for x in range(3):
d= self.handle.readline().strip()
#print 'got', d
if "Rx:Disabled" in d:
self.mode = MODE_NONE
self.__stream_open = False
Expand Down Expand Up @@ -264,7 +265,7 @@ def inject(self, packet, channel=None, count=1, delay=0, page=0):

# KillerBee expects the driver to implement this function
#TODO I suspect that if you don't call this often enough while getting frames, the serial buffer may overflow.
def pnext(self, timeout=100):
def pnext(self, timeout=1):
'''
Returns packet data as a string, else None.
@type timeout: Integer
Expand Down