Files
homeclaw/web-ui/vendor/rp2040js/gdb/gdb-utils.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

37 lines
1.2 KiB
JavaScript

export function encodeHexByte(value) {
return (value >> 4).toString(16) + (value & 0xf).toString(16);
}
export function encodeHexBuf(buf) {
return Array.from(buf).map(encodeHexByte).join('');
}
export function encodeHexUint32BE(value) {
return encodeHexBuf(new Uint8Array([(value >> 24) & 0xff, (value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
}
export function encodeHexUint32(value) {
const buf = new Uint32Array([value]);
return encodeHexBuf(new Uint8Array(buf.buffer));
}
export function decodeHexBuf(encoded) {
const result = new Uint8Array(encoded.length / 2);
for (let i = 0; i < result.length; i++) {
result[i] = parseInt(encoded.substr(i * 2, 2), 16);
}
return result;
}
export function decodeHexUint32Array(encoded) {
return new Uint32Array(decodeHexBuf(encoded).buffer);
}
export function decodeHexUint32(encoded) {
return decodeHexUint32Array(encoded)[0];
}
export function gdbChecksum(text) {
const value = text
.split('')
.map((c) => c.charCodeAt(0))
.reduce((a, b) => a + b, 0) & 0xff;
return encodeHexByte(value);
}
export function gdbMessage(value) {
return `$${value}#${gdbChecksum(value)}`;
}