5 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
Adrian Zuercher
da78a00446 add heartbeat send data every 30 Seconds 2025-07-16 21:53:47 +02:00
Adrian Zuercher
ba3c55dc34 add mac DS_Store 2025-07-16 21:52:31 +02:00
zuadi
e0950b44ee Update build.yml add flags for smaller executable 2025-07-13 20:07:44 +02:00
3 changed files with 10 additions and 6 deletions

View File

@@ -36,9 +36,9 @@ jobs:
run: | run: |
mkdir -p build mkdir -p build
if [ "${{ matrix.goos }}" == "windows" ]; then 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 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 fi
- name: Upload artifacts - name: Upload artifacts

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.DS_Store
*.cfg *.cfg
*.log *.log
artNetDriver-arm64 artNetDriver-arm64

View File

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