3 Commits

Author SHA1 Message Date
Adrian Zuercher
de4758c563 fix mmissing defer for close channel and move make channel up earlier 2025-07-20 09:03:45 +02:00
Adrian Zuercher
a85c9ccd66 Merge branch 'main' of https://github.com/tecamino/tecamino-driver-artNet 2025-07-16 22:00:53 +02:00
zuadi
e0950b44ee Update build.yml add flags for smaller executable 2025-07-13 20:07:44 +02:00
2 changed files with 8 additions and 7 deletions

View File

@@ -36,9 +36,9 @@ jobs:
run: |
mkdir -p build
if [ "${{ matrix.goos }}" == "windows" ]; then
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/tecamino-driver-artNet-${{ matrix.goos }}-${{ matrix.goarch }}.exe main.go
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -o build/tecamino-driver-artNet-${{ matrix.goos }}-${{ matrix.goarch }}.exe main.go
else
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/tecamino-driver-artNet-${{ matrix.goos }}-${{ matrix.goarch }} main.go
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -o build/tecamino-driver-artNet-${{ matrix.goos }}-${{ matrix.goarch }} main.go
fi
- name: Upload artifacts

View File

@@ -107,9 +107,11 @@ func (b *Bus) Start(log *logging.Logger) error {
var ctx context.Context
ctx, b.Watchdog = context.WithCancel(context.Background())
b.Send = make(chan *DMX, 1024)
go func() {
var interval time.Duration = 10 * time.Second
log.Info("bus.Start", fmt.Sprintf("device:%s ip:%s watchdog stopped", b.Name, b.Ip))
log.Info("bus.Start", fmt.Sprintf("device:%s ip:%s watchdog starting", b.Name, b.Ip))
for {
select {
case <-ctx.Done():
@@ -126,7 +128,7 @@ func (b *Bus) Start(log *logging.Logger) error {
interval = 5 * time.Second
} else {
b.Reachable = true
// send data as a heartbeat for the ArtNet Protocol
// send data as a heartbeat for she ArtNet Protocol
b.Send <- b.Data
log.Info("bus.Start", fmt.Sprintf("device:%s ip:%s watchdog running", b.Name, b.Ip))
interval = 30 * time.Second
@@ -145,12 +147,11 @@ func (b *Bus) Start(log *logging.Logger) error {
return err
}
b.Send = make(chan *DMX, 1024)
go func() {
defer conn.Close()
//close send channel
close(b.Send)
defer close(b.Send)
for send := range b.Send {
_, err = conn.Write(NewArtNetPackage(send))
if err != nil {