Event Creation
To create a usbhotplug event, load the @brightsign/usbhotplug module using the require()
method:
Code Block | ||
---|---|---|
| ||
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
string: Indicates whether a USB device has been added or removed.[String] path
string: 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
Code Block | ||
---|---|---|
| ||
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); |