[PATCH v4 17/29] wpaspy: add debug support for Ctrl UDP class

Janusz Dziedzic janusz.dziedzic at tieto.com
Fri Feb 26 01:38:32 PST 2016


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

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 wpaspy/wpaspy.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py
index 30bb652..76ac785 100644
--- a/wpaspy/wpaspy.py
+++ b/wpaspy/wpaspy.py
@@ -10,7 +10,9 @@ import os
 import stat
 import socket
 import select
+import logging
 
+logger = logging.getLogger()
 counter = 0
 
 class Ctrl:
@@ -54,7 +56,7 @@ class Ctrl:
                 self.cookie = reply
                 self.port = port
             except:
-                print "connect exception ", path, str(port)
+                logger.debug("connect exception " + str(path) + "/" + str(port))
                 if self.s != None:
                     self.s.close()
                 raise
@@ -79,12 +81,13 @@ class Ctrl:
 
     def request(self, cmd, timeout=10):
         if self.udp == True:
+            logger.debug(self.path + "/" + str(self.port) + " request: " + cmd)
             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 +118,6 @@ class Ctrl:
 
     def recv(self):
         res = self.s.recv(4096)
+        if self.udp == True:
+           logger.debug(self.path + "/" + str(self.port) + " recv: " + res)
         return res
-- 
1.9.1




More information about the Hostap mailing list