mirror of
https://github.com/vale981/tenx_usb_missile_launcher
synced 2025-03-04 09:21:38 -05:00
Check if USB device found and ignore commands if no device is found
This commit is contained in:
parent
c90262c715
commit
6bdadd8534
1 changed files with 6 additions and 0 deletions
|
@ -50,6 +50,8 @@ function TenxDriver() {
|
|||
TenxDriver.prototype.open = function() {
|
||||
// Find and Open
|
||||
this.launcher = usb.findByIds(0x1130,0x202);
|
||||
if (!this.launcher) return;
|
||||
|
||||
this.launcher.open();
|
||||
|
||||
// Detach Kernel Driver
|
||||
|
@ -63,6 +65,8 @@ TenxDriver.prototype.open = function() {
|
|||
}
|
||||
|
||||
TenxDriver.prototype.close = function() {
|
||||
if (!this.launcher) return;
|
||||
|
||||
if (!this.launcher.interfaces[0].isKernelDriverActive()) {
|
||||
this.launcher.interfaces[0].attachKernelDriver();
|
||||
}
|
||||
|
@ -157,6 +161,8 @@ TenxDriver.prototype.send_command = function(command) {
|
|||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
if (!this.launcher) return;
|
||||
|
||||
this.launcher.controlTransfer(0x21,0x09,0x02,0x01,header_1);
|
||||
this.launcher.controlTransfer(0x21,0x09,0x02,0x01,header_2);
|
||||
if (command == CMD.LEFT) this.launcher.controlTransfer(0x21,0x09,0x02,0x00, left_msg);
|
||||
|
|
Loading…
Add table
Reference in a new issue