예제 #1
0
def discover_devices(ip_address = None):
  global device_list, the_first_device, mac_byte_map, ip_address_map

  # Reset all maps and lists
  device_list    = []
  ip_address_map = {}
  mac_byte_map   = {}

  # First create the initial device for discovery.

  # If our client wants to discover devices only on a specific IP address,
  # use that to create a new broadcast device.
  if (ip_address != None):
    specified_device = Device(
      ip_address       = ip_address,
      id               = CHAIN_INITIATOR_ID,
      frame_size_limit = MIN_FRAME_SIZE,
      client_socket    = client_socket)
    try:
      frame_list = specified_device.send_frame(DISCOVER_REQUEST);
    except RuntimeError, e:
      print(str(e))
      raise DeviceError("No reponse to discover frame.")
예제 #2
0
  # use that to create a new broadcast device.
  if (ip_address != None):
    specified_device = Device(
      ip_address       = ip_address,
      id               = CHAIN_INITIATOR_ID,
      frame_size_limit = MIN_FRAME_SIZE,
      client_socket    = client_socket)
    try:
      frame_list = specified_device.send_frame(DISCOVER_REQUEST);
    except RuntimeError, e:
      print(str(e))
      raise DeviceError("No reponse to discover frame.")
  else:
    # Otherwise use normal broadcast device
    try:
      frame_list = broadcast_device.send_frame(DISCOVER_REQUEST);
    except RuntimeError, e:
      print(str(e))
      raise DeviceError("No reponse to discover frame.")

  # Then parse the replies from the discovery request to find out the
  # IP addresses and MAC bytes of each device.
  for reply in frame_list:
    firmware_version = (reply.major_version, reply.minor_version)
    # If returned firmware version is not found, default is min frame size.
    frame_size_limit = MIN_FRAME_SIZE

    if (sequencer.firmware.FIRMWARE_PARAMS.has_key(firmware_version)):
      params = sequencer.firmware.FIRMWARE_PARAMS[firmware_version]
      frame_size_limit = params.frame_size_limit