[PATCH v2 16/22] wpaspy: add debug support for Ctrl class
Janusz Dziedzic
janusz.dziedzic at tieto.com
Sun Feb 7 05:07:49 PST 2016
Add debug support for Ctrl class. This is
useful for debuging purpose.
Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
wpaspy/wpaspy.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py
index 30bb652..b6a3c6f 100644
--- a/wpaspy/wpaspy.py
+++ b/wpaspy/wpaspy.py
@@ -12,10 +12,12 @@ import socket
import select
counter = 0
+debug = False
class Ctrl:
def __init__(self, path, port=9877):
global counter
+ global debug
self.started = False
self.attached = False
self.path = path
@@ -78,13 +80,18 @@ class Ctrl:
self.started = False
def request(self, cmd, timeout=10):
+ if debug is True:
+ if self.udp == True:
+ print self.path + "/" + str(self.port) + " request: " + cmd
+ else:
+ print self.path + "request: " + cmd
if self.udp == True:
self.s.sendto(self.cookie + cmd, self.sockaddr)
else:
self.s.send(cmd)
[r, w, e] = select.select([self.s], [], [], timeout)
if r:
- return self.s.recv(4096)
+ return self.recv()
raise Exception("Timeout on waiting response")
def attach(self):
@@ -115,4 +122,9 @@ class Ctrl:
def recv(self):
res = self.s.recv(4096)
+ if debug is True:
+ if self.udp == True:
+ print self.path + "/" + str(self.port) + " recv: " + res
+ else:
+ print self.path + " recv: " + res
return res
--
1.9.1
More information about the Hostap
mailing list