Giter VIP home page Giter VIP logo

sacn's Introduction

sACN receiver & sender in node.js

Build Status Coverage Status npm version npm install size

πŸ’‘ This module can receive DMX data sent via sACN from professional lighting consoles (e.g. ETC, Onyx).

🎭 It can also send data to DMX fixtures that support sACN, e.g. LED lights, smoke machines, etc.

Install

npm install sacn

Usage - Receiver

πŸ”¦ Sending RDM data to fixtures is not implemented yet, see issue #1.

const { Receiver } = require('sacn');

const sACN = new Receiver({
  universes: [1, 2],
  // see table 1 below for all options
});

sACN.on('packet', (packet) => {
  console.log('got dmx data:', packet.payload);
  // see table 2 below for all packet properties
});

sACN.on('PacketCorruption', (err) => {
  // trigged if a corrupted packet is received
});

sACN.on('PacketOutOfOrder', (err) => {
  // trigged if a packet is received out of order
});

/* advanced usage below */

sACN.on('error', (err) => {
  // trigged if there is an internal error (e.g. the supplied `iface` does not exist)
});

// start listening to a new universe (universe 3 in this example)
sACN.addUniverse(3);

// stop listening to a universe 1
sACN.removeUniverse(1);

// close all connections; terminate the receiver
sACN.close();

sACN.universes; // is a list of the universes being listened to

Table 1 - Options for Receiver

Name Type Purpose Default
universes number[] Required. List of universes to listen to. Must be within 1-63999 []
port number Optional. The multicast port to use. All professional consoles broadcast to the default port. 5568
iface string Optional. If the computer is connected to multiple networks, specify which network adaptor to use by using this computer's local IP address null
reuseAddr boolean Optional. Allow multiple programs on your computer to listen to the same sACN universe. false

Table 2 - Packet properties

{
  "sourceName": "Onyx", // controller that sent the packet
  "sourceAddress": "192.168.1.69", // ip address of the controller
  "universe": 1, // DMX universe
  "sequence": 172, // packets are numbered 0-255 to keep them in order
  "priority": 100, // 0-200. used if multiple controllers send to the same universe
  "payload": { // an object with the percentage values of DMX channels 1-512
    1: 100,
    2: 50,
    3: 0
  },

  /* there are more low-level properties which most
     users won't need, see the ./src/packet.ts file */
}

Usage - Sender

const { Sender } = require('sacn');

const sACNServer = new Sender({
  universe: 1,
  // see table 3 below for all options
});

async function main() {
  await sACNServer.send({
    payload: {
      // Required. An object with the percentages (0-100) for each DMX channel.
      // You can use 0-255 instead of 0-100 by setting `useRawDmxValues: true`
      // per packet, or in the `defaultPacketOptions`.
      1: 100,
      2: 50,
      3: 0,
    },
    sourceName: "My NodeJS app", // optional. LED lights will use this as the name of the source lighting console.
    priority: 100, // optional. value between 0-200, in case there are other consoles broadcasting to the same universe
  });

  sACNServer.close(); // terminate the server when your app is about to exit.
}

main(); // wrapped in a main() function so that we can `await` the promise

Table 3 - Options for Sender

Name Type Purpose Default
universe number Required. The universe to send to. Must be within 1-63999
port number Optional. The multicast port to use. All professional consoles broadcast to the default port. 5568
reuseAddr boolean Optional. Allow multiple programs on your computer to send to the same sACN universe.
defaultPacketOptions object Optional. You can specify options like sourceName, cid, priority and useRawDmxValues here instead of on every packet
iface string Optional. Specifies the IPv4 address of the network interface/card to use. OS default interface (=active internet connection)
minRefreshRate number Optional. How often the data should be re-sent (in Hertz/Hz), even if it hasn't changed. By default data will only be sent once (equivilant of setting refreshRate: 0). To re-send data 5 times per second (5Hz), set refreshRate: 5. This is equivilant to 200ms. 0
useUnicastDestination string Optional. Setting this attribute to an IPv4 address will cause data to be sent directly to that device, instead of broadcasting to the whole LAN.

Contribute

npm run build # compile typescript
npm test # run tests

Network Requirements

  • Multicast must be enabled1. sACN uses port 5568 on 239.255.x.x
  • Network infrastructure that supports at least 100Mbps (100BaseT)

Protocol Docs

The Architecture for Control Networks (ACN) and derived protocols are created by the Entertainment Services and Technology Association.


1Β­. Unicast is also supported by default, but this is not how sACN normally works. See Table 3 for how to send data directly to a unicast address. ↩

sacn's People

Contributors

chronikum avatar dependabot[bot] avatar greenkeeper[bot] avatar hansschall avatar k-yle avatar lukas-runge avatar mutec avatar schw4rzlicht avatar varkokonyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sacn's Issues

Email

Hey @k-yle,

Screen Shot 2020-10-16 at 11 42 05 am

Tried to send you email but it bounced. Is there a better way to contact you?

Lyndon

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.18.2 to 2.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ build (12.x): There are 2 failures, 0 warnings, and 0 notices.
  • ❌ build (10.x): There are 2 failures, 0 warnings, and 0 notices.
  • ❌ build (8.x): There are 1 failures, 0 warnings, and 0 notices.

Commits

