smc

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Rendered for darwin/amd64

Index

Constants

View Source
const (
	AppleSMC    = "AppleSMC"
	FanNum      = "FNum"
	BattNum     = "BNum"
	BattPwr     = "BATP"
	BattInf     = "BSIn"
	KeyWildcard = "%"

	TempUnit = "°C"
)

Variables

View Source
var AppleCurrent = []SensorStat{
	{Key: "IC0C", Desc: "CPU Core", Platform: ""},
	{Key: "IC1C", Desc: "CPU VccIO", Platform: ""},
	{Key: "IC2C", Desc: "CPU VccSA", Platform: ""},
	{Key: "IC0R", Desc: "CPU High Side", Platform: ""},
	{Key: "IC5R", Desc: "CPU DRAM", Platform: ""},
	{Key: "IC8R", Desc: "CPU PLL", Platform: ""},
	{Key: "IC0G", Desc: "CPU GFX", Platform: ""},
	{Key: "IC0M", Desc: "CPU Memory", Platform: ""},
	{Key: "IG0C", Desc: "GPU Rail", Platform: ""},
	{Key: "IM0C", Desc: "Memory Controller", Platform: ""},
	{Key: "IM0R", Desc: "Memory Rail", Platform: ""},
	{Key: "IN0C", Desc: "MCH", Platform: ""},
	{Key: "ID0R", Desc: "Mainboard S0 Rail (DC In)", Platform: ""},
	{Key: "ID5R", Desc: "Mainboard S5 Rail", Platform: ""},
	{Key: "IO0R", Desc: "Misc. Rail", Platform: ""},
	{Key: "IB0R", Desc: "Battery Rail", Platform: ""},
	{Key: "IPBR", Desc: "Charger BMON", Platform: ""},
	{Key: "I50R", Desc: "5V Low-Side", Platform: ""},
	{Key: "IAPC", Desc: "WLAN Low-Side", Platform: ""},
	{Key: "IBAC", Desc: "Battery", Platform: ""},
	{Key: "IBLC", Desc: "Backlight", Platform: ""},
	{Key: "IDBR", Desc: "Brightness", Platform: ""},
	{Key: "IC0I", Desc: "CPU I/O High Side", Platform: ""},
	{Key: "IC0S", Desc: "CPU SA High Side", Platform: ""},
	{Key: "IC1R", Desc: "CPU High Side From EMC1704", Platform: ""},
	{Key: "IC3C", Desc: "CPU DDR", Platform: ""},
	{Key: "ICMC", Desc: "Camera S2", Platform: ""},
	{Key: "ICS0", Desc: "CPU Core", Platform: ""},
	{Key: "ICS1", Desc: "CPU From CPU IMON", Platform: ""},
	{Key: "ICTR", Desc: "CPU Riser 12V High Side", Platform: ""},
	{Key: "ID1R", Desc: "CPU 1V5 Average", Platform: ""},
	{Key: "ID2E", Desc: "Power Supply 12V Filtered", Platform: ""},
	{Key: "ID2I", Desc: "Power Supply 12V Filter Input S7.8", Platform: ""},
	{Key: "ID2J", Desc: "Power Supply 12V Max Error", Platform: ""},
	{Key: "ID2R", Desc: "Power Supply 12V", Platform: ""},
	{Key: "ID2T", Desc: "Power Supply 12V Trend", Platform: ""},
	{Key: "IG0F", Desc: "GPU FB Input-Side", Platform: ""},
	{Key: "IG0I", Desc: "GPU VDDCI Load-Side", Platform: ""},
	{Key: "IG0R", Desc: "GPU High Side", Platform: ""},
	{Key: "IG0S", Desc: "GPU A VDDCI Low-Side", Platform: ""},
	{Key: "IG0U", Desc: "GPU Uncore High Side", Platform: ""},
	{Key: "IG1A", Desc: "GPU Aux Input-Side", Platform: ""},
	{Key: "IG1C", Desc: "GPU Core Input-Side", Platform: ""},
	{Key: "IG1F", Desc: "GPU FB Input-Side", Platform: ""},
	{Key: "IG1R", Desc: "GFX B Riser 12V High Side", Platform: ""},
	{Key: "IG1S", Desc: "GPU B VDDCI Low-Side", Platform: ""},
	{Key: "IG2C", Desc: "Ext GPU 1.05V", Platform: ""},
	{Key: "IG3C", Desc: "Ext GPU VRAM & I/O", Platform: ""},
	{Key: "IH02", Desc: "HDD 12V Low-Side", Platform: ""},
	{Key: "IH05", Desc: "Drive 0 5V Load-Side", Platform: ""},
	{Key: "IH0R", Desc: "SSD 3V3 Low-Side", Platform: ""},
	{Key: "IH1R", Desc: "SSD 3.3V Low-Side", Platform: ""},
	{Key: "IHDC", Desc: "SSD", Platform: ""},
	{Key: "IHSC", Desc: "Thunderbolt", Platform: ""},
	{Key: "IHSP", Desc: "Thunderbolt", Platform: ""},
	{Key: "II0R", Desc: "TBT IO High Side", Platform: ""},
	{Key: "ILDC", Desc: "LCD Panel", Platform: ""},
	{Key: "IM1C", Desc: "1.8V S3 Low-Side", Platform: ""},
	{Key: "IM2C", Desc: "LPDDR 1.8V", Platform: ""},
	{Key: "IM3C", Desc: "DDR S3", Platform: ""},
	{Key: "IMTR", Desc: "Memory 1V5 High Side", Platform: ""},
	{Key: "IN0R", Desc: "GFX Vcore Average", Platform: ""},
	{Key: "IN1C", Desc: "MCP DDR", Platform: ""},
	{Key: "IN1R", Desc: "PCH Low-Side", Platform: ""},
	{Key: "IO3R", Desc: "Current Other 3.3V High", Platform: ""},
	{Key: "IO5R", Desc: "Battery BMON", Platform: ""},
	{Key: "IODC", Desc: "ODD", Platform: ""},
	{Key: "IP0R", Desc: "Battery Discrete", Platform: ""},
	{Key: "IPB1", Desc: "Discrete Battery", Platform: ""},
	{Key: "IR0C", Desc: "3.3V S0", Platform: ""},
	{Key: "IR1C", Desc: "Other High Side", Platform: ""},
	{Key: "IR1R", Desc: "PCH/GPU/TBT 1.05V High Side", Platform: ""},
	{Key: "IR2C", Desc: "S3 5.0V", Platform: ""},
	{Key: "IR3C", Desc: "3.3V S0", Platform: ""},
	{Key: "IR5C", Desc: "5.0V S0", Platform: ""},
	{Key: "IS2C", Desc: "S2 Camera", Platform: ""},
	{Key: "ISBC", Desc: "PCH Core", Platform: ""},
	{Key: "ISDC", Desc: "SSD", Platform: ""},
	{Key: "ITPC", Desc: "Trackpad Actuator", Platform: ""},
	{Key: "IW0R", Desc: "Wifi Low-Side", Platform: ""},
	{Key: "IZAP", Desc: "WLAN", Platform: ""},
	{Key: "IZBL", Desc: "LCD Backlight", Platform: ""},
	{Key: "IZDM", Desc: "1V5S3", Platform: ""},
	{Key: "IZHD", Desc: "HDD", Platform: ""},
	{Key: "IZOD", Desc: "ODD", Platform: ""},
	{Key: "IZOP", Desc: "Airport", Platform: ""},
	{Key: "Ic0R", Desc: "CSreg", Platform: ""},
	{Key: "IU1R", Desc: "Thunderbolt Left", Platform: ""},
	{Key: "IU2R", Desc: "Thunderbolt Right", Platform: ""},
}
View Source
var AppleFPConv = map[string]FPConv{
	"fp1f": {Div: 32768.0},
	"fp2e": {Div: 16384.0},
	"fp3d": {Div: 8192.0},
	"fp4c": {Div: 4096.0},
	"fp5b": {Div: 2048.0},
	"fp6a": {Div: 1024.0},
	"fp79": {Div: 512.0},
	"fp88": {Div: 256.0},
	"fpa6": {Div: 64.0},
	"fpc4": {Div: 16.0},
	"fpe2": {Div: 4.0},
	"sp1e": {Div: 16384.0, Signed: true},
	"sp2d": {Div: 8192.0, Signed: true},
	"sp3c": {Div: 4096.0, Signed: true},
	"sp4b": {Div: 2048.0, Signed: true},
	"sp5a": {Div: 1024.0, Signed: true},
	"sp69": {Div: 512.0, Signed: true},
	"sp78": {Div: 256.0, Signed: true},
	"sp87": {Div: 128.0, Signed: true},
	"sp96": {Div: 64.0, Signed: true},
	"spa5": {Div: 32.0, Signed: true},
	"spb4": {Div: 16.0, Signed: true},
	"spf0": {Div: 1.0, Signed: true},
}

AppleFPConv maps floating point type conversion constants and signedness property.

View Source
var AppleFans = []SensorStat{
	{Key: "F%dAc", Desc: "Fan %d Current Speed", Platform: ""},
	{Key: "F%dMn", Desc: "Fan %d Minimal Speed", Platform: ""},
	{Key: "F%dMx", Desc: "Fan %d Maximum Speed", Platform: ""},
	{Key: "F%dSf", Desc: "Fan %d Safe Speed", Platform: ""},
	{Key: "F%dTg", Desc: "Fan %d Target Speed", Platform: ""},
}
View Source
var ApplePower = []SensorStat{}/* 129 elements not displayed */
View Source
var AppleTemp = []SensorStat{}/* 1077 elements not displayed */
View Source
var AppleVoltage = []SensorStat{
	{Key: "VCAC", Desc: "CPU IA", Platform: ""},
	{Key: "VCSC", Desc: "CPU System Agent", Platform: ""},
	{Key: "VC%C", Desc: "CPU Core %", Platform: ""},
	{Key: "VCTC", Desc: "GPU Intel Graphics", Platform: ""},
	{Key: "VG%C", Desc: "GPU %", Platform: ""},
	{Key: "VM%R", Desc: "Memory %", Platform: ""},
	{Key: "Vb0R", Desc: "CMOS", Platform: ""},
	{Key: "VD0R", Desc: "DC In", Platform: ""},
	{Key: "VP0R", Desc: "12V Rail", Platform: ""},
	{Key: "Vp0C", Desc: "12V VCC", Platform: ""},
	{Key: "VV2S", Desc: "3V", Platform: ""},
	{Key: "VR3R", Desc: "3.3V", Platform: ""},
	{Key: "VV1S", Desc: "5V", Platform: ""},
	{Key: "VV9S", Desc: "12V", Platform: ""},
	{Key: "VeES", Desc: "PCI 12V", Platform: ""},
	{Key: "VV1R", Desc: "CPU VTT", Platform: ""},
	{Key: "VN1R", Desc: "PCH", Platform: ""},
	{Key: "VN0C", Desc: "MCH", Platform: ""},
	{Key: "VH05", Desc: "Main 5V", Platform: ""},
	{Key: "VV7S", Desc: "Auxiliary 3V", Platform: ""},
	{Key: "VV3S", Desc: "Standby 3V", Platform: ""},
	{Key: "VV8S", Desc: "Standby 5V", Platform: ""},
	{Key: "VBAT", Desc: "Battery", Platform: ""},
	{Key: "V50R", Desc: "5V Low-Side", Platform: ""},
	{Key: "VACC", Desc: "ACC", Platform: ""},
	{Key: "VAPC", Desc: "Wireless", Platform: ""},
	{Key: "VBLC", Desc: "Backlight Output Boosted", Platform: ""},
	{Key: "VC0G", Desc: "CPU AXG Low-Side", Platform: ""},
	{Key: "VC0M", Desc: "CPU Mem Load-Side", Platform: ""},
	{Key: "VC0S", Desc: "CPU VSA Low-Side", Platform: ""},
	{Key: "VC1R", Desc: "CPU High Side From EMC1704", Platform: ""},
	{Key: "VCFR", Desc: "FIVR CPU Supply", Platform: ""},
	{Key: "VCRP", Desc: "CPU Ripple", Platform: ""},
	{Key: "VCS0", Desc: "CPU Core", Platform: ""},
	{Key: "VG0F", Desc: "GPU Frame Buffer Input-Side", Platform: ""},
	{Key: "VG0I", Desc: "GPU VDDCI Load-Side", Platform: ""},
	{Key: "VG0S", Desc: "GPU A VDDCI Low-Side", Platform: ""},
	{Key: "VG0U", Desc: "GPU Uncore High Side", Platform: ""},
	{Key: "VG1F", Desc: "GPU Frame Buffer Input-Side", Platform: ""},
	{Key: "VG1S", Desc: "GPU B VDDCI Low-Side", Platform: ""},
	{Key: "VH0R", Desc: "SSD 3V3 Low-Side", Platform: ""},
	{Key: "VH1R", Desc: "SSD 3.3V Low-Side", Platform: ""},
	{Key: "VL3t", Desc: "LCD IR", Platform: ""},
	{Key: "VM0C", Desc: "1.2V To CPU/MEM Low-Side", Platform: ""},
	{Key: "VM1C", Desc: "1.8V S3 Low-Side", Platform: ""},
	{Key: "VN0R", Desc: "Average GFX Vcore", Platform: ""},
	{Key: "VN1C", Desc: "MCP Memory", Platform: ""},
	{Key: "VODC", Desc: "ODD", Platform: ""},
	{Key: "VP0T", Desc: "PSU", Platform: ""},
	{Key: "VR1R", Desc: "PCH/GPU/TBT Load-Side", Platform: ""},
	{Key: "VSDC", Desc: "SD Card", Platform: ""},
	{Key: "VTPC", Desc: "T101 Accuator", Platform: ""},
	{Key: "VZAP", Desc: "WIFI", Platform: ""},
	{Key: "VZBL", Desc: "Backlight", Platform: ""},
	{Key: "VZDM", Desc: "Memory", Platform: ""},
	{Key: "VZHD", Desc: "SSD", Platform: ""},
	{Key: "VZOD", Desc: "ODD", Platform: ""},
}

