Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connect): device connect/reset issue workarounds #15525

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,17 @@
} catch (error) {
if (
!this.inconsistent &&
(error.message === 'GetFeatures timeout' || error.message === 'Unknown message')
(error.message === 'GetFeatures timeout' ||
error.message === 'Unknown message' ||
error.message.startsWith('assertType: Response of unexpected type'))
) {
// handling corner-case T1B1 + bootloader < 1.4.0 (above)
// if GetFeatures fails try again
// this time add empty "fn" param to force Initialize message

// also a workaround for "Response of unexpected type" error, where a previous call was interrupted
this.inconsistent = true;
console.log('Retry GetFeatures due to incorrect message');

Check warning on line 568 in packages/connect/src/device/Device.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

Unexpected console statement

return this._runInner(() => Promise.resolve({}), options);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/connect/src/device/DeviceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
}

private onDeviceConnected(descriptor: Descriptor, transport: Transport) {
console.log('onDeviceConnected', descriptor);

Check warning on line 198 in packages/connect/src/device/DeviceList.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

Unexpected console statement
const { path } = descriptor;
const id = (this.deviceCounter++).toString(16).slice(-8);
const device = new Device({
Expand All @@ -206,9 +207,11 @@
this.devices[path] = device;

const penalty = this.authPenaltyManager.get();
console.log('before handshake');

Check warning on line 210 in packages/connect/src/device/DeviceList.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

Unexpected console statement
this.handshakeLock(async () => {
if (this.devices[path]) {
// device wasn't removed while waiting for lock
console.log('handshake');

Check warning on line 214 in packages/connect/src/device/DeviceList.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

Unexpected console statement
await device.handshake(penalty);
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/transport/src/api/usb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class UsbApi extends AbstractApi {
`usb: device.selectConfiguration error ${err}. device: ${this.formatDeviceForLog(device)}`,
);
}
try {
/*try {
// reset fails on ChromeOS and windows
this.logger?.debug('usb: device.reset');
await this.abortableMethod(() => device?.reset(), { signal });
Expand All @@ -329,7 +329,7 @@ export class UsbApi extends AbstractApi {
`usb: device.reset error ${err}. device: ${this.formatDeviceForLog(device)}`,
);
// empty
}
}*/
}
try {
const interfaceId = this.debugLink ? DEBUGLINK_INTERFACE_ID : INTERFACE_ID;
Expand Down Expand Up @@ -367,7 +367,7 @@ export class UsbApi extends AbstractApi {
this.logger?.debug(`usb: device.releaseInterface: ${interfaceId}`);
if (!this.debugLink) {
// NOTE: `device.reset()` interrupts transfers for all interfaces (debugLink and normal)
await device.reset();
// await device.reset();
}
await device.releaseInterface(interfaceId);
this.logger?.debug(
Expand Down
Loading