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

Method softwareEvent

src/frontend/swo/decoders/console.ts:111–154  ·  view source on GitHub ↗
(packet: Packet)

Source from the content-addressed store, hash-verified

109 }
110
111 public softwareEvent(packet: Packet) {
112 if (packet.port !== this.port) { return; }
113 const letters = packet.data.toString(this.encoding);
114
115 if (this.logFd >= 0) {
116 try {
117 fs.writeSync(this.logFd, letters);
118 }
119 catch (e) {
120 const msg = `Could not write to file ${this.logfile} for writing. ${e.toString()}`;
121 vscode.window.showErrorMessage(msg);
122 try { fs.closeSync(this.logFd); } catch {}
123 this.logFd = -1;
124 }
125 }
126
127 for (const letter of letters) {
128 if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; }
129
130 if (letter === '\n') {
131 this.pushOutput('\n');
132 this.position = 0;
133 continue;
134 }
135
136 if (this.position === 0) {
137 this.pushOutput(this.createDateHeaderUs());
138 }
139
140 this.pushOutput(letter);
141 this.position += 1;
142
143 if (this.timestamp && (this.position > 0)) {
144 if (this.timeout) {
145 clearTimeout(this.timeout);
146 }
147 this.timeout = setTimeout(() => {
148 this.pushOutput('\n');
149 this.position = 0;
150 this.timeout = null;
151 }, 5000);
152 }
153 }
154 }
155
156 public hardwareEvent(event: Packet) {}
157 public synchronized() {}

Callers

nothing calls this directly

Calls 3

pushOutputMethod · 0.95
createDateHeaderUsMethod · 0.95
toStringMethod · 0.80

Tested by

no test coverage detected