Functions

func Close added in v0.17.0

func Close(conn uint)

Close releases an SMC connection returned by Open.

func DecodeValue added in v0.14.1

func DecodeValue(dataType string, bytes gosmc.SMCBytes, size uint32) string

DecodeValue converts raw SMC bytes to a human-readable string based on data type, mirroring smcFanControl's printVal logic. Returns an empty string for unrecognised types.

func EnumerateKeys added in v0.17.0

func EnumerateKeys(conn uint) []string

EnumerateKeys returns every SMC key name over conn without reading values, so a caller sampling a fixed subset can enumerate once and then read only its keys.

func GetAll added in v0.6.1

func GetAll() map[string]any

GetAll returns all SMC sensor readings grouped by category (Battery, Current, Fans, Temperature, Power, Voltage).

func GetBattery added in v0.6.1

func GetBattery() map[string]any

GetBattery returns battery count, status flags, and AC power state read from SMC keys.

func GetCurrent added in v0.6.1

func GetCurrent() map[string]any

GetCurrent returns current sensor readings (in amperes) from SMC.

func GetFans added in v0.6.1

func GetFans() map[string]any

GetFans returns fan count and per-fan speed readings (in RPM) from SMC.

func GetPower added in v0.6.1

func GetPower() map[string]any

GetPower returns power sensor readings (in watts) from SMC.

