[PATCH v2 16/22] wpaspy: add debug support for Ctrl class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add debug support for Ctrl class. This is
useful for debuging purpose.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx>
---
 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


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux