opennetzteil

package module
v0.0.0-...-b8a4e1b Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

README

opennetzteil

Opennetzteil is a specification for a http interface for power supply devices. This project provides a server and a cli client.

The following devices are supported:

Writing drivers is simple; please contribute! :)

Run it

Build it:

$ make

Configure it:

$ cat $HOME/.config/netzteil/config.toml
[http]
bind = ":8000"

[[netzteile]]
handle = "file:///dev/ttyACM0"
model = "rnd320"

Run it:

$ ./netzteild

This is a usual http server. More complex setups with reverse proxy, authentication, tls, … are possible but out of scope for including it here. Use caddy or nginx for this.

What means Netzteil?

Netzteil is german for "power supply device".

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("endpoint not implemented")
)

Functions

This section is empty.

Types

type HTTPServer

type HTTPServer struct {
	ReqLog  io.Writer
	Devices []Netzteil
	Logger  *penlogger.Logger
}

func (*HTTPServer) CreateHandler

func (s *HTTPServer) CreateHandler() http.Handler

type Netzteil

type Netzteil interface {
	Probe() error
	Status() (interface{}, error)
	GetMaster() (bool, error)
	SetMaster(enabled bool) error
	GetIdent() (string, error)
	SetBeep(enabled bool) error
	GetChannels() (int, error)
	GetCurrent(channel int) (float64, error)
	SetCurrent(channel int, current float64) error
	GetVoltage(channel int) (float64, error)
	SetVoltage(channel int, voltage float64) error
	GetOut(channel int) (bool, error)
	SetOut(channel int, enabled bool) error
	GetOCP(channel int) (bool, error)
	SetOCP(channel int, enabled bool) error
	GetOVP(channel int) (bool, error)
	SetOVP(channel int, enabled bool) error
}

type NetzteilBase

type NetzteilBase struct {
	Name  string
	Ident string
	// contains filtered or unexported fields
}

func (*NetzteilBase) GetIdent

func (nt *NetzteilBase) GetIdent() (string, error)

func (*NetzteilBase) Request

func (nt *NetzteilBase) Request(handle io.ReadWriter, cmd []byte) ([]byte, error)

func (*NetzteilBase) RequestLine

func (nt *NetzteilBase) RequestLine(handle io.ReadWriter, cmd []byte) ([]byte, error)

func (*NetzteilBase) RequestWithTimeout

func (nt *NetzteilBase) RequestWithTimeout(handle io.ReadWriter, cmd []byte, timeout time.Duration) ([]byte, error)

func (*NetzteilBase) SendCommand

func (nt *NetzteilBase) SendCommand(handle io.Writer, cmd []byte) error

func (*NetzteilBase) SendCommandLine

func (nt *NetzteilBase) SendCommandLine(handle io.Writer, cmd []byte) error

func (*NetzteilBase) TCPRequest

func (nt *NetzteilBase) TCPRequest(target, cmd string) ([]byte, error)

TCPRequest creates a connection, sends the command, reads back the response, and closes the connection.

func (*NetzteilBase) TCPSend

func (nt *NetzteilBase) TCPSend(target, cmd string) error

TCPSend creates a connection, sends a commend and closes the connection. Useful if the relevant powersupply only supports one TCP connection at a time. To avoid deadlocks a HTTP/1 pattern is used. One request maps to one TCP connection. A HTTP keep-alive equivalent is avail with TCPSendBatched().

func (*NetzteilBase) TCPSendBatched

func (nt *NetzteilBase) TCPSendBatched(target string, cmd []string) error

TCPSendBatched creates a connection, sends multiple commands and closes the connection.

Directories

Path Synopsis
bin
devices
rnd
rs

Jump to

Keyboard shortcuts

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