serial-standardization

2.0.0 • Public • Published

serial-standardization

Description

Serial port standardization utility. This package helps connect to a serial port, automatically detects and initializes the correct COM port.

Installation

npm install serial-standardization

Steps to Use in Your Project

Step 1. Import the SerialManager Class

Import the SerialManager class in your JavaScript file:

import SerialManager from "serial-standardization/dist/utils/serialManager.js";

Ensure Proper Module Type

Ensure you have "type": "module" in your package.json if you are using import statements to support ES module imports:

{
  "type": "module",
  "dependencies": {
    "serial-standardization": "^1.0.0"
  }
}

Instantiate the SerialManager Class

Create an instance of the SerialManager class:

const serialManager = new SerialManager();

Check for Active Port

Use the isActivePortAvailable method to check if an active port is available:

serialManager.isActivePortAvailable();

Handle Device Ready Event

Use the on method to listen for the deviceReady event. Once the device is ready, you can send data:

serialManager.on("deviceReady", () => {
  console.log("Device is ready. Now sending initial data...");
  serialManager.sendData("S");
});

Example Usage

import SerialManager from "serial-standardization/dist/utils/serialManager.js";

const serialManager = new SerialManager();

// Check if an active port is available
serialManager.isActivePortAvailable();

// Listen for the device ready event
serialManager.on("deviceReady", () => {
  console.log("Device is ready. Now sending initial data...");
  serialManager.sendData("S");
});

Readme

Keywords

none

Package Sidebar

Install

npm i serial-standardization

Weekly Downloads

5

Version

2.0.0

License

ISC

Unpacked Size

14.6 kB

Total Files

12

Last publish

Collaborators

  • yamunarathod