let inEndpoint = undefined;
let outEndpoint = undefined;
for (const { alternates } of device.configuration.interfaces) {
// Only support devices with out multiple alternate interfaces.
const alternate = alternates[0];
// Identify the interface implementing the USB CDC class.
const USB_CDC_CLASS = 10;
if (alternate.interfaceClass !== USB_CDC_CLASS) {
continue;
}
for (const endpoint of alternate.endpoints) {
// Identify the bulk transfer endpoints.
if (endpoint.type !== "bulk") {
continue;
}
if (endpoint.direction === "in") {
inEndpoint = endpoint.endpointNumber;
} else if (endpoint.direction === "out") {
outEndpoint = endpoint.endpointNumber;
}
}
}USBEndpoint / notebook
USBEndpoint
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.