npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serial-nci-scale

v1.0.0

Published

Serial interface for Salter Brecknell PS-USB scales using NCI protocol and SCP-12 layout

Downloads

23

Readme

Serial NCI Scale

An API to query a Serial Scale which supports the NCI protocal (SCP-12, NCI 3825, NCI 3835). Tested against the Salter Brecknell PS-USB scale. Depends on the Web Serial API.

Getting Started

Page Hosting the library must be served over HTTPS. Demo is available at https://chris-rudmin.github.io/serial-nci-scale/

Installation

npm install serial-nci-scale --save

Usage

import SerialNCIScale from 'serial-nci-scale';

const scale = new SerialNCIScale();
const { weight, units, status } = await scale.getWeight();

Constructor

  • const scale = new SerialNCIScale( [config] ) - Create a new instance with optional device filter array or port config object

Config Object

  • config.filters - Optional - Array of filters to use when initializing the port. Defaults to [].
  • config.portConfig - Optional - Object containing serial configuration to use for initializing port. Defaults to 7E1 byte format.

Instance Methods

  • scale.getWeight() - Returns a promise which resolves with scale weight data. Required to be called from user action
  • scale.getStatus() - Returns a promise which resolves with scale status data. Required to be called from user action
  • scale.zero() - Returns a promise which resolves when the scale is zeroed. Required to be called from user action
  • scale.startPolling([pollInterval]) - Starts polling the scale for weight data. Default polling interval is 500 ms Required to be called from user action
  • scale.stopPolling() - Stops polling the scale
  • scale.disconnect() - Returns a promise which resolves once disconnected. Closes the read and write streams and frees the serial port

Static Attributes

  • SerialNCIScale.isWebSerialSupported - true if Web Serial API exists in your browser
  • SerialNCIScale.supportedScaleFilters - Array of devices which are known to be supported

Events

The serial-nci-scale instance is an EventTarget and can be listened to for custom events. Scale data is contained the in the detail property.

  • weight - Dispatched for every weight read
  • status - Dispatched for every status read
  • settled - Dispatched when the scale is no longer in motion and if the weight is different than the last settled weight
scale.addEventListener('settled', ({ detail }) => foo(detail.status));
scale.startPolling();

Supported Browsers

Currently only Chrome 89+ and Edge 89+ support the Web Serial API. Earlier versions of Chrome and Edge can use the API if it is enabled in chrome://flags