Documentation
¶
Index ¶
- Variables
- func DecodeFloat(dataType DataType, bytes []byte) (float64, error)
- func DecodeInt(dataType DataType, bytes []byte) (int64, error)
- func DecodeUint(dataType DataType, bytes []byte) (uint64, error)
- func EncodeFloat(dataType DataType, size int, value float64) ([]byte, error)
- func EncodeInt(dataType DataType, size int, value int64) ([]byte, error)
- func EncodeUint(dataType DataType, size int, value uint64) ([]byte, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) KeyAt(index uint32) (string, error)
- func (c *Client) KeyCount() (uint32, error)
- func (c *Client) KeyInfo(key string) (KeyInfo, error)
- func (c *Client) Keys() ([]string, error)
- func (c *Client) Open() error
- func (c *Client) Read(key string) (Value, error)
- func (c *Client) ReadAll() ([]Value, error)
- func (c *Client) WriteBytes(key string, data []byte) error
- func (c *Client) WriteFloat32(key string, value float32) error
- func (c *Client) WriteFloat64(key string, value float64) error
- func (c *Client) WriteInt8(key string, value int8) error
- func (c *Client) WriteInt16(key string, value int16) error
- func (c *Client) WriteInt64(key string, value int64) error
- func (c *Client) WriteUint8(key string, value uint8) error
- func (c *Client) WriteUint16(key string, value uint16) error
- func (c *Client) WriteUint32(key string, value uint32) error
- func (c *Client) WriteUint64(key string, value uint64) error
- type DataType
- type DisplayOption
- type DisplayOptions
- type IOReturnError
- type KeyInfo
- type Value
- func (v Value) Decoded() (value any, ok bool, err error)
- func (v Value) Display(opts ...DisplayOption) string
- func (v Value) Float64() (float64, error)
- func (v Value) Hex() string
- func (v Value) HexBytes() string
- func (v Value) Int64() (int64, error)
- func (v Value) StringValue() (string, bool)
- func (v Value) Uint64() (uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidKey = errors.New("smc key must be exactly 4 bytes") ErrInvalidData = errors.New("invalid smc data") ErrNoData = errors.New("smc key has no data") ErrClosed = errors.New("smc client is not open") ErrUnsupported = errors.New("operation is not supported") ErrTypeMismatch = errors.New("value is incompatible with smc data type") ErrValueOutOfRange = errors.New("value is out of range") )
Functions ¶
func DecodeFloat ¶
DecodeFloat decodes flt, fixed-point, and {pwm values.
func DecodeUint ¶
DecodeUint decodes ui8, ui16, ui32, and ui64 values.
func EncodeFloat ¶
EncodeFloat encodes flt, fixed-point, and {pwm values.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an open Apple SMC connection plus a Go-side key-info cache.
func New ¶
func New() *Client
New creates a client. Call Open before using it, or use Open directly.
func (*Client) KeyInfo ¶
KeyInfo returns cached metadata for key, fetching it from the SMC if needed.
func (*Client) WriteBytes ¶
WriteBytes writes raw bytes to key after validating the key's expected size.
func (*Client) WriteFloat32 ¶
WriteFloat32 writes a float to an flt, fixed-point, or pwm SMC key.
func (*Client) WriteFloat64 ¶
WriteFloat64 writes a float to an flt, fixed-point, or pwm SMC key.
func (*Client) WriteInt16 ¶
WriteInt16 writes a signed integer to a si16 SMC key.
func (*Client) WriteInt64 ¶
WriteInt64 writes a signed integer to a signed SMC integer key.
func (*Client) WriteUint8 ¶
WriteUint8 writes an unsigned integer to a ui8 SMC key.
func (*Client) WriteUint16 ¶
WriteUint16 writes an unsigned integer to a ui16 SMC key.
func (*Client) WriteUint32 ¶
WriteUint32 writes an unsigned integer to a ui32 SMC key.
type DataType ¶
type DataType string
DataType is the four-byte SMC data type attached to a key.
const ( TypeFloat32 DataType = "flt " TypeFP1F DataType = "fp1f" TypeFP4C DataType = "fp4c" TypeFP5B DataType = "fp5b" TypeFP6A DataType = "fp6a" TypeFP79 DataType = "fp79" TypeFP88 DataType = "fp88" TypeFPA6 DataType = "fpa6" TypeFPC4 DataType = "fpc4" TypeFPE2 DataType = "fpe2" TypeSP1E DataType = "sp1e" TypeSP3C DataType = "sp3c" TypeSP4B DataType = "sp4b" TypeSP5A DataType = "sp5a" TypeSP69 DataType = "sp69" TypeSP78 DataType = "sp78" TypeSP87 DataType = "sp87" TypeSP96 DataType = "sp96" TypeSPB4 DataType = "spb4" TypeSPF0 DataType = "spf0" TypeUInt8 DataType = "ui8 " TypeUInt16 DataType = "ui16" TypeUInt32 DataType = "ui32" TypeUInt64 DataType = "ui64" TypeSInt8 DataType = "si8 " TypeSInt16 DataType = "si16" TypeSInt32 DataType = "si32" TypeSInt64 DataType = "si64" TypePWM DataType = "{pwm" )
func (DataType) IsFixedPoint ¶
func (DataType) IsSignedInteger ¶
func (DataType) IsUnsignedInteger ¶
type DisplayOption ¶
type DisplayOption func(*DisplayOptions)
DisplayOption mutates DisplayOptions.
func WithFloatDigits ¶
func WithFloatDigits(n int) DisplayOption
WithFloatDigits limits float output to at most n fractional digits. Use -1 to keep the default shortest representation.
func WithHexLimit ¶
func WithHexLimit(n int) DisplayOption
WithHexLimit truncates fallback hex displays to at most n characters.
func WithStringLimit ¶
func WithStringLimit(n int) DisplayOption
WithStringLimit truncates printable string values to at most n characters.
type DisplayOptions ¶
DisplayOptions controls how Value.Display renders human-readable output.
type IOReturnError ¶
IOReturnError wraps a non-success kern_return_t from an IOKit SMC call.
func (IOReturnError) Error ¶
func (e IOReturnError) Error() string
type Value ¶
Value is a raw SMC value plus the data type needed to decode it.
func (Value) Display ¶
func (v Value) Display(opts ...DisplayOption) string
Display returns a human-readable decoded value when possible, then falls back to hex.
func (Value) StringValue ¶
StringValue returns printable ASCII when all bytes are printable, otherwise ok=false.