MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / unescapeSLIP

Method unescapeSLIP

tools/xsbug/esptool.js:584–609  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

582 return received;
583 }
584 unescapeSLIP(input) {
585 let length = 0;
586
587 for (let offset = 0; offset < input.length; offset++) {
588 let byte = input[offset];
589
590 if (0xdb === byte) {
591 if (0xdd === input[offset + 1]) {
592 byte = 0xdb;
593 offset += 1;
594 }
595 else
596 if (0xdc === input[offset + 1]) {
597 byte = 0xc0;
598 offset += 1;
599 }
600 else
601 throw new Error("unexpected SLIP escape");
602 }
603 input[length++] = byte;
604 }
605 if (length !== input.byteLength)
606 input = input.slice(0, length);
607
608 return input;
609 }
610 parseReply(input, id) {
611 if (!input)
612 throw new Error("no reply to command " + id);

Callers 2

readPartMethod · 0.95
parseReplyMethod · 0.95

Calls 1

sliceMethod · 0.65

Tested by

no test coverage detected