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

54 lines
1.8 KiB
JavaScript

import { STOP_REPLY_SIGINT, STOP_REPLY_TRAP } from './gdb-server.js';
import { gdbChecksum, gdbMessage } from './gdb-utils.js';
export class GDBConnection {
constructor(server, onResponse) {
this.server = server;
this.onResponse = onResponse;
this.target = this.server.target;
this.buf = '';
server.addConnection(this);
onResponse('+');
}
feedData(data) {
const { onResponse } = this;
if (data.charCodeAt(0) === 3) {
this.server.info('BREAK');
this.target.stop();
onResponse(gdbMessage(STOP_REPLY_SIGINT));
data = data.slice(1);
}
this.buf += data;
for (;;) {
const dolla = this.buf.indexOf('$');
const hash = this.buf.indexOf('#', dolla + 1);
if (dolla < 0 || hash < 0 || hash + 2 > this.buf.length) {
return;
}
const cmd = this.buf.substring(dolla + 1, hash);
const cksum = this.buf.substr(hash + 1, 2);
this.buf = this.buf.substr(hash + 2);
if (gdbChecksum(cmd) !== cksum) {
this.server.warn(`GDB checksum error in message: ${cmd}`);
onResponse('-');
}
else {
onResponse('+');
this.server.debug(`>${cmd}`);
const response = this.server.processGDBMessage(cmd);
if (response) {
this.server.debug(`<${response}`);
onResponse(response);
}
}
}
}
onBreakpoint() {
try {
this.onResponse(gdbMessage(STOP_REPLY_TRAP));
}
catch (e) {
this.server.removeConnection(this);
}
}
}