Serial port
Serial port: an extended interface using serial communication.
Serial port communication: a communication method in which the serial port sends and receives bytes bit by bit.
The Serialport class is used to handle serial port communication. It creates a new serial port object using the serial port path, baud rate, callback function, and simulator. It is used to simulate serial port communication data.
Installation
npm install @cutos/drivers
Introduce dependencies
const {SerialPort} = require("@cutos/drivers");
Serialport
constructor(path, baudRate, callback = null, simulator = null)
- path: port path
- baudRate: baud rate
- callback: callback function
- simulator: simulator instance
Example:
The driver creates a new serialport instance and returns the port result, which is often used in device connection related methods.
let serialport = new SerialPort('/dev/ttySS3', 19200, error => {
if (error) {
console.log(error)
}
}, simulator)
Methods from the base class SerialPortStream
See @serialport/stream
- write
- on('data')