lucigo

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT, MIT Imports: 12 Imported by: 0

README

LUCIGO: A Go client for LUCIDAC

Go Reference Github CI

This repository holds a little client for the LUCIDAC with the focus on device administration. While all other clients available require ecosystems such as Python PIP or the Julia package manager, the LUCIGO client can be easily compiled and distributed as static binaries for all major desktop platforms. This makes it great for getting started, in particular for novices who cannot do well with the terminal.

Getting started as a user

Just grab the latest release. It contains binaries ready to download for all major platforms (Mac OS X, MS Windows, GNU/Linux).

For instance, on Linux you get started with these three commands

wget https://github.com/anabrid/lucigo/releases/download/latest/lucigo
chmod 755 lucigo
./lucigo --help

Scope

The current scope of this client implementation is not to provide a full experience of configuring and running analog circuits but instead on changing permanent settings and bringing LUCIDAC onto the network. Typical use cases are

  • User needs USB to bootstrap the networking, i.e. set some static IPv4 on the device before it can start.
  • User cannot make use of networking but USB works. He nevertheless wants to enjoy the web based GUI. As the embedded webserver is not reachable, lucigo is ready to provide a (websocket'ing) webserver and proxy the USB Serial.

Feature list

Checked if implemented

  • USB communication
  • TCP/IP communication
  • mDNS discovery
  • basic CLI
  • convenient permanent settings (hierarchical and shorthanded)
  • websocket proxying
  • USB Serial discovery
  • current serial USB library does not work for Mac (at least not cross compiling, cf the gitlab-CI)

Getting started as developer

Once Go is running on your system, it is very easy to build the code. Here are three possible methods:

  1. Just run go install github.com/anabrid/lucigo@latest from somewhere, without checking out the repository or anything. This will download and compile all dependencies and put them to $GOPATH, which defaults to ~/go/bin on Linux and Mac.
  2. Check out the repository, run go build . and find the executable in the same directory.
  3. Check out the repository, run make build, find the executables in the build/ directory. This also does cross compilation, so you find executables for all platforms in the build/ directory. Choose yours.

Note that using make is the currently the only way of building a fully fledged executable which has version information about itself (lucigo --version) and contains a build image of the LUCIGUI. The other ways of building the executable are still fine and working, however, for instance, lucigo --version currently holds no information in these builds.

Current executable sizes/artifact sizes are about 15MB in size.

Installing Go

Install go with your package manager, such as apt install golang, or follow the instructions from https://go.dev/doc/install

On Mac, need to make sure that Xcode is installed before you can use the go compiler, otherwisse you will get an error about xcrun. Run xcode-select --install and also probably follow the steps described here if the xcrun problems remain.

License

As all anabrid code within the LUCIDAC project, this code is dual licensed:

Copyright (c) 2024 anabrid GmbH

Contact: https://www.anabrid.com/licensing/

SPDX-License-Identifier: MIT OR GPL-2.0-or-later

Documentation

Overview

Package lucigo provides a client for the LUCIDAC analog digital hybrid-computer made by anabrid. This is accompanied with a command/executable with the same name.

Usage Example

The main purpose of this class is to provide a *thin* layer above the JSONL protocol (de-)serialization and different endpoints.

hc, err := lucigo.HybridController("tcp://1.2.3.4")
if err != nil {
	log.Fatal(err)
}

resp, err := hc.Query("net_status")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("net_status = %#v\n", resp)

You can also have a look into the executabe called `lucigo` to get an idea how to use this library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindServers

func FindServers()

FindServers currently implements mDNS Zeroconf discovery in the local IP broadcast domain. TODO: It is supposed to be extended for USB device discovery.

func ParseEndpoint

func ParseEndpoint(endpoint string) (interface{}, error)

ParseEndpoint creates either a JSONLEndpoint or a SerialEndpoint, i.e. translates an endpoint URL string to a structure.

func RecvIsSuccess

func RecvIsSuccess(recv *RecvEnvelope) bool

isSuccess indicates whether the RecvEnvelope contains an Error message or not.

Types

type HybridController

type HybridController struct {
	Endpoint      string
	Endpoint_type interface{}
	Stream        io.ReadWriter // *serial.Port
	Reader        *bufio.Scanner
}

The HybridController is the most important object in this package and provides an OOP interface to the LUCIDAC. This class is sometimes also called "LUCIDAC" in other clients.

func NewHybridController

func NewHybridController(endpoint string) (*HybridController, error)

NewHybridController expects an endpoint URL as string. It uses ParseEndpoint for translating this to an endpoint structure.

func (*HybridController) Command

func (hc *HybridController) Command(sent_envelope SendEnvelope) (*RecvEnvelope, error)

Command is a low-level command to send and receive envelopes. Note how this is a *synchronous* implementation.

func (*HybridController) Query

func (hc *HybridController) Query(Type string) (*RecvEnvelope, error)

Query is a high-level command for communicating with the LUCIDAC. It is a shorthand for [QueryMsg] sending an *empty* message. Some command types (such as `Type="net_status"`) do not expect messages.

func (*HybridController) QueryMsg

func (hc *HybridController) QueryMsg(Type string, Msg map[string]interface{}) (*RecvEnvelope, error)

QueryMsg is the high-level command for communicating with the LUCIDAC.

type JSONLEndpoint

type JSONLEndpoint struct {
	Host string
	Port int
}

JSONLEndpoint contains all information neccessary to connect to a TCP/IP endpoint. An endpoint is where an actual LUCIDAC serves.

func (*JSONLEndpoint) HostPort

func (e *JSONLEndpoint) HostPort() string

type RecvEnvelope

type RecvEnvelope struct {
	Type  string                 `json:"type"`
	Id    uuid.UUID              `json:"id"`
	Code  int                    `json:"code"`
	Error string                 `json:"error"`
	Msg   map[string]interface{} `json:"msg"`
}

RecvEnvelope is the outer structure of a received message from LUCIDAC in the JSONL protocol. By convention, the Id and Type have to match with the previously sent SendEnvelope. The message depends on the Type.

type SendEnvelope

type SendEnvelope struct {
	Type string      `json:"type"`
	Id   uuid.UUID   `json:"id"`
	Msg  interface{} `json:"msg"`
}

SendEnvelope is the outer structure of a message sent to LUCIDAC in the JSONL protocol.

func NewEnvelope

func NewEnvelope(Type string) SendEnvelope

NewEnvelope creates a SendEnvelope for a given type with random UUID and emtpy Msg

type SerialEndpoint

type SerialEndpoint struct {
	Device string
}

SerialEndport contains all information neccessary to connect to a local USB Serial device.

Directories

Path Synopsis
cmd
lucigo command
lucigo is a client for the LUCIDAC and a reference implementation for the similiarly named golang package which allows to write clients in the go programming language.
lucigo is a client for the LUCIDAC and a reference implementation for the similiarly named golang package which allows to write clients in the go programming language.

Jump to

Keyboard shortcuts

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