Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Current »

The usbhotplug object can be used to generate events when USB devices are added or removed. 

usbhotplug IDL

interface usbhotplugevent {
    attribute String action;    // "add", "remove"
    attribute String path;      // platform specific device path
};

callback UsbHotplugEventCallback = void (usbhotplugevent event);

interface UsbHotplug {
    void addEventListener(String type, UsbHotplugEventCallback callback);
    void removeEventListener(String type, UsbHotplugEventCallback callback);
};

ON THIS PAGE



Event Creation

To create a usbhotplug event, load the @brightsign/usbhotplug module using the require() method:

let usbhotplugClass = require("@brightsign/usbhotplug");
let usbhotplug = new usbhotplugClass();

UsbHotPlug 

Use this interface to configure a usbhotplug event.

usbhotplugevent: This event is raised when the hotplug status changes. Use the addEventListener() method to listen for this event, or the removeEventListener() method to remove an event listener.

usbhotplugevent Properties 

  • [String] action: Indicates whether a USB device has been added or removed.

  • [String] path: The path is an arbitrary string which varies between models and should not be parsed.  It may be useful for diagnostics. The path will be the same for add and remove events for a particular USB device. Use @brightsign/deviceinfo getUsbBusTopology() to examine attached devices. These events are hints that the topology has changed.

Example

let usbhotplugClass = require("@brightsign/usbhotplug");
let usbhotplug = new usbhotplugClass();

function onusbhotplugevent(event) {
  if (event.action == 'add') {
     console.log('New device at' + event.path)
  } else if (event.action == 'remove')
  {
     console.log('Device removed from' + event.path)
  }
}

usbhotplug.addEventListener("usbhotplugevent", onusbhotplugevent);




  • No labels