-
Notifications
You must be signed in to change notification settings - Fork 2
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
WIP: Generalize ArgusProbe for Serial and OpenTestbed inputs #31
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments to know what to look for when proposing a patch.
Also, the title of the PR is not clear as the code patch has nothing to do with nodes on a single channel. The description of the PR should also be more verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks for all the changes. A couple of comments inline.
ArgusProbe_Beamlogic.py
Outdated
with self.dataLock: | ||
pleaseConnect = self.pleaseConnect | ||
|
||
if pleaseConnect: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pleaseConnect
always set to True
, why complicate the code. Please remove the if condition and unnecessary pleaseConnect
vars.
time.sleep(1) | ||
|
||
except Exception as err: | ||
logCrash(self.name, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you not destroy the thread in this case as well? i.e. call self.close()
.
ArgusProbe_Beamlogic.py
Outdated
|
||
#======================== public ========================================== | ||
|
||
def connectSerialPort(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this method used anywhere in the code. Please remove.
ArgusProbe_Beamlogic.py
Outdated
print "WARNING: Could not read from serial at \"{0}\".".format( | ||
self.serialport) | ||
print "Is device connected?" | ||
self.goOn = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose both #335 and #336 lines should be within the close()
method. Just invoke the method here instead of doing it manually for each case.
ArgusProbe_Beamlogic.py
Outdated
with self.dataLock: | ||
self.pleaseConnect = True | ||
|
||
def disconnectSerialPort(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge disconnectSerialPort
and close
methods, leaving only close
in use throughout the code.
ArgusProbe_Beamlogic.py
Outdated
self.send_to_parser([ord(c) for c in self.rxBuffer]) | ||
|
||
if self.rxBuffer[0] == 'P': #packet from sniffer SERFRAME_MOTE2PC_SNIFFED_PACKET 'P' | ||
self.rxBuffer = self.rxBuffer[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a short comment that you are discarding the type byte.
ArgusProbe_Beamlogic.py
Outdated
valid_frame = True | ||
|
||
except openhdlc.HdlcException as err: | ||
#log.warning('{}: invalid serial frame: {} {}'.format(self.name, format_string_buf(temp_buf), err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
ArgusProbe_Beamlogic.py
Outdated
|
||
except openhdlc.HdlcException as err: | ||
#log.warning('{}: invalid serial frame: {} {}'.format(self.name, format_string_buf(temp_buf), err)) | ||
print 'HDLC Exception' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is too generic of a print, add some context like in the commented warning log just above
Argus is limited to using only BeamLogic device as sniffer. To use nodes over serial or nodes in the testbed as sniffers, we need to extend the ArgusProbe script. In that way, we are not limited by the number of BeamLogic sniffers in the network.