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

nmeaflow

v0.1.1

Published

NMEAFlow is a basic CLI tool designed to emulate a sensor server, which can broadcast data from one or more simulated sensors at the same time. The data is read from text files and replayed continuously, at desired intervals.

Downloads

5

Readme

NMEAFlow: Sensor Server Simulator

NMEAFlow is a basic CLI tool designed to emulate a sensor server, which can broadcast data from one or more simulated sensors at the same time. The data is read from text files and replayed continuously, at desired intervals.

Use NMEAFlow for developing and testing applications that consume real-time sensor data, without the need for actual sensors.

Features

  • Replay any data from text files
  • Flexible port configuration
  • Extensive logging and error handling
  • Dynamic interval settings
  • Pre-loaded with sample NMEA strings for various marine sensors
  • Types included for TypeScript support
  • Programmatic API for further integration

Requirements

  • Node.js >= v14.x
  • NPM >= v6.x

Installation

npm install nmeaflow

Command Line Usage

Options

| Option | Description | Default Value | |-------------------------|-----------------------------------------------------------------------------------------------|---------------------| | --port-start| Starting port for the simulator | 4001 | | --port-end | Ending port for the simulator | 4006 | | -c, --config | Config file with list of files to replay | | | --id | Id for an individual simulator instance | | | -p, --port | Single port to run an individual simulator instance | | | -f, --filename| Filename for an individual simulator instance | | | -i, --interval| Broadcasting interval for an individual simulator instance in milliseconds | 10000 | | -a, --address | Address to listen on | localhost | | -h, --host | Listen to all available IPs | | | --log-level | Specify log level | debug |

Logging

You can set the log level either by running using the --log-level option or by setting the LOG_LEVEL environment variable.

The log levels are as follows:

  • error
  • warn
  • info
  • verbose
  • debug
  • silly
  • none

Config File

The config file is a JavaScript file that exports an array of objects. Each object contains the file, id, and interval keys.

Example:

module.exports = [
  { file: 'gps.txt', id: 'GPS', interval: 10000 },
  { file: 'trawl.txt', id: 'TRAWL_SONAR', interval: 15000 },
  { file: 'depthsounder.txt', id: 'DEPTH_SOUNDER', interval: 15000 },
  { file: 'wind.txt', id: 'WIND', interval: 10000 },
];

The interval can be either a number (in milliseconds) or a function. The function takes the id as argument and should return a number representing the interval in milliseconds.

Running as an individual instance

To run the simulator as an individual instance you need to specify the individual parameters, as follows:

nmeaflow -p 4000 -f sample_data.txt -id Sensor01 --interval 10000

This will run the simulator with id Sensor01 on port 4000, reading data from the file sample_data.txt, and broadcasting the data every 10,000 milliseconds (or 10 seconds).

Programmatic API

NMEAFlow comes with type definitions, enabling easy integration into TypeScript projects. Here's an example:

import { NMEAFlow } from 'nmeaflow';

const options = {
  address: 'localhost',
  port: 4001,
  filename: 'custom_data.txt',
  interval: 2000,
};

const simulator = new NMEAFlow(options);
simulator.start()
  .then(() => {
    console.log('Simulator started');
  })
  .catch((err) => {
    console.error('Failed to start simulator', err);
  });

License

MIT