Compare commits
2 commits
ac42d9463e
...
5e768c19d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e768c19d0 | ||
|
|
3b0652ccce |
3 changed files with 9 additions and 7 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@adafruit/circuitpython-repl-js",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@adafruit/circuitpython-repl-js",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.3",
|
||||
"license": "MIT",
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"publishConfig": {
|
||||
"registry": "https://npm.pkg.github.com"
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.3",
|
||||
"description": "A JavaScript Module to help with interfacing to the REPL on CircuitPython Devices over serial",
|
||||
"main": "repl.js",
|
||||
"dependencies": {
|
||||
|
|
|
|||
10
repl.js
10
repl.js
|
|
@ -83,7 +83,7 @@ export class REPL {
|
|||
}, this.promptTimeout
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("Awaiting prompt timed out.");
|
||||
console.error("Awaiting prompt timed out.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -102,15 +102,17 @@ export class REPL {
|
|||
}
|
||||
|
||||
async onSerialReceive(e) {
|
||||
// Prepend a partial token if it exists
|
||||
// We don't want to modify e.data, so we make a copy of it
|
||||
let data = e.data;
|
||||
|
||||
// Prepend a partial token if it exists
|
||||
if (this._partialToken) {
|
||||
e.data = this._partialToken + e.data;
|
||||
data = this._partialToken + data;
|
||||
this._partialToken = null;
|
||||
}
|
||||
|
||||
// Tokenize the larger string and send to the parent
|
||||
let tokens = this._tokenize(e.data);
|
||||
let tokens = this._tokenize(data);
|
||||
|
||||
// Remove any partial tokens and store for the next serial data receive
|
||||
if (tokens.length && this._hasPartialToken(tokens.slice(-1))) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue