protocol

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdEndMemory   = 0x80 // TX Memorias FIN
	CmdRepeat      = 0x90 // TX Memoria REPITE
	CmdNext        = 0xA0 // TX Memoria SIGUIENTE
	CmdNext24h     = 0xB0 // TX Memoria 24h SIGUIENTE
	CmdStartMemory = 0xC0 // TX Memoria INICIA
	CmdGetCurrent  = 0xE0 // TX Actual (solicitud asíncrona)
)

Command base codes (before OR with device address). Final command byte = Base | DeviceAddr (addr 1-14, default 4).

View Source
const DefaultAddr = 4

DefaultAddr is the device address shipped from the factory.

Variables

This section is empty.

Functions

func AppendChecksum

func AppendChecksum(data []byte) []byte

AppendChecksum appends a 4-char hex checksum to data and returns the full frame.

func Command

func Command(base byte, addr byte) byte

Command returns the wire byte for a base command and device address.

func SensorNames

func SensorNames() [8]string

SensorNames returns default display names for the 8 memory-frame channels. Channel 7 (index 6) is the motor/compressor; exact mapping should be verified against the physical chamber wiring.

func TempC

func TempC(raw int) float64

TempC converts a raw sensor value to degrees Celsius (values are in 0.1 °C units).

func VerifyChecksum

func VerifyChecksum(frame []byte) bool

VerifyChecksum returns true if the frame passes its checksum.

Memory frame (77 chars):

  • bytes 1-73 (0-72 in Go) are data
  • bytes 74-77 (73-76) are 4-char uppercase hex sum

Async frame (52 chars):

  • bytes 1-48 (0-47) are data
  • bytes 49-52 (48-51) are 4-char uppercase hex sum

Types

type Frame

type Frame struct {
	RecordIndex int
	Timestamp   time.Time
	Sensors     [8]SensorReading
}

Frame is a parsed PITEC memory record (77-char frame). Sensor numbering follows the device's internal channel order (1-8). Channel 7 is the motor/compressor duty channel; the others are thermal sensors.

func ParseFrame

func ParseFrame(raw []byte) (*Frame, error)

ParseFrame parses a full 77-char memory frame (positions are 1-indexed in the source). Returns an error if the frame is too short or the checksum fails.

type FrameCurrent

type FrameCurrent struct {
	RecordIndex int
	Timestamp   time.Time
	Sensors     [4]SensorReading
}

FrameCurrent is a parsed PITEC async "current values" response (52-char frame). It carries fewer fields than a full memory frame.

func ParseFrameCurrent

func ParseFrameCurrent(raw []byte) (*FrameCurrent, error)

ParseFrameCurrent parses the shorter 52-char async frame.

type SensorReading

type SensorReading struct {
	Value int
	Alarm bool // true when flag byte == 'M'
}

SensorReading holds the raw integer value and alarm flag for one sensor channel. Values are in device units (typically 0.1 °C for temperature, 0.1 % for humidity, or raw counts for motor/fan). Divide by 10.0 to get physical SI values for temp/hum.

Jump to

Keyboard shortcuts

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