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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址