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

Method buildSerial

tools/xsbug/esptool.js:462–500  ·  view source on GitHub ↗
(baud)

Source from the content-addressed store, hash-verified

460 internal functions from here
461 */
462 async buildSerial(baud) {
463 if (this.#serial) {
464 this.#serial.close();
465 this.#serial = undefined;
466 }
467
468 return new Promise((resolve, reject) => {
469 this.#serial = new Serial({
470 ...this.#serialOptions,
471 baud,
472 device: this.#device,
473 onWritable(count) {
474 if (resolve)
475 resolve(true);
476 resolve = reject = undefined;
477
478 this.flash.#writeSpaceAvailable = count;
479 if (this.flash.#writable) {
480 this.flash.#writable(true);
481 this.flash.#writable = undefined;
482 }
483 },
484 onReadable() {
485 if (this.flash.#readable) {
486 this.flash.#readable(true);
487 this.flash.#readable = undefined;
488 }
489 },
490 onError() {
491 if (reject) {
492 reject(-1);
493 resolve = reject = undefined;
494 }
495 }
496 });
497 this.#serial.format = "buffer";
498 this.#serial.flash = this;
499 });
500 }
501 async downloadToMemory(data, offset, entry) {
502 const byteLength = data.byteLength;
503 const ESP_RAM_BLOCK = 6 * 1024;

Callers 3

resetMethod · 0.95
beginProgrammingMethod · 0.95
changeBaudMethod · 0.95

Calls 1

closeMethod · 0.65

Tested by

no test coverage detected