Lantronix Discovery Protocol
This example is a Python application in source code that shows how to search and find Lantronix Devices. It is run from the command line.
The Lantronix Discovery protocol uses a UDP broadcast out port 77FE on a network interface. All Lantronix devices on that subnet will respond with 30 bytes of data.
Their MAC address is included in the 30 bytes
Prerequisites
1) import socket, time and sys
2) While this code could be incorporated and run from a PremierWave device, it was written and tested on a PC. (win 7)
Sample Code
# utility to search and find Lantronix devices # import socket #for sockets import sys #for exit import time j = 0 k = 0 host = '' port = 30718 DATA = [] LTRXnode = [] packet = [] print "searching for Lantronix devices...\n" # create datagram udp socket try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) s.bind((host,port)) s.settimeout(2) except socket.error: print 'Failed to create socket' sys.exit() #Set the search string msg = chr(0)+chr(0)+chr(0)+chr(0xf6) try: s.sendto(msg, ('<broadcast>', port)) except socket.error, msg: print 'Error Code : ' + str(msg[0]) + ' Message ' + msg[1] sys.exit() #time.sleep(4) t1 = 0 t0 = time.clock() # set start time while (t1<3): # loop for no more than 3 seconds try: # receive data from client (data, addr) d, address = s.recvfrom(128) packet = "".join("%02x" % ord(c) for c in d) if packet[6:8] == "f7": LTRXnode.append(address[0]) DATA.append(packet[48:60]) j += 1 except Exception: #print "no rcv" s.close() time.sleep(1) t1 = time.clock() - t0 # find difference in time #print t1 # print out results of search print "%d devices found " % j for x in LTRXnode: print "%s %s " % (x,DATA[k]) k +=1 print "\n" raw_input('Press the Enter Key to Exit\n')