vedirect

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

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 3 Imported by: 0

README

WIP

Fork of https://github.com/rosenstand/go-vedirect

Go package for VE.Direct

go-vedirect can read data from the VE.Direct serial protocol used in compatible products by Victron Energy.

It currently uses the tarm/serial Go package for setting up the serial port.

Has been tested on a Raspberry Pi Zero W connected to a Victron Energy SmartSolar MPPT 75/15 solar charger.

Disclaimer

This is my first Go program. It's not pretty (yet). Suggestions for improvements will be highly appreciated.

Usage

s := vedirect.NewStream("/dev/ttyUSB0")
fmt.Println(s)
for {
	block, checksum := s.ReadBlock()
	if checksum == 0 {
		fmt.Println(block)
	} else {
		fmt.Println("Bad block, skipping:", block)
	}
}

TODO

  • Proper error handling.
  • Godoc support.
  • Use a larger buffer instead of doing a read() for every byte.
  • Improve interface and naming.

Documentation

Index

Constants

View Source
const (
	InChecksum = 1
	InFrame    = 2
	InLabel    = 3
	InValue    = 4
	WaitHeader = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Checksum int
	Fields   map[string]string
}

func (Block) Validate

func (b Block) Validate() bool

type Stream

type Stream struct {
	Device string
	//Port   *os.File
	Port  *serial.Port
	State int
}

func NewStream

func NewStream(dev string) (Stream, error)

func (*Stream) ReadBlock

func (s *Stream) ReadBlock() (Block, int)

type Streamer

type Streamer interface {
	Read() int
}

Jump to

Keyboard shortcuts

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