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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@oscura/iot-data-parse

v1.0.8

Published

设备数据解析

Readme

IOT-DATA-PARSE

npm-v1.0.8

CopyRight

@2019-2021 Oscura, All Rights Reserved

How to get

npm install @oscura/iot-data-parse

Description

Now, it is a demo.

Target

For general data analysis of Internet of Things.

Example

When the data uploaded by the device is as below.

{
	"status": true,
	"temperature": 126,
	"time": "1606630210",
}

The useful data is just like

true
126
1606630210

and "status","temperature","time" are useless and waste bandwidth. So we can convert the data as

true => 01
126 => 7E
1606630210 => 5F C3 3B 42

= 01 7E 5F C3 3B 42

At last, the data we need is "01 7E 5F C3 3B 42", when we get it, we can parse it out according to the rules.

Instance

/*********************************** EXAMPLE1 ***********************************/
import { DataUnit, HexParse, HexUtils } from '@oscura/iot-data-parse'

// data configuration that comes from xls file
const json = [
  { description: "运行状态", unit: "", name: "runStatus", byteOffset: 0, bitOffset: 0, count: 1, dataType: "bool", littleEndian: false },
  { description: "报警状态", unit: "", name: "alarmStatus", byteOffset: 0, bitOffset: 1, count: 1, dataType: "bool", littleEndian: false },
  { description: "自动状态", unit: "", name: "autoStatus", byteOffset: 0, bitOffset: 2, count: 1, dataType: "bool", littleEndian: false },
  { description: "生产数量", unit: "个", name: "productNumber", byteOffset: 1, bitOffset: 0, count: 1, dataType: "int", littleEndian: false },
  { description: "电流", unit: "A", name: "current", byteOffset: 5, bitOffset: 0, count: 1, dataType: "float", littleEndian: false },
  { description: "电压", unit: "V", name: "voltage", byteOffset: 9, bitOffset: 0, count: 1, dataType: "float", littleEndian: false },
  { description: "温度", unit: "℃", name: "temperature", byteOffset: 13, bitOffset: 0, count: 2, dataType: "double", littleEndian: false },
  { description: "频率", unit: "Hz", name: "frequency", byteOffset: 29, bitOffset: 0, count: 2, dataType: "float", littleEndian: false },
  { description: "用户名", unit: "", name: "username", byteOffset: 37, bitOffset: 0, count: 7, dataType: "string", littleEndian: false },
  { description: "报警内容", unit: "", name: "alarmContent", byteOffset: 44, bitOffset: 0, count: 20, dataType: "string", littleEndian: false }
]
const dataUnitArray = DataUnit.batchInit(json)

// io data source
const ioStr = '07000000994200999A425CF5C340429C28F5C28F5C40434147AE147AE141A1000042033E776A61636B736F6EE4BB8AE5A4A9E5A4A9E6B094E5A5BD'

// create hex parse (in Uint8Array)
const hexParse = new HexParse(HexUtils.toHexArray(ioStr))

// parse data
const newData = hexParse.parseDataArray(dataUnitArray)
console.log(DataUnit.toArrayString(newData))

// result
  运行状态: true
  报警状态: true
  自动状态: true
  生产数量: 153 个
  电流: 32.150001525878906 A
  电压: 55.2400016784668 V
  温度: 37.22 ℃, 38.51 ℃
  频率: 20.125 Hz, 32.81100082397461 Hz
  用户名: jackson
  报警内容: 今天天气好
/*********************************** EXAMPLE2 ***********************************/
import { DataUnit, HexParse, HexUtils } from '@oscura/iot-data-parse'

// data configuration that comes from xls file
const json = [
  { description: "运行状态", unit: "", name: "runStatus", byteOffset: 0, bitOffset: 0, count: 1, dataType: "bool", littleEndian: false },
  { description: "报警状态", unit: "", name: "alarmStatus", byteOffset: 0, bitOffset: 1, count: 1, dataType: "bool", littleEndian: false },
  { description: "自动状态", unit: "", name: "autoStatus", byteOffset: 0, bitOffset: 2, count: 1, dataType: "bool", littleEndian: false },
  { description: "生产数量", unit: "个", name: "productNumber", byteOffset: 1, bitOffset: 0, count: 1, dataType: "int", littleEndian: false },
  { description: "电流", unit: "A", name: "current", byteOffset: 5, bitOffset: 0, count: 1, dataType: "float", littleEndian: false },
  { description: "电压", unit: "V", name: "voltage", byteOffset: 9, bitOffset: 0, count: 1, dataType: "float", littleEndian: false },
  { description: "温度", unit: "℃", name: "temperature", byteOffset: 13, bitOffset: 0, count: 2, dataType: "double", littleEndian: false },
  { description: "频率", unit: "Hz", name: "frequency", byteOffset: 29, bitOffset: 0, count: 2, dataType: "float", littleEndian: false },
  { description: "用户名", unit: "", name: "username", byteOffset: 37, bitOffset: 0, count: 7, dataType: "string", littleEndian: false },
  { description: "报警内容", unit: "", name: "alarmContent", byteOffset: 44, bitOffset: 0, count: 20, dataType: "string", littleEndian: false }
]
const dataUnitArray = DataUnit.batchInit(json)

// create hex parse (in Uint8Array)
const hexParse = new HexParse()
hexParse.addUint8(0x07)
  // productNumber
  .addInt32(153)
  // current
  .addFloat32(32.15)
  // voltage
  .addFloat32(55.24)
  // temperature
  .addFloat64Array([37.22, 38.51])
  // frequency
  .addFloat32Array([20.125, 32.811])
  // username
  .addString("jackson")
  // alarmContent
  .addString("今天天气好")
  .assignRdDataViewByAddResult()

  // parse data
  const newData = hexParse.parseDataArray(dataUnitArray)
  console.log(DataUnit.toArrayString(newData))

// result
  运行状态: true
  报警状态: true
  自动状态: true
  生产数量: 153 个
  电流: 32.150001525878906 A
  电压: 55.2400016784668 V
  温度: 37.22 ℃, 38.51 ℃
  频率: 20.125 Hz, 32.81100082397461 Hz
  用户名: jackson
  报警内容: 今天天气好