summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Foster <nick@ettus.com>2011-06-15 18:45:44 -0700
committerNick Foster <nick@ettus.com>2011-06-15 18:45:44 -0700
commitc713f8a4727b140f8524dd38b81ab2a9077859ff (patch)
tree471a4062bb8cf38fb6581f850b27375c8648da25
parent46fe7d86ee0425d9dc16f5a40c4d4bc061c43505 (diff)
downloaduhd-c713f8a4727b140f8524dd38b81ab2a9077859ff.tar.gz
uhd-c713f8a4727b140f8524dd38b81ab2a9077859ff.tar.bz2
uhd-c713f8a4727b140f8524dd38b81ab2a9077859ff.zip
fw_updater: device enumeration support, not integrated into main app yet
-rwxr-xr-xhost/utils/usrp_n2xx_net_burner.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/host/utils/usrp_n2xx_net_burner.py b/host/utils/usrp_n2xx_net_burner.py
index 65ddfa4e7..878b8b28c 100755
--- a/host/utils/usrp_n2xx_net_burner.py
+++ b/host/utils/usrp_n2xx_net_burner.py
@@ -191,6 +191,28 @@ def win_get_interfaces():
if not adNode:
break
+def enumerate_devices():
+ ifaces = get_interfaces()
+ devices = []
+ for bcast_addr in ifaces:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
+ sock.settimeout(UDP_TIMEOUT)
+ print "Sending bcast pkt to %s" % bcast_addr
+ out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_OHAI_LOL, 0, 0, 0)
+ sock.sendto(out_pkt, (bcast_addr, UDP_FW_UPDATE_PORT))
+ still_goin = True
+ while(still_goin):
+ try:
+ pkt = sock.recv(UDP_MAX_XFER_BYTES)
+ (proto_ver, pktid, rxseq, ip_addr) = unpack_flash_ip_fmt(pkt)
+ if(pktid == update_id_t.USRP2_FW_UPDATE_ID_OHAI_OMG):
+ devices.append(socket.inet_ntoa(struct.pack("<L", socket.ntohl(ip_addr))))
+ except socket.timeout:
+ still_goin = False
+
+ return devices
+
########################################################################
# Burner class, holds a socket and send/recv routines
########################################################################
@@ -200,7 +222,6 @@ class burner_socket(object):
self._sock.settimeout(UDP_TIMEOUT)
self._sock.connect((addr, UDP_FW_UPDATE_PORT))
self.set_callbacks(lambda *a: None, lambda *a: None)
- get_interfaces()
self.init_update() #check that the device is there
self.get_hw_rev()