Class: Usbmux::USBMux

Inherits:
Object
  • Object
show all
Defined in:
lib/usbmux/usbmux.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket_path = nil) ⇒ USBMux

Returns a new instance of USBMux.



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/usbmux/usbmux.rb', line 305

def initialize(socket_path = nil)
  if socket_path.nil?
    if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
      socket_path = '/var/run/usbmuxd'
    else
      socket_path = '/var/run/usbmuxd'
    end
  end
  @socket_path = socket_path
  begin
    @protocol_class = BinaryProtocol
    @version = 0
    @listener = MuxConnection.new(@socket_path, @protocol_class)
    @listener.listen()
  rescue MuxVersionError
    @protocol_class = PlistProtocol
    @version = 1
    @listener = MuxConnection.new(@socket_path, @protocol_class)
    @listener.listen()
  end
  @devices = @listener.devices
end

Instance Attribute Details

#devicesObject

Returns the value of attribute devices.



304
305
306
# File 'lib/usbmux/usbmux.rb', line 304

def devices
  @devices
end

#listenerObject

Returns the value of attribute listener.



304
305
306
# File 'lib/usbmux/usbmux.rb', line 304

def listener
  @listener
end

#protocol_classObject

Returns the value of attribute protocol_class.



304
305
306
# File 'lib/usbmux/usbmux.rb', line 304

def protocol_class
  @protocol_class
end

#socket_pathObject

Returns the value of attribute socket_path.



304
305
306
# File 'lib/usbmux/usbmux.rb', line 304

def socket_path
  @socket_path
end

#versionObject

Returns the value of attribute version.



304
305
306
# File 'lib/usbmux/usbmux.rb', line 304

def version
  @version
end

Instance Method Details

#connect(device, port) ⇒ Object



332
333
334
335
# File 'lib/usbmux/usbmux.rb', line 332

def connect(device, port)
  connection = MuxConnection.new(@socket_path, @protocol_class)
  connection.connect(device, port)
end

#process(timeout = nil) ⇒ Object



328
329
330
# File 'lib/usbmux/usbmux.rb', line 328

def process(timeout = nil)
  @listener.process(timeout)
end