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 ¶
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 ¶
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. |