From b0ccec821d047b2245f4c1a7c41bbdf87c5814c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Thu, 23 Oct 2025 11:55:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=E4=BF=AE=E5=A4=8D=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=89=88=E4=B8=8Busb=20mini=E5=9C=A8=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E7=94=B1=E4=BA=8E=E6=B3=A2=E7=89=B9=E7=8E=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=B7=A5=E4=BD=9C=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/web/usb-mini.js | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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); }