(input)
| 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); |
no test coverage detected