mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
dist: pep8 ng_sniffer.py
This commit is contained in:
parent
67197854df
commit
c10ea983f9
14
dist/tools/ng_sniffer/ng_sniffer.py
vendored
14
dist/tools/ng_sniffer/ng_sniffer.py
vendored
@ -30,7 +30,8 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
'''
|
||||
|
||||
import sys, re
|
||||
import sys
|
||||
import re
|
||||
from time import sleep, time
|
||||
from struct import pack
|
||||
from serial import Serial
|
||||
@ -42,7 +43,8 @@ MINOR = 4
|
||||
ZONE = 0
|
||||
SIG = 0
|
||||
SNAPLEN = 0xffff
|
||||
NETWORK = 230 # 802.15.4 no FCS
|
||||
NETWORK = 230 # 802.15.4 no FCS
|
||||
|
||||
|
||||
def configure_interface(port, channel):
|
||||
line = ""
|
||||
@ -54,7 +56,7 @@ def configure_interface(port, channel):
|
||||
print >> sys.stderr, "Application has no network interface defined"
|
||||
sys.exit(2)
|
||||
match = re.search(r'^Iface +(\d+)', line)
|
||||
if match != None:
|
||||
if match is not None:
|
||||
iface = int(match.group(1))
|
||||
break
|
||||
|
||||
@ -66,6 +68,7 @@ def configure_interface(port, channel):
|
||||
port.write('ifconfig %d raw\n' % iface)
|
||||
port.write('ifconfig %d promisc\n' % iface)
|
||||
|
||||
|
||||
def generate_pcap(port, out):
|
||||
# count incoming packets
|
||||
count = 0
|
||||
@ -96,9 +99,11 @@ def generate_pcap(port, out):
|
||||
out.write(pack('<B', int(byte.group(1), 16)))
|
||||
out.flush()
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 4:
|
||||
print >> sys.stderr, "Usage: %s tty baudrate channel [outfile]" % (argv[0])
|
||||
print >> sys.stderr, "Usage: %s tty baudrate channel [outfile]" % \
|
||||
(argv[0])
|
||||
print >> sys.stderr, " channel = 11-26"
|
||||
sys.exit(2)
|
||||
|
||||
@ -127,5 +132,6 @@ def main(argv):
|
||||
print ""
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
|
Loading…
Reference in New Issue
Block a user