diff --git a/common/modules/mixly-modules/web/usb-mini.js b/common/modules/mixly-modules/web/usb-mini.js index a1ff2be5..ef3ee28e 100644 --- a/common/modules/mixly-modules/web/usb-mini.js +++ b/common/modules/mixly-modules/web/usb-mini.js @@ -212,9 +212,10 @@ class USBMini extends Serial { this.#endpointOut_ = endpoint.endpointNumber; } } + await this.#device_.claimInterface(0); await this.#device_.claimInterface(this.#interfaceNumber_); - await this.setBaudRate(baud); super.open(baud); + await this.setBaudRate(baud); this.onOpen(); this.#addEventsListener_(); } @@ -237,6 +238,28 @@ class USBMini extends Serial { if (!this.isOpened() || this.getRawBaudRate() === baud) { return; } + const dwDTERate = new Uint8Array([ + baud & 0xFF, + (baud >> 8) & 0xFF, + (baud >> 16) & 0xFF, + (baud >> 24) & 0xFF + ]); + const bCharFormat = 0x00; + const bParityType = 0x00; + const bDataBits = 0x08; + const lineCoding = new Uint8Array([ + ...dwDTERate, + bCharFormat, + bParityType, + bDataBits + ]); + await this.#device_.controlTransferOut({ + requestType: 'class', + recipient: 'interface', + request: 0x20, + value: 0x0000, + index: 0 + }, lineCoding); await super.setBaudRate(baud); }