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

@oi4/oi4-oec-dnp-encoding

v1.1.0-preview.13

Published

helper functions to encode & decode from/into dnp-encoding

Downloads

51

Readme

OI4 OEC dnp encoding helper

During the validation of the OEC Development Spec v1.0 a compatibility problem with DIN SPEC 91406 was identified. The dnp-encoding solves this incompatibility. This project capsules a helper function for decoding & encoding.

How to use

The library can be imported using the import-statement:

import { decode, encode } from 'oi4-oec-dnp-encoding';

When using this package within node-red, it can also be loaded, so it can be used in function nodes. Read more about this here.

When loaded, it can then be used easily inside your code like this:

encode('Edge Gateway >4GB'); //returns 'Edge,20Gateway,20,3E4GB'

Please be aware that all special characters stated below are encoded. It is not possible to directly put in whole oi4 identifiers, as the forward slashes will get encoded. You instead have to encode the single fields for themselves and put the oi4-identifier together afterwards.

dnp-encoding explained

Define the mask-sign

The set of allowed and prohibited characters is given by the DIN SPEC 91406.

To provide an urlEncode-like encoding, we have to define an algorithm which is easy to understand/implement and (for better acceptance) as similar as possible to the url encoding:

use one single character for masking (url: %)

This character is also used to mask itself (url: % => %25)

The mask character is followed by a unique definition to represent the masked character (url: %<HEXDIG><HEXDIG>)

The intersection of all reserved characters in DIN SPEC 91406 and masked characters in URL is:

/ ? # [ ] @ $ & + , ; =

The intersection of all reserved characters in DIN SPEC 91406 which are not masked in URL is:

! ' ( ) *

We define comma (,ascii = 44dec = 2Chex) is the global mask character for dnp-encoding.

:arrow_forward: An comma-encoding mechanism is used to represent a data octet in a component when that octet's corresponding character is outside the allowed set or is being used as a delimiter of, or within, the component. An comma-encoded octet is encoded as a character triplet, consisting of the apostrophe character "," followed by the two hexadecimal digits representing that octet's numeric value. For example, "'20" is the comma-encoding for the binary octet "00100000", which in US-ASCII corresponds to the space character (SP).

:arrow_forward: The provided dnp-encoding rules are common rules to replace urlEncoding functionality in context of DIN SPEC 91406. It shall not be restricted to the Alliance or even worst to the oi4Identifier.

What characters are masked within dnp-encoding?

| dnp-encoding of unreserved characters | | | ----------------------------------------- | ------------------- | | character | Encoded character | | a .. z, A .. Z | a .. z, A .. Z | | 0 .. 9 | 0 .. 9 | | – . _ ~ | – . _ ~ |

| dnp-encoding of reserved characters | | | --------------------------------------- | ----------------- | | character | Encoded triplet | | # | ,23 | | / | ,2F | | : | ,3A | | ? | ,3F | | @ | ,40 | | [ | ,5B | | ] | ,5D | | ! | ,21 | | $ | ,24 | | & | ,26 | | ‘ | ,27 | | ( | ,28 | | ) | ,29 | | * | ,2A | | + | ,2B | | , | ,2C | | ; | ,3B | | = | ,3D |

| dnp-encoding of prohibited printable characters | | | --------------------------------------------------- | ----------------- | | character | Encoded triplet | | SP | ,20 | | “ | ,22 | | % | ,25 | | < | ,3C | | > | ,3E | | \ | ,5C | | ^ | ,5E | | ` | ,60 | | { | ,7B | | | | ,7C | | } | ,7D |