golang-ecal

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

golang-ecal

A high-level interface from GO to eCAL based on a low-level interface generated via SWIG.

Status

This is the initial version providing an abstraction of the SWIG-generated low-level interface for initialization, publishers and subscribers.

ecal: This is the high-level interface. It allows initialization, data publishing and reception.

ecalc: This is the pure SWIG-generated low-level interface.

As the full low-level interface is accessible, you can do whatever the eCAL C interface allows you to do. More GO-like approaches like channels are only available via the high-level interface and thus are currently limited to publishers and subscribers. The publisher and subscriber interface are complete excluding event callbacks. Services and other functionality are currently only available via the low-level ecalc interface.

Usage

GO is about simplicity, so the high-level interface initializes a lot of settings with defaults if you do not call the initialization functions yourself.

Sending:

package main

import (
    "log"
    "time"

    "github.com/Blutkoete/golang-ecal/ecal"
)

func main() {
    pub, pubChannel, err := ecal.PublisherCreate("Hello", "base:std::string", "", true)
    if err != nil {
	    log.Fatal(err)
    }
    defer pub.Destroy()

    count := 0
    for ecal.Ok() {
	    message := ecal.Message{Content: []byte(fmt.Sprintf("Hello World from Go (%d)", count)),
		                    	Timestamp: -1}
	    count += 1
	    select {
	    case pubChannel <- message:
		    log.Printf("Sent \"%s\"\n", message.Content)
	    case <-time.After(time.Second):
	    }
	    <-time.After(250 * time.Millisecond)
    }
}

Receiving:

package main

import (
    "log"
    "time"

    "github.com/Blutkoete/golang-ecal/ecal"
)

func main() {
    sub, subChannel, err := ecal.SubscriberCreate("Hello", "base:std::string", "", true, 1024)
    if err != nil {
	    log.Fatal(err)
    }
    defer sub.Destroy()

    for ecal.Ok() {
	    select {
	    case message := <-subChannel:
		    log.Printf("Received \"%s\"\n", message.Content)
	    case <-time.After(time.Second):
	    }
    }
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL