MCPcopy Create free account
hub / github.com/Marus/cortex-debug / SWOBinaryProcessor

Class SWOBinaryProcessor

src/frontend/swo/decoders/binary.ts:14–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14export class SWOBinaryProcessor implements SWORTTDecoder {
15 private output: vscode.OutputChannel;
16 public readonly format: string = 'binary';
17 private port: number;
18 private scale: number;
19 private encoding: string;
20 private useTerminal = true;
21 private ptyTerm: PtyTerminal = null;
22 private hrTimer: HrTimer = new HrTimer();
23 private logFd: number = -1;
24 private logfile: string;
25
26 constructor(config: SWOBinaryDecoderConfig) {
27 this.port = config.port;
28 this.scale = config.scale || 1;
29 this.encoding = (config.encoding || 'unsigned').replace('.', '_');
30 this.useTerminal = 'useTerminal' in config ? (config as any).useTerminal : true; // TODO: Remove
31
32 if (this.useTerminal) {
33 this.createVSCodeTerminal(config);
34 } else {
35 this.createVSCodeChannel(config);
36 }
37 if (config.logfile) {
38 this.logfile = config.logfile;
39 try {
40 this.logFd = fs.openSync(config.logfile, 'w');
41 }
42 catch (e) {
43 const msg = `Could not open file ${config.logfile} for writing. ${e.toString()}`;
44 vscode.window.showErrorMessage(msg);
45 }
46 }
47 }
48
49 private createVSCodeTerminal(config: SWOBinaryDecoderConfig) {
50 const options: IPtyTerminalOptions = {
51 name: this.createName(config),
52 prompt: '',
53 inputMode: TerminalInputMode.DISABLED
54 };
55 this.ptyTerm = PtyTerminal.findExisting(options.name);
56 if (this.ptyTerm) {
57 this.ptyTerm.clearTerminalBuffer();
58 } else {
59 this.ptyTerm = new PtyTerminal(options);
60 this.ptyTerm.terminal.show();
61 }
62 }
63
64 private createVSCodeChannel(config: SWOBinaryDecoderConfig) {
65 const chName = this.createName(config);
66 this.output = vscode.window.createOutputChannel(chName);
67 }
68
69 private createName(config: SWOBinaryDecoderConfig) {
70 return `SWO:${config.label || ''}[port:${this.port}, enc:${this.encoding}]`;
71 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected