Code Monkey home page Code Monkey logo

sacn's Introduction

sACN (E1.31) Documentation

Swift Package for macOS, iOS, and tvOS to send sACN (E1.31) DMX Data over UDP using Network.framework.

Usage

You only need to initiate a Connection for a universe and you can start sending DMX Data.

let connection = Connection(universe: 1)
connection.sendDMXData(Data([0, 10, 255, 0, 0, 0, 255]))

If you want to use UDP Unicast instead of Multicast, you can simply specify an endpoint yourself:

let connection = Connection(endpoint: .hostPort(host: "192.168.2.102", .sACN), universe: 2)
connection.sendDMXData(Data([0, 10, 255, 0, 0, 0, 255]))

Features

  • Sending DMX Data via UDP Multicast and Unicast on IPv4/IPv6
  • sACN Package Priority
  • Preview Data
  • Depends only on Foundation and Network.framework

Advanced Usage

Using IPv6

For Unicast, you need to specify an IPv6 Endpoint. For Multicast, you need to specify the IP version you want to use:

let connection = Connection(universe: 1, ipVersion: .v6)

Priority

After you created a connection, you can set the priority per packet using the Connection.sendDMXData(_:priority:isPreviewData:) method. The default priority is 100.

connection.sendDMXData(data, priority: 200)

Preview Data

After you created a connection, you can choose per packet if it is preview data or not using the Connection.sendDMXData(_:priority:isPreviewData:) method. isPreviewData defaults to false.

connection.sendDMXData(data, isPreviewData: true)

Other Connection Initialization Configuration

Connection does support customizing the port, component identifier (CID), source name, DispatchQueue, and NWConneciton.Parameter. Look into the Documentation for more information.

public convenience init(
    universe: UInt16,
    ipVersion: IPVersion = .v4,
    port: NWEndpoint.Port = .sACN,
    cid: UUID = .init(),
    sourceName: String = getDeviceName(),
    queue: DispatchQueue? = nil,
    parameters: NWParameters? = nil
)

Known Limitations

sacn's People

Contributors

dnadoba avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

sacn's Issues

Sent data does not work / it doesnt send

Hi,
I have a problem using this package. I'm building a macOS application using Swiftui and I'm not able to control my lights with this package. I have a Raspberry Pi set up with OLA.
To explain the problem a bit further, yesterday I set up the Raspberry Pi. I checked the XCode Network (Debug) Monitor to look for Network Traffic, and indeed, I saw data was going out of my program into the pi. (Yes I checked the pi too). But no values seemed to change in the universe. I retried multiple times and tried different methods too. My current attempt is using UDP Unicast to a local IP address. (Yes I tried plugging every component into a switch, and yes it didn't work) I checked every reachability, and to my surprise when I used qlc+ everything worked out fine. So it seems the problem is on the side of this package. I hope to get some help or answer on this issue because the other one didn't really get any response.
Best regards,
MIC

let connection = Connection(endpoint: .hostPort(host: "192.168.178.178", port: .sACN), universe: 1)
connection.sendDMXData(Data([255, 0, 0, 0, 255]), priority: 200, isPreviewData: false)

In OLA:
Bildschirmfoto 2024-02-24 um 21 50 18
Bildschirmfoto 2024-02-24 um 21 50 30
Bildschirmfoto 2024-02-24 um 21 51 11

IN XCode:
Bildschirmfoto 2024-02-24 um 23 35 09

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.