diff --git a/tenx_driver.js b/tenx_driver.js index 3cf136a..3760bff 100644 --- a/tenx_driver.js +++ b/tenx_driver.js @@ -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);