func GetTemperature added in v0.6.1

func GetTemperature() map[string]any

GetTemperature returns temperature sensor readings (in °C) from SMC, filtered to the detected platform family.

func GetVoltage added in v0.6.1

func GetVoltage() map[string]any

GetVoltage returns voltage sensor readings (in volts) from SMC.

func LookupTempDesc added in v0.16.3

func LookupTempDesc(key, family string) (string, bool)

LookupTempDesc returns the AppleTemp description for a concrete key under family, matching GetTemperature's runtime resolution (last-write-wins on duplicates). The per-family key→description map is built once via MappedTempKeys and cached, so repeated guess-output lookups are O(1).

func MappedTempKeys added in v0.16.3

func MappedTempKeys(family string) map[string]string

MappedTempKeys returns every concrete temperature key in scope for family, wildcards expanded to 0–9, mapped to the description GetTemperature resolves.

func Open added in v0.17.0

func Open() (uint, error)

Open opens an SMC connection for callers issuing many reads over one connection (e.g. repeated sampling); the caller must release it with Close.

func RawKeyToFloat32 added in v0.14.0

func RawKeyToFloat32(k RawKey) (float32, bool)

RawKeyToFloat32 converts a RawKey's raw bytes to a float32 value using the SMC type information stored in the key.

Supported types: flt, ioft, and all fp*/sp* fixed-point variants. The Ta0P sensor is handled specially: it is labelled "flt" by the SMC but actually encodes its value in sp78 (signed 7.8 fixed-point) format.

Returns (value, true) on success and (0, false) for unsupported types, insufficient data, non-finite results, or values outside the plausible temperature window.

Types

type FPConv

type FPConv struct {
	Div    float32
	Signed bool
}

FPConv type used for AppleFPConv map.

type RawKey added in v0.14.0

type RawKey struct {
	Key      string
	DataType string
	DataSize uint32
	Bytes    gosmc.SMCBytes
}

RawKey holds raw SMC key data for reporting.

func GetRaw added in v0.14.0

func GetRaw() []RawKey

GetRaw returns all SMC keys with their raw byte values.

func ReadRawKey added in v0.17.0

func ReadRawKey(conn uint, key string) (RawKey, bool)

ReadRawKey reads a single key's raw value over conn, reporting read success.

type SensorStat

type SensorStat struct {
	Key      string
	Desc     string
	Platform string
}

SensorStat is SMC key to description mapping.

Jump to

Keyboard shortcuts

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