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

nec-display-protocol

v2.2.0

Published

NEC display encoder/decoder based on NEC LCD control protocol

Downloads

14

Readme

Introduction

nec-display-protocol is Node module to encode and decode NEC displays commands using NEC control protocol for LCD monitors.

Main features

  • no external dependencies
  • regardless of connection type (tcp/serial)
  • just encode and decode functions
  • no flow control
  • helper constans for connection
  • easy extensible parameters/commands file (data.js)

Usage

const NECD = require('nec-display-protocol');
const net = require('net');
let socket = net.createConnection(7142, '192.168.4.212', () => {
  let enc = NECD.encode('power on', 1);
  console.log('>', enc)
  socket.write(enc.encoded);
})
socket.on('data', data => {
  console.log('<', NECD.decode(data));
})

/* expected output
> {
  command: 'power on',
  id: 1,
  duration: 10000,
  encodedStr: '\x010A0A0C\x02C203D60001\x03s\r',
  encoded: <Buffer 01 30 41 30 41 30 43 02 43 32 30 33 44 36 30 30 30 31 03 73 0d>
}
< {
  raw: <Buffer 01 30 30 41 42 30 45 02 30 30 43 32 30 33 44 36 30 30 30 31 03 76 0d>,
  rawStr: '\x0100AB0E\x0200C203D60001\x03v\r',
  id: 1,
  extra: {
    msgType: 'B',
    message: '00C203D60001',
    strValue: '0001',
    numValue: 1
  },
  req: 'power',
  value: 'on'
}
*/

Parameters and commands

NEC control protocol defines set of parameters and commands.
Parameters are used to set or get states of LCD using single value. Parameter syntax is parameter_name[?][ value]. Sample parameters are: input, backlight, volume, spectraView. Parameters are defined in parameters array in data.js file. You can also find accepted values here.
Commands can be more complex and can accept multiple paremeters or return more complex structures. Command syntax is command_name[ val1[,val2[...]]]. Sample commands: power, model, diagnosis. Supported commands are defined in commands array in data.js

encode(cmd, id) function

Encodes human friendly command to bytes according to NEC LCD control protocol.

  • cmd <string> - required. The cmd is a human friendly command which corresponds to NEC parameter or command name. For parameters you must provide a value or '?' directly after the name. Examples: 'power on', 'backlight 30', 'input hdmi', 'input?', 'sn'
  • id <number|string> - optional. If not specified, default id 1 will be used. You can also use wildcard id 'ALL'. This affects monitor regardless of its id. It is usefull when you don't know monitor id or you want to control all displays connected with RS232 chain using single command.

Return value is cmdObj <Object>. The most important property is encoded which contains encoded command as Buffer. This buffer must be send to LCD. Other properties are helper ones.

decode(data) function

Decodes response from NEC LCD into JS object.

  • data <Buffer|string> - data read from TCP socket or serial port

Returns response <Object|Null> - an response object containing properties:

  • raw <Buffer> - same as data if it contains valid protocol response
  • rawStr <string> - raw as string
  • id <number> - monitor id
  • req <string> - a parameter or command name (request)
  • value <string|number> - decoded value. Return type depends on command
  • extra <Object> - some pre-decoded values, specific for NEC control protocol.

The function does not control completeness of data. It verifies if data is a valid protocol response and tries to decode it. If data is not a valid response, a null is returned.