예제 #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
def setup_socket():
  # Bind to localhost
  client_socket.bind(('', CLIENT_PORT))
  client_socket.settimeout(RETRY_TIMEOUT)
#------------------------------------------------------------------------------
def teardown_socket():
  client_socket.close()

###############################################################################
# Module initialisatiovn code

import sequencer.firmware
from sequencer.ptp.devices import Device

broadcast_device = Device(
  id               = CHAIN_INITIATOR_ID,
  frame_size_limit = sequencer.firmware.current_params.frame_size_limit,
  client_socket    = client_socket)

device_list    = []
ip_address_map = {}
mac_byte_map   = {}

the_first_device = None
#this_device      = None

#------------------------------------------------------------------------------
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    = []