The new version differs by 46 commits.

  • 9b76635 Bump to v2.19.0
  • 47a232e [resolvers/webpack] v0.12.0
  • 26ad476 [resolvers/webpack] [deps] update debug, enhanced-resolve, has, interpret, lodash, resolve, semver
  • 3f0e8f3 [resolvers/node] [Deps] update resolve
  • 7190c3e bump utils to v2.5.0
  • a60e5c6 [New] no-commonjs: add allowConditionalRequire option
  • 414c923 [New] enable passing cwd as an option to eslint-import-resolver-webpack
  • 8224e51 [New] order/no-extraneous-dependencies: Alphabetize imports within groups
  • f12ae59 [New] no-duplicates: add a considerQueryString option to handle false positives when using some webpack loaders.
  • 2d3d045 [fix] importType: Accept '@example' as internal
  • 0426f16 [New] order: add pathGroups option to add support to order by paths
  • 99b3fbf [Fix] no-extraneous-dependencies: Add support for export from
  • 21bf8c6 [Fix] no-cycle: should not warn for Flow imports
  • 0cd5e43 [Fix] no-unused-modules: fix crash due to export *
  • 05085bb [flow] no-unused-modules: add flow type support

There are 46 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 12.12.1 to 12.12.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ build (12.x): There are 2 failures, 0 warnings, and 0 notices.
  • ❌ build (10.x): There are 2 failures, 0 warnings, and 0 notices.
  • ❌ build (8.x): There are 2 failures, 0 warnings, and 0 notices.

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/parser is breaking the build 🚨

The devDependency @typescript-eslint/parser was updated from 2.19.0 to 2.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ build (12.x): There are 1 failures, 0 warnings, and 0 notices.
  • ❌ build (10.x): There are 1 failures, 0 warnings, and 0 notices.
  • ❌ build (8.x): There are 2 failures, 0 warnings, and 0 notices.

Release Notes for v2.19.1

2.19.1 (2020-02-10)

Bug Fixes

  • eslint-plugin: [unbound-method] blacklist a few unbound natives (#1562) (4670aab)
  • typescript-estree: ts returning wrong file with project references (#1575) (4c12dac)
Commits

The new version differs by 5 commits.

  • 1c8f0df chore: publish v2.19.1
  • 4c12dac fix(typescript-estree): ts returning wrong file with project references (#1575)
  • e9cf734 docs(eslint-plugin): fix typo in readme
  • 10d86b1 docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
  • 4670aab fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

handle network connection issues

Ought to close and reopen the dgram socket on network disconnect/reconnect.

Could be an optional feature:

sACN.on('close', sACN.tryReopen);

Listen to single universes doesn't work

Although I define universes to listen to in the constructor of Receiver, Receiver.on("packet", ...) is called for all received universes.

Is this expected behaviour?

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 2.6.0 to 2.6.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ build (12.x): There are 2 failures, 7 warnings, and 0 notices.
  • ❌ build (10.x): There are 2 failures, 7 warnings, and 0 notices.
  • ❌ build (8.x): There are 2 failures, 7 warnings, and 0 notices.

Release Notes for v2.6.1

2.6.1 (2019-11-04)

Bug Fixes

  • typescript-estree: don't use typescript's synthetic default (#1156) (17c956e), closes #1153
  • typescript-estree: fix filename handling for vue JSX + markdown (#1127) (366518f)
  • typescript-estree: improve comment parsing code (#1120) (e54998d)
Commits

The new version differs by 4 commits.

  • 643d6d6 chore: publish v2.6.1
  • e54998d fix(typescript-estree): improve comment parsing code (#1120)
  • 366518f fix(typescript-estree): fix filename handling for vue JSX + markdown (#1127)
  • 17c956e fix(typescript-estree): don't use typescript's synthetic default (#1156)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Return raw numbers and arrays

Until 2.3.2 the message event returned a Packet that contained slotsData. Although objectify existed, we could build our own logic to extract data from the buffer. Since I need the data in raw values (0-255) and as an array, I did that with a few lines of code.

Since 3.1.0 Packet deserializes the buffer directly to the same object as objectify did. Therefore I'd like to propose a change towards the old behavior, maybe including both worlds.

I would create a PR for that but wanted to discuss the issue with you first.

Callback throws Error: addMembership EADDRNOTAVAIL

When calling new Receiver() with an interface that doesn't exist, Socket.addMembership() throws Error: addMembership EADDRNOTAVAIL which is not catchable since it happens in the callback.

Wouldn't it be a better idea to add a start() method to Receiver which returns a promise so we could handle the error properly?

iface option for Sender only works once.

Using the below example, only universe 11 is sent via the desired interface, the others are sent via default.

const ip = "10.101.100.1";
const sacn11 = new Sender({
    universe: 11,
    iface: ip
});

const sacn12 = new Sender({
    universe: 12,
    iface: ip
});
const sacn13 = new Sender({
    universe: 13,
    iface: ip
});

[Sender] Missing option to select the interface

I found no documentated way to the select the interface the data is sent to.

The default interface is choosen automatically. In my case this is always the WiFi interface, even if it is turned off. For local loopback this is no problem, if the default receiver interface is used, too. This makes it impossible to comunicate over network if the computer has more than one network interface.

sender script

Hello together,
your receiver is very beautiful and it works perfectly. Now I want to implement the sender and the priority is 0, with the tool sacnview for windows.
And the sender only once sent the information.

`const { Sender } = require('sacn');

const sACNServer = new Sender({
universe: 1,
// see table 3 below for all options
});

async function main() {
await sACNServer.send({
payload: { // required. object with the percentages for each DMX channel
1: 100,
2: 50,
3: 0,
},
sourceName: "My NodeJS app", // optional. LED lights will use this as the name of the source lighting console.
priority: 188, // optional. value between 0-200, in case there are other consoles broadcasting to the same universe
});

}

main(); // wrapped in a main() function so that we can await the promise`

Universe identifier inconsistencies

Hey there!

I just noticed that although documentation states universes must be between 0 and 63999, util.js throws RangeError: universe must be between 1-63999 when using 0. What am I supposed to use now?

Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.