Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hubs/basehub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,18 @@ export class BaseHub extends EventEmitter {
const device = this._createDevice(deviceType, portId);
this._attachDevice(device);
return device;
} else {
}
else if (deviceType) {
if (this._attachedDevices[portId].type === deviceType) {
debug(`Device of ${deviceType} already attached to portId ${portId}, returning existing device`);
return this._attachedDevices[portId];
} else {
throw new Error(`Already a different type of device attached to portId ${portId}. Only use this method when you are certain what's attached.`);
}
}
else {
this._detachDevice(this._attachedDevices[portId]);
}
}


Expand Down