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

samsung-mdc-protocol

v2.0.0

Published

Samsung display encoder/decoder based on multiple display control (MDC) protocol

Readme

Introduction

samsung-mdc-protocol is Node module to encode or decode Samsung displays commands using multiple display control protocol (MDC).

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 command file (data.js)

Usage

const MDC = require('samsung-mdc-protocol');
const net = require('net');
let socket = net.createConnection(7142, '192.168.4.43', () => {
  let enc = MDC.encode('status?', 3);
  console.log('>', enc)
  if(enc.encoded)
    socket.write(enc.encoded);
})
socket.on('data', data => console.log('<', MDC.decode(data)))

/* expected output
> {
  command: 'status?',
  id: 3,
  duration: 1000,
  encodedStr: 'ª\x00\x03\x00\x03',
  encoded: <Buffer aa 00 03 00 03>
}
< {
  raw: <Buffer aa ff 03 09 41 00 00 28 00 25 01 00 00 9a>,
  rawStr: '*\x7F\x03\tA\x00\x00(\x00%\x01\x00\x00\x1A',
  id: 3,
  extra: {
    ack: 'A',
    rcmd: 0,
    data: [0, 40, 0, 37, 1,  0, 0]
  },
  status: 'OK',
  req: 'status',
  value: {
    power: 'off',
    volume: 40,
    mute: 'off',
    input: 'DP',
    aspect: 1,
    NTimeNF: 0,
    FTimeNF: 0
  }
}
*/

Commands

MDC protocol uses a set of commands. Supported commands are defined in commands array from data.js. You can also find accepted values here.
Commands can accept multiple values or return a complex structures. Command syntax is command_name[?][ val1[,val2[...]]], but most common are commands with single value.
Sample commands: status?, power on, input HDMI.

encode(cmd, id) function

Encodes human friendly command to bytes according to Samsung MDC protocol.

  • cmd <string> - required. The cmd is a human friendly command which corresponds to MDC command name. To read a value you must provide a question mark '?' directly after the name (no space between). Example: 'input?'
  • id <number> - optional. If not specified, default id 0 will be used. You can also use wildcard id '0xFE'. This affects display 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 display. Other properties are helper ones.

decode(data) function

Decodes response from Samsung display into JS object.

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

Returns response <Object> - 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). Used to identify a response
  • value <string|number|Object> - decoded value. Return type depends on command
  • allValue <Object> - some pre-decoded values, specific for MDC 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 undefined value is returned.