GithubHelp home page GithubHelp logo

hundemeier / go-sacn Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 8.0 88 KB

Implementation of the sACN aka ANSI E1.31 protocol for streaming DMX-data in go

License: MIT License

Go 100.00%
sacn dmx udp unicast multicast godoc golang golang-library

go-sacn's People

Contributors

adregner avatar andrewmulkeycci avatar hundemeier avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

go-sacn's Issues

Transmitter Not Working on other Universes

Apparently there is a problem where the transmitter does not transmit packets on universes other than universe 1. I used the latest Version on go version go1.10.1 linux/amd64 .

How to Reproduce

  1. First start a Receiver on your host.
package main

import (
        "fmt"
        "log"

        "github.com/Hundemeier/go-sacn/sacn"
)

func main() {
        recv, err := sacn.NewReceiverSocket("", nil)
        if err != nil {
                log.Fatal(err)
        }
        recv.SetOnChangeCallback(func(old sacn.DataPacket, newD sacn.DataPacket) {
                fmt.Println("data changed on", newD.Universe())
        })
        recv.SetTimeoutCallback(func(univ uint16) {
                fmt.Println("timeout on", univ)
        })
        recv.Start()
        fmt.Println("Started")
        select {} //only that our program does not exit. Exit with Ctrl+C
}

This should print out every sACN Packet it receives.

  1. Run the Transmitter
package main

import (
        "log"
        "time"

        "github.com/Hundemeier/go-sacn/sacn"
)

func main() {
        //instead of "" you could provide an ip-address that the socket should bind to
        trans, err := sacn.NewTransmitter("", [16]byte{1, 2, 3}, "test")
        if err != nil {
                log.Fatal(err)
        }

        //activates the first universe
        ch, err := trans.Activate(1)
        if err != nil {
                log.Fatal(err)
        }
        //deactivate the channel on exit
        defer close(ch)

        //set a unicast destination, and/or use multicast
        trans.SetMulticast(1, true) //this specific setup will not multicast on windows,
        //because no bind address was provided

        //set some example ip-addresses
        trans.SetDestinations(1, []string{"127.0.0.1"})

        // Turn Shutter on and off
        for i := 0; i < 20; i++ {
                ch <- [512]byte{0, 255}
                time.Sleep(1000 * time.Millisecond)
                ch <- [512]byte{255, 0}
                time.Sleep(1000 * time.Millisecond)

        }
}

Now we should get an output on the Receiver. This should look like

Started
data changed on 1
data changed on 1
data changed on 1

However

If we change our code to transmit on universe 2 , we dont see any packets incoming on the Receiver.

Wireshark

If were transmitting Universe 1, Wireshark shows us the corresponding UDP Packets. Everything is alright.

Now we set the Universe to 2 and no new Packets get transmitted.

        //set a unicast destination, and/or use multicast
        trans.SetMulticast(2, true) //this specific setup will not multicast on windows,
        //because no bind address was provided

        //set some example ip-addresses
        trans.SetDestinations(2, []string{"127.0.0.1"})

Without Multicast

If we comment out the trans.SetMulticast(2, true) we get the same behaviour

System Info

  • OS Ubuntu 18.10 cosmic
  • x86_64 Linux 4.18.0-10-generic
  • Shell: zsh 5.5.1
  • DE: KDE 5.50.0 / Plasma 5.13.5

Kind Regards,
localleon

Receiving / Transmitting on same Host

OS: Linux
Version: latest

If you run a sACN-Receiver on your Host and the start a sACN-Transmitter. You get the following error.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4df4fa]

goroutine 1 [running]:
github.com/Hundemeier/go-sacn/sacn.NewTransmitter(0x0, 0x0, 0x35c1711ec70da98e, 0xb1f8cce947e4eb8e, 0x53431f, 0x8, 0, 0x0, 0x0, 0x0, ...)
        /home/linuxleon/bin/Golang/src/github.com/Hundemeier/go-sacn/sacn/transmitter.go:43 +0x19a
main.main()
        /home/linuxleon/bin/key2sACN/key2sacn.go:43 +0x2e7

You can reproduce the error with the sample code.

Why panic for errors?

Hello,

I have been using this lib and it works great, except when something unexpected happen and the lib crashes my program completely.
(For example, putting the computer to sleep, breaks the socket and panics).

I saw 6 panics in the code, and 3 of them could be simply passed up the function to the caller to be handled.
The 3 others happen inside goroutines running to send/receive data, and will need special handling from there.

Imo, there should be a way to handle these errors externally, so that we have full control over errors happening during execution.
But, changing the functions which could return an error to the user would result in an api break, and returning errors from the Rx/Tx goroutines would necessitate a new way to get them to the library user.

I would be willing to put the work for implementing those changes, but I would like inputs about the best ways to proceed.
The simplest way I see is having a callback called when an universe/socket is stopped because of an error, letting the user know of the issue and letting them reconnect.

Thanks for your opinions

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.