Files
homeclaw/web-ui/vendor/rp2040js/usb/setup.js
T
kim 209f3a3aef v3.0.6: RP2040 에뮬레이터 개선 — USB CDC, vendor화, 부팅 감지
- USB CDC 경로 복원: #define Serial Serial1 우회 제거
- rp2040js/avr8js/codemirror/xterm/monaco-editor vendor화
- /vendor 정적 라우팅 추가 (Express 5 catch-all 우회)
- 부팅 완료 타임아웃 감지 (Serial 출력 없어도 8초 후 RAF 전환)
- 리셋 시 Simulator 재생성으로 주변 장치 상태 초기화
- 시리얼 패널의 내부 메시지를 console.log로 이동
2026-06-19 15:49:36 +09:00

47 lines
1.6 KiB
JavaScript

import { DataDirection, SetupRecipient, SetupRequest, SetupType, } from './interfaces.js';
export function createSetupPacket(params) {
const setupPacket = new Uint8Array(8);
setupPacket[0] = (params.dataDirection << 7) | (params.type << 5) | params.recipient;
setupPacket[1] = params.bRequest;
setupPacket[2] = params.wValue & 0xff;
setupPacket[3] = (params.wValue >> 8) & 0xff;
setupPacket[4] = params.wIndex & 0xff;
setupPacket[5] = (params.wIndex >> 8) & 0xff;
setupPacket[6] = params.wLength & 0xff;
setupPacket[7] = (params.wLength >> 8) & 0xff;
return setupPacket;
}
export function setDeviceAddressPacket(address) {
return createSetupPacket({
dataDirection: DataDirection.HostToDevice,
type: SetupType.Standard,
recipient: SetupRecipient.Device,
bRequest: SetupRequest.SetAddress,
wValue: address,
wIndex: 0,
wLength: 0,
});
}
export function getDescriptorPacket(type, length, index = 0) {
return createSetupPacket({
dataDirection: DataDirection.DeviceToHost,
type: SetupType.Standard,
recipient: SetupRecipient.Device,
bRequest: SetupRequest.GetDescriptor,
wValue: type << 8,
wIndex: index,
wLength: length,
});
}
export function setDeviceConfigurationPacket(configurationNumber) {
return createSetupPacket({
dataDirection: DataDirection.HostToDevice,
type: SetupType.Standard,
recipient: SetupRecipient.Device,
bRequest: SetupRequest.SetDeviceConfiguration,
wValue: configurationNumber,
wIndex: 0,
wLength: 0,
});
}