Object Creation
Code Block | ||
---|---|---|
| ||
var UsbPowerControlClass = require("@brightsign/usbpowercontrol");
var usbPowerControl = new UsbPowerControlClass(); |
usbpowercontrol
Use this interface to control power on USB ports.
powerCyclePort()
Code Block | ||
---|---|---|
| ||
Promise<void> powerCyclePort(String friendly_name) |
Allows you to power cycle the VBus on a device that may be stuck on a specific port.
friendly_name
string: The friendly name of the specific USB port. Please refer to the table below to map friendly names to supported platforms. For example, callusbPowerControl.powerCyclePort("USB:A")
to turn the USB power on port 1 of AU325 off and on again.
Platform | USB | Friendly Name |
---|---|---|
AU325 | 1, 2, 3, 4, 5, 6 | "USB:A", "USB:B", "USB:C", "USB:D", "USB:E", "USB:F" |
AU335 | Type-C | "USB:A" |
XD1034, XT1144 | Type-C, Type-A | "USB:A", "USB:B" |
powerCycleAllPorts()
Code Block | ||
---|---|---|
| ||
Promise<void> powerCycleAllPorts() |
Call usbPowerControl.powerCycleAllPorts()
to turn the power off and on for all USB ports and power cycle all plugged in devices.
portPowerOn()
Code Block | ||
---|---|---|
| ||
Promise<void> portPowerOn(String friendly_name) |
Allows you to power on the specified port.
friendly_name
string: The friendly name of the specific USB port. Please refer to the table above to map friendly names on supported platforms.
portPowerOff()
Code Block | ||
---|---|---|
| ||
Promise<void> portPowerOff(String friendly_name) |
Allows you to power off the specified port.
friendly_name
string: The friendly name of the specific USB port. Please refer to the table above to map friendly names on supported platforms.
Example
This example power cycles USB:A and USB:B ports:
Code Block | ||
---|---|---|
| ||
const UsbPowerControlClass = require("@brightsign/usbpowercontrol");
const usbPowerControl = new UsbPowerControlClass();
let promise = usbPowerControl.portPowerOff("USB:A");
promise.then(function(){
console.log("A is turned off");
return usbPowerControl.portPowerOff("USB:B");
}).then(function(){
console.log("B is turned off");
return usbPowerControl.portPowerOn("USB:A");
}).then(function(){
console.log("A is back on");
return usbPowerControl.portPowerOn("USB:B");
}).then(function(){
console.log("B is back on" );
}).catch(function(err){
console.log("error");
}); |