GitHub - DownerCase/ecal-go: Go bindings for eclipse eCAL (original) (raw)

Go-eCAL

Go bindings and CLI tools for eCAL 6 (currently unreleased). Inspired from Blutkoete/golang-ecal.

Usage

Go binding demo

go run .

Go version of eCAL monitor

go run ./cmd/monitor

Features

Provides Go interfaces for:

Example

package main

import ( "fmt" "time"

"github.com/DownerCase/ecal-go/ecal"

)

func main() { // Initialize eCAL ecal.Initialize( ecal.NewConfig(ecal.WithConsoleLogging(true), ecal.WithConsoleLogAll()), "Go eCAL!", ecal.CDefault, ) defer ecal.Finalize() // Shutdown eCAL at the end of the program

// Send messages
go func() {
    publisher, err := ecal.NewStringPublisher("string topic")
    if err != nil {
        panic("Failed to make string publisher")
    }
    defer publisher.Delete()

    for idx := 0; true; idx++ {
        publisher.Send(fmt.Sprint("This is message ", idx))

        time.Sleep(time.Second)
    }
}()

// Receive messages
subscriber, err := ecal.NewStringSubscriber("string topic")
if err != nil {
    panic("Failed to Create string subscriber")
}
defer subscriber.Delete()

for ecal.Ok() {
    msg, err := subscriber.Receive(time.Second * 2)
    if err == nil {
        fmt.Println("Received:", msg)
    } else {
        fmt.Println(err)
    }
}

}

CLI Tools

Monitor

Features:

All the basic functionality from the upstream TUI monitor but:

Non-system installations

If eCAL is not installed in a default search path or you wish to use a specific install of eCAL there is a helper CMake project to generate a package_user.gowith the correct cgo flags.

cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/cmake/install go run .

Development

To help write the C and C++ wrapper use the CMake project to generate acompile_commands.json.