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

Method writeBinary

src/frontend/rtt_terminal.ts:267–292  ·  view source on GitHub ↗
(input: string | Buffer)

Source from the content-addressed store, hash-verified

265 }
266
267 public writeBinary(input: string | Buffer) {
268 const data: Buffer = Buffer.from(input);
269 const timestamp = this.hrTimer.createDateTimestamp();
270 for (const chr of data) {
271 this.buffer[this.bytesRead] = chr;
272 this.bytesRead = this.bytesRead + 1;
273 if (this.bytesRead === this.bytesNeeded) {
274 let chars = '';
275 for (const byte of this.buffer) {
276 if (byte <= 32 || (byte >= 127 && byte <= 159)) {
277 chars += '.';
278 } else {
279 chars += String.fromCharCode(byte);
280 }
281 }
282 const blah = this.buffer.toString();
283 const hexvalue = padLeft(this.buffer.toString('hex'), 8, '0');
284 const decodedValue = parseEncoded(this.buffer, this.encoding);
285 const decodedStr = padLeft(`${decodedValue}`, 12);
286 const scaledValue = padLeft(`${decodedValue * this.scale}`, 12);
287
288 this.ptyTerm.write(`${timestamp} ${chars} 0x${hexvalue} - ${decodedStr} - ${scaledValue}\n`);
289 this.bytesRead = 0;
290 }
291 }
292 }
293}

Callers 1

onDataMethod · 0.80

Calls 5

padLeftFunction · 0.85
createDateTimestampMethod · 0.80
toStringMethod · 0.80
parseEncodedFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected