How to use @serialport/parser-readline - 1 common examples

To help you get started, we’ve selected a few @serialport/parser-readline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jos-b / language-circuitpython / lib / board-view.js View on Github external
v.vendorId = "";
                }

                return v;
            });

            let chosenBoard = ports.find(e => vendorIDs.indexOf(e.vendorId.toLowerCase()) != -1);

            if (!chosenBoard) {
                atom.notifications.addError("Could not find a valid device");
                return;
            }
            // Create a stream to the serial
            this.sp = new SerialPort(chosenBoard.comName);

            this.parser = new Readline();
            this.sp.pipe(this.parser);

            this.parser.on("data", (data) => {
                this.sendToPlotter(data);
                let shouldScroll = false;

                // If 10 or less pixels from bottom then scroll with  new output
                if (this.logs.scrollHeight - this.logs.clientHeight <= this.logs.scrollTop + 10) {
                    shouldScroll = true;
                }

                this.logs.textContent += data + "\n";

                if (this.logs.textContent.split("\n").length > atom.config.get("language-circuitpython.maxLines")) {
                    this.logs.textContent = this.logs.textContent.split("\n").slice(atom.config.get("language-circuitpython.maxLines") - 40).join("\n");
                }

@serialport/parser-readline

See our api docs See our api docs https://serialport.io/docs/api-parser-readline

MIT
Latest version published 1 year ago

Package Health Score

84 / 100
Full package analysis

Popular @serialport/parser-readline functions

Similar packages