Documentation ¶
Index ¶
- type CRC
- type Cache
- type Command
- type Connection
- func (c *Connection) Close()
- func (c *Connection) Query(id Identifier) (dg *Datagram, err error)
- func (c *Connection) QueryFloat32(id Identifier) (val float32, err error)
- func (c *Connection) QueryUint16(id Identifier) (val uint16, err error)
- func (c *Connection) QueryUint8(id Identifier) (val uint8, err error)
- func (c *Connection) Receive() (dg *Datagram, err error)
- func (c *Connection) Send(rdb *DatagramBuilder) (n int, err error)
- type Datagram
- type DatagramBuilder
- func (rdb *DatagramBuilder) Build(dg *Datagram)
- func (r *DatagramBuilder) Bytes() []byte
- func (rdb *DatagramBuilder) Reset()
- func (r *DatagramBuilder) String() string
- func (rdb *DatagramBuilder) WriteByte(b byte)
- func (rdb *DatagramBuilder) WriteByteUnescapedNoCRC(b byte)
- func (rdb *DatagramBuilder) WriteCRC()
- type DatagramParser
- type Identifier
- type InverterStates
- type ParserState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CRC ¶
type CRC struct {
// contains filtered or unexported fields
}
Checksum for a RCT datagram
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
A datagram cache
type Command ¶
type Command uint8
Command type for the RCT device
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection to a RCT device
func NewConnection ¶
func NewConnection(host string, timeout time.Duration) (conn *Connection, err error)
Creates a new connection to a RCT device at the given address
func (*Connection) Query ¶
func (c *Connection) Query(id Identifier) (dg *Datagram, err error)
Queries the given identifier on the RCT device, returning its value as a datagram
func (*Connection) QueryFloat32 ¶
func (c *Connection) QueryFloat32(id Identifier) (val float32, err error)
Queries the given identifier on the RCT device, returning its value as a float32
func (*Connection) QueryUint16 ¶
func (c *Connection) QueryUint16(id Identifier) (val uint16, err error)
Queries the given identifier on the RCT device, returning its value as a uint16
func (*Connection) QueryUint8 ¶
func (c *Connection) QueryUint8(id Identifier) (val uint8, err error)
Queries the given identifier on the RCT device, returning its value as a uint8
func (*Connection) Receive ¶
func (c *Connection) Receive() (dg *Datagram, err error)
Receives an RCT response via the connection
func (*Connection) Send ¶
func (c *Connection) Send(rdb *DatagramBuilder) (n int, err error)
Sends the given RCT datagram via the connection
type Datagram ¶
type Datagram struct { Cmd Command Id Identifier Data []byte }
A RCT datagram
type DatagramBuilder ¶
type DatagramBuilder struct {
// contains filtered or unexported fields
}
Builds RCT datagrams into an internal buffer, with escaping and CRC correction
func NewDatagramBuilder ¶
func NewDatagramBuilder() (b *DatagramBuilder)
Returns a new DatagramBuilder
func (*DatagramBuilder) Build ¶
func (rdb *DatagramBuilder) Build(dg *Datagram)
Builds a complete datagram into the buffer
func (*DatagramBuilder) Bytes ¶
func (r *DatagramBuilder) Bytes() []byte
Returns the datagram built so far as an array of bytes
func (*DatagramBuilder) Reset ¶
func (rdb *DatagramBuilder) Reset()
Resets the internal buffer and CRC
func (*DatagramBuilder) String ¶
func (r *DatagramBuilder) String() string
Converts the datagram into a string representation for printing
func (*DatagramBuilder) WriteByte ¶
func (rdb *DatagramBuilder) WriteByte(b byte)
Adds a byte to the internal buffer, handling escaping and CRC calculation
func (*DatagramBuilder) WriteByteUnescapedNoCRC ¶
func (rdb *DatagramBuilder) WriteByteUnescapedNoCRC(b byte)
Adds a byte to the internal buffer, without escaping or CRC calculation
func (*DatagramBuilder) WriteCRC ¶
func (rdb *DatagramBuilder) WriteCRC()
Writes the CRC into the current datastream, handling CRC calcuation padding to an even number of bytes
type DatagramParser ¶
type DatagramParser struct {
// contains filtered or unexported fields
}
A parser for RCT datagrams
func (*DatagramParser) Parse ¶
func (p *DatagramParser) Parse() (dg *Datagram, err error)
Parses a given transmission into a datagram
func (*DatagramParser) Reset ¶
func (p *DatagramParser) Reset()
Resets the state, without reallocating the buffer
type Identifier ¶
type Identifier uint32
Identifier type for variables on the RCT device
const ( // power // SolarGenAPowerW Identifier = 0xB5317B78 // float32 SolarGenBPowerW Identifier = 0xAA9AA253 // float32 BatteryPowerW Identifier = 0x400f015b // float32, positive = discharge, negative = charge InverterACPowerW Identifier = 0xDB2D69AE // float32 RealPowerW Identifier = 0x4E49AEC5 // float32 TotalGridPowerW Identifier = 0x91617C58 // float32, positive = taken from grid, negative = feed into grid BatterySoC Identifier = 0x959930BF // float32, range 0 ... 1 // voltage // SolarGenAVoltage Identifier = 0xB298395D // float32 SolarGenBVoltage Identifier = 0x5BB8075A // float32 BatteryVoltage Identifier = 0xA7FA5C5D // float32 // energy // TotalEnergyWh Identifier = 0xB1EF67CE // float32 TotalEnergySolarGenAWh Identifier = 0xFC724A9E // float32 TotalEnergySolarGenBWh Identifier = 0x68EEFD3D // float32 TotalEnergyBattInWh Identifier = 0x5570401B // float32 TotalEnergyBattOutWh Identifier = 0xA9033880 // float32 TotalEnergyHouseholdWh Identifier = 0xEFF4B537 // float32 TotalEnergyGridWh Identifier = 0xA59C8428 // float32 TotalEnergyGridFeedInWh Identifier = 0x44D4C533 // float32 TotalEnergyGridLoadWh Identifier = 0x62FBE7DC // float32 // other // InverterState Identifier = 0x5F33284E // uint8 BatteryCapacityAh Identifier = 0xB57B59BD // float32 BatteryTemperatureC Identifier = 0x902AFAFB // float32 BatterySoCTarget Identifier = 0x8B9FF008 // float32 0 ... 1 BatterySoCTargetHigh Identifier = 0xB84A38AB // float32 0 ... 1 BatterySoCTargetMin Identifier = 0xCE266F0F // float32 0 ... 1 BatterySoCTargetMinIsland Identifier = 0x8EBF9574 // float32 0 ... 1 )
Identifier values for variables on the RCT device
func (Identifier) String ¶
func (i Identifier) String() string
Converts an identifier to a human-readable representation
type InverterStates ¶
type InverterStates uint8
Inverter state type for InverterState responses from the RCT
const ( StateStandby InverterStates = iota StateInitialization StateStandby2 StateEfficiency StateInsulationCheck StateIslandCheck StatePowerCheck StateSymmetry StateRelayTest StateGridPassive StatePrepareBattPassive StateBattPassive StateHWCheck StateFeedIn )
Inverter state values for InverterState responses from the RCT
func (InverterStates) String ¶
func (i InverterStates) String() string
Converts an inverter state value to a human-readable string
type ParserState ¶
type ParserState int
State machine type for the RCT datagram parser
const ( AwaitingStart ParserState = iota AwaitingCmd AwaitingLen AwaitingId0 AwaitingId1 AwaitingId2 AwaitingId3 AwaitingData AwaitingCrc0 AwaitingCrc1 Done )
State machine values for the RCT datagram parser