Better error handling

This commit is contained in:
Nathan Kunicki 2018-08-01 14:25:40 +01:00
parent a509a9c0b2
commit 0d0d1a8d32
2 changed files with 4 additions and 2 deletions

View File

@ -114,6 +114,9 @@ export class BoostMoveHub extends LPF2Hub {
*/
public setMotorAngle (port: string, angle: number, speed: number = 100) {
const portObj = this._ports[port];
if (!(portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR || portObj.type === Consts.Devices.BOOST_MOVE_HUB_MOTOR)) {
throw new Error("Angle rotation is only available when using a Boost Interactive Motor or Boost Move Hub Motor");
}
return new Promise((resolve, reject) => {
portObj.busy = true;
const data = Buffer.from([0x0e, 0x00, 0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);

View File

@ -36,8 +36,7 @@ export class PUPHub extends LPF2Hub {
this.type = Consts.Hubs.POWERED_UP_HUB;
this._ports = {
"A": new Port("A", 0),
"B": new Port("B", 1),
"AB": new Port("AB", 57)
"B": new Port("B", 1)
};
debug("Discovered Powered Up Hub");
}