aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/discovery.py
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-04-19 18:45:29 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:45 -0800
commit285f14392b4494501b462796743e67cc54c4cca8 (patch)
treee680bf89d33f73b58f515bb9558a4c3db6ec07f5 /mpm/python/usrp_mpm/discovery.py
parentb05f72f339dcb02cc6efc6f2bc7d92c4476b5cc9 (diff)
downloaduhd-285f14392b4494501b462796743e67cc54c4cca8.tar.gz
uhd-285f14392b4494501b462796743e67cc54c4cca8.tar.bz2
uhd-285f14392b4494501b462796743e67cc54c4cca8.zip
mpm: Moved over to new logging infrastructure
Also currently hardcodes some settings.
Diffstat (limited to 'mpm/python/usrp_mpm/discovery.py')
-rw-r--r--mpm/python/usrp_mpm/discovery.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/mpm/python/usrp_mpm/discovery.py b/mpm/python/usrp_mpm/discovery.py
index 595368c76..a8044d49e 100644
--- a/mpm/python/usrp_mpm/discovery.py
+++ b/mpm/python/usrp_mpm/discovery.py
@@ -19,19 +19,16 @@ Code to run the discovery port
"""
from __future__ import print_function
-from logging import getLogger
from multiprocessing import Process
-from six import iteritems
import socket
+from six import iteritems
from usrp_mpm.types import MPM_DISCOVERY_PORT
-
-LOG = getLogger(__name__)
+from .mpmlog import get_main_logger
RESPONSE_PREAMBLE = "USRP-MPM"
RESPONSE_SEP = ";"
RESPONSE_CLAIMED_KEY = "claimed"
-
def spawn_discovery_process(device_info, shared_state):
"""
Returns a process that contains the device discovery.
@@ -59,6 +56,7 @@ def _discovery_process(device_info, state):
["{k}={v}".format(k=RESPONSE_CLAIMED_KEY, v=state.claim_status.value)] + \
["{k}={v}".format(k="token", v=state.claim_token.value)]
)
+ log = get_main_logger().getChild('discovery')
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((("0.0.0.0", MPM_DISCOVERY_PORT)))
@@ -68,19 +66,19 @@ def _discovery_process(device_info, state):
# try:
while True:
data, sender = sock.recvfrom(8000)
- LOG.info("Got poked by: %s", sender[0])
+ log.info("Got poked by: %s", sender[0])
if data.strip("\0") == "MPM-DISC":
- LOG.info("Sending discovery response to %s port: %d",
+ log.info("Sending discovery response to %s port: %d",
sender[0], sender[1])
send_data = create_response_string()
send_sock.sendto(send_data, sender)
elif data.strip("\0").startswith("MPM-ECHO"):
- LOG.info("Received echo request")
+ log.info("Received echo request from {sender}".format(sender=sender[0]))
send_data = data
send_sock.sendto(send_data, sender)
# except Exception as err:
- # LOG.info("Error: %s", err)
- # LOG.info("Error type: %s", type(err))
+ # log.info("Error: %s", err)
+ # log.info("Error type: %s", type(err))
# sock.close()
# send_sock.close()