hundemeier / go-sacn Goto Github PK
View Code? Open in Web Editor NEWImplementation of the sACN aka ANSI E1.31 protocol for streaming DMX-data in go
License: MIT License
Implementation of the sACN aka ANSI E1.31 protocol for streaming DMX-data in go
License: MIT License
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
.
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.
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
If we change our code to transmit on universe 2 , we dont see any packets incoming on the Receiver.
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"})
If we comment out the trans.SetMulticast(2, true)
we get the same behaviour
Kind Regards,
localleon
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.