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

@westh/umxxc-parser

v1.0.4

Published

Parse messages from UMxxC devices, e.g. the UM34C

Downloads

18

Readme

@westh/umxxc-parser

Parse messages from UMxxC devices, that is for instance the UM24C, UM25C, or the UM34C.

This parser is a derivative of these guys' work:

Whereas the above repos provide a complete 'suite' for getting and parsing the data from a UMxxC device this is merely the parser.

Installation

npm install @westh/umxxc-parser

Usage

const umxxcParser = require('@westh/umxxc-parser')

const messageToBeParsed = Buffer.from('...') // ...however you get your data from the UMxxC device
const parsedMessage = umxxcParser.parse(messageToBeParsed)

The parsedMessage will contain something that looks like the following:

{
  model: 'UM34C',
  voltage: 4.84, // [V] for UM25C this value will be decivolts
  current: 25, // [mA] for UM25C this value will be tenth-milliamps
  power: 121, // [mW]
  temperature: {
    celsius: 23,
    fahrenheit: 74
  },
  selectedGroup: 0,
  groups: [
    { accumulatedCurrent: 2, accumulatedPower: 10 }, // [mAh] [mWh]
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 },
    { accumulatedCurrent: 0, accumulatedPower: 0 }
  ],
  usbDataPlus: 0.04, // [V]
  usbDataMinus: 0.03, // [V]
  chargingMode: 7,
  accumulatedCurrent: 2, // [mAh]
  accumulatedPower: 10, // [mWh]
  thresholdCurrent: 0, // [A] and is the threshold at which accumulated... is captured
  accumulatedTime: 390, // [s]
  connected: 1,
  screenTimeout: 1,
  screenBrightness: 3,
  resistance: 193.6, // [Ω]
  screenMode: 2,
  unknown: <Buffer 15 d4>
}

Description

Basically the parser does what is described below to whatever Buffer you might throw at it. The calculations mentioned in the 'Meaning' column are taken care of, except for the edge cases for the UM25C which are not handled at the moment.

| Offset | Length | Type | Meaning | | ------ | ------ | ---------------- | ------------------------------------------------------------ | | 0 | 2 | model | Model ID | | 2 | 2 | measurement | Voltage - UM25C: millivolts (divide by 1000 to get V), UM24C/UM34C: centivolts (divide by 100 to get V) | | 4 | 2 | measurement | Amperage - UM25C tenth-milliamps (divide by 10000 to get A), UM24C/UM34C: milliamps (divide by 1000 to get A) | | 6 | 4 | measurement | Wattage (in mW, divide by 1000 to get W) | | 10 | 2 | measurement | Temperature (in Celsius) | | 12 | 2 | measurement | Temperature (in Fahrenheit) | | 14 | 2 | configuration | Currently selected data group, zero-indexed | | 16 | 80 | measurement | Array of 10 main capacity data groups (where the first one, group 0, is the ephemeral one) -- for each data group: 4 bytes mAh, 4 bytes mWh | | 96 | 2 | measurement | USB data line voltage (positive) in centivolts (divide by 100 to get V) | | 98 | 2 | measurement | USB data line voltage (negative) in centivolts (divide by 100 to get V) | | 100 | 2 | measurement | Charging mode index | | 102 | 4 | measurement | mAh from threshold-based recording | | 106 | 4 | measurement | mWh from threshold-based recording | | 110 | 2 | configuration | Currently configured threshold for recording (in centiamps, divide by 100 to get A) | | 112 | 4 | measurement | Duration of threshold recording, in cumulative seconds | | 116 | 2 | configuration | Threshold recording active (1 if recording, 0 if not) | | 118 | 2 | configuration | Current screen timeout setting, in minutes (0-9, 0 is no screen timeout) | | 120 | 2 | configuration | Current backlight setting (0-5, 0 is dim, 5 is full brightness) | | 122 | 4 | measurement | Resistance in deci-ohms (divide by 10 to get ohms) | | 126 | 2 | configuration | Current screen (zero-indexed, same order as on device) | | 128 | 1 | unknown | | | 129 | 1 | checksum/unknown | Checksum (UM34C) or unknown |

Source RDTech UM series by sigrok.

Testing

Running yarn test will first run yarn build and then test both the CommonJS and ESM version.

License

GPL-3.0