{"id":23461346,"url":"https://github.com/hhromic/e131-node","last_synced_at":"2025-04-14T06:08:37.261Z","repository":{"id":8410386,"uuid":"58281516","full_name":"hhromic/e131-node","owner":"hhromic","description":"Node.js client/server library for the E1.31 (sACN) protocol","archived":false,"fork":false,"pushed_at":"2024-04-15T19:30:40.000Z","size":35,"stargazers_count":28,"open_issues_count":8,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T20:33:19.009Z","etag":null,"topics":["e131","light-controller","nodejs","protocol","sacn"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hhromic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-07T19:37:43.000Z","updated_at":"2024-04-12T00:56:51.000Z","dependencies_parsed_at":"2024-06-18T22:55:01.625Z","dependency_job_id":"ed76330f-e285-422d-b559-00de1a66c14e","html_url":"https://github.com/hhromic/e131-node","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.0625,"last_synced_commit":"093f62d26f4c6f055d8edd62812abf9c5da2d57b"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhromic%2Fe131-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhromic%2Fe131-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhromic%2Fe131-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhromic%2Fe131-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hhromic","download_url":"https://codeload.github.com/hhromic/e131-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248594140,"owners_count":21130312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["e131","light-controller","nodejs","protocol","sacn"],"created_at":"2024-12-24T07:34:38.447Z","updated_at":"2025-04-14T06:08:37.164Z","avatar_url":"https://github.com/hhromic.png","language":"JavaScript","readme":"# Node.js library for the E1.31 (sACN) protocol\n\nA Node.js module that provides simple client and server objects for communicating with devices using the E1.31 (sACN) protocol. A lot of information about E.131 (sACN) can be found on this [Wiki article](http://www.doityourselfchristmas.com/wiki/index.php?title=E1.31_(Streaming-ACN)_Protocol).\n\n## Installation\n\nTo install, use `npm`:\n\n    $ npm install e131\n\n## Client Class\n\nThe Client class implements a UDP client for sending E1.31 (sACN) traffic. The class constructor is as follows:\n\n```javascript\nvar e131 = require('e131');\nvar client = new e131.Client(arg, [port]);\n```\n\nThe first argument can be a host address, name or universe number. If `port` is omitted, the default E1.31 port `5568` is used.\nIf a universe is given, the client will automatically join the relevant Multicast group.\nThe client automatically increments (and wraps around if necessary) the sequence number of the transmitted packet.\n\nThe client provides two methods:\n\n* `createPacket(numSlots)`: creates a new E1.31 (sACN) packet to be used for sending.\n* `send(packet)`: sends a E1.31 (sACN) packet to the remote host or multicast group.\n\nFull code example for the Client class:\n\n```javascript\nvar e131 = require('e131');\n\nvar client = new e131.Client('192.168.1.12');  // or use a universe\nvar packet = client.createPacket(24);  // we want 8 RGB (x3) slots\nvar slotsData = packet.getSlotsData();\npacket.setSourceName('test E1.31 client');\npacket.setUniverse(0x01);  // make universe number consistent with the client\npacket.setOption(packet.Options.PREVIEW, true);  // don't really change any fixture\npacket.setPriority(packet.DEFAULT_PRIORITY);  // not strictly needed, done automatically\n\n// slotsData is a Buffer view, you can use it directly\nvar color = 0;\nfunction cycleColor() {\n  for (var idx=0; idx\u003cslotsData.length; idx++) {\n    slotsData[idx] = color % 0xff;\n    color = color + 90;\n  }\n  client.send(packet, function () {\n    setTimeout(cycleColor, 125);\n  });\n}\ncycleColor();\n```\n\n## Server Class\n\nThe Server class implements a UDP server for receiving E1.31 (sACN) traffic. The class constructor is as follows:\n\n```javascript\nvar e131 = require('e131');\nvar server = new e131.Server([universes], [port]);\n```\n\nThe `universes` argument can be an array (for joining multiple universes) or a single integer for joining a single universe. If `universes` is omitted, a single value of `1` is assumed.\n\n\u003e **Note:** This library only uses one UDP socket and there is a maximum limit of 20 multicast memberships (universes) per single UDP socket. See issue #17 for more details.\n\nIf `port` is omitted, the default E1.31 port `5568` is used.\nThe server will join the corresponding Multicast groups for each provided universe automatically and starts listening as soon as it is created.\nThe server performs basic out-of-order detection on received packets. If an out-of-order packet is received, it is discarded.\n\nThe server supports the following events that you can listen to:\n\n* `listening`: fires as soon as the server starts listening.\n* `close`: fires when the server is closed.\n* `error`: fires when an error occurs within the server.\n* `packet`: (packet) fires when a valid E1.31 (sACN) packet is received.\n* `packet-out-of-order`: (packet) fires when an out-of-order packet is received.\n* `packet-error`: (packet, err) fires when an invalid packet is received.\n\nFull code example for the Server class:\n\n```javascript\nvar e131 = require('e131');\n\nvar server = new e131.Server([0x0001, 0x0002]);\nserver.on('listening', function() {\n  console.log('server listening on port %d, universes %j', this.port, this.universes);\n});\nserver.on('packet', function (packet) {\n  var sourceName = packet.getSourceName();\n  var sequenceNumber = packet.getSequenceNumber();\n  var universe = packet.getUniverse();\n  var slotsData = packet.getSlotsData();\n\n  console.log('source=\"%s\", seq=%d, universe=%d, slots=%d',\n    sourceName, sequenceNumber, universe, slotsData.length);\n  console.log('slots data = %s', slotsData.toString('hex'));\n});\n```\n\n## E1.31 (sACN) Packet Class\n\nThe E1.31 Packet class contains a number of useful setter methods:\n\n* `setCID(uuid)`: sets the CID field into the root layer.\n* `setSourceName(name)`: sets source name field into the frame layer.\n* `setPriority(priority)`: sets the priority field into the frame layer.\n* `setSequenceNumber(number)`: sets the sequence number into the frame layer.\n* `setOption(option, state)`: sets the state of a framing option into the frame layer.\n* `setUniverse(universe)`: sets the DMX universe into the frame layer.\n* `setSlotsData(buffer)`: sets the DMX slots data into the DMP layer.\n\nAlso the following getter methods are provided:\n\n* `getCID()`: gets the CID field from the root layer.\n* `getSourceName()`: gets the source name field from the frame layer.\n* `getPriority()`: gets the priority field from the frame layer.\n* `getSequenceNumber()`: gets the sequence number from the frame layer.\n* `getOption(option)`: gets the state of a framing option from the frame layer.\n* `getUniverse()`: gets the DMX universe from the frame layer.\n* `getSlotsData()`: gets the DMX slots data from the DMP layer.\n\nAvailable E1.31 framing options are:\n\n* `Options.TERMINATED`: the current packet is the last one in the stream. The receiver should stop processing further packets.\n* `Options.PREVIEW`: the data in the packet should be only used for preview purposes, e.g. console display, and not to drive live fixtures.\n\nAvailable constants in the Packet class are:\n\n* `DEFAULT_PRIORITY`: the default priority number used to initialize new packets.\n\nIf a packet fails validation, the following errors can be returned:\n\n* `ERR_ROOT_LAYER:` mismatch in the ACN PID or vector fields of the root layer.\n* `ERR_FRAME_LAYER:` mismatch in the vector field of the frame layer.\n* `ERR_DMP_LAYER:` mismatch in the type, addresses or vector fields of the DMP layer.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhromic%2Fe131-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhhromic%2Fe131-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhromic%2Fe131-node/lists"}