scale

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetryDelay        = 3 * time.Second
	SerialReadTimeout = 5 * time.Second
	BaudRate          = 9600
)
View Source
const (
	ErrEOF        = "ERR_EOF"
	ErrTimeout    = "ERR_TIMEOUT"
	ErrRead       = "ERR_READ"
	ErrConnection = "ERR_SCALE_CONN"
)

Variables

View Source
var BrandCommands = map[string]string{
	"rhino":         "P",
	"rhino bar 8rs": "P",
}

BrandCommands maps scale brands to their weight request commands

View Source
var ErrorDescriptions = map[string]string{
	ErrEOF:        "EOF recibido. Posible desconexión.",
	ErrTimeout:    "Timeout de lectura.",
	ErrRead:       "Error de lectura.",
	ErrConnection: "No se pudo conectar al puerto serial.",
}

Functions

func GenerateSimulatedWeights

func GenerateSimulatedWeights() []float64

GenerateSimulatedWeights creates a sequence of realistic weight readings Returns 5 fluctuating values followed by a stable reading

func GetCommand

func GetCommand(brand string) string

GetCommand returns the command for a given brand Defaults to "P" if brand is unknown

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader manages serial port communication with the scale

func NewReader

func NewReader(cfg *config.Config, broadcast chan<- string) *Reader

NewReader creates a new scale reader

func (*Reader) ClosePort

func (r *Reader) ClosePort()

ClosePort closes the serial port for config changes

func (*Reader) Start

func (r *Reader) Start(ctx context.Context)

Start begins the reading loop (blocking)

func (*Reader) Stop

func (r *Reader) Stop()

Stop signals the reader to stop

Jump to

Keyboard shortcuts

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