Help us shape the future of Go! Take the 2026 Go Developer Survey

smc

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 5 Imported by: 0

README

iSMC-lib

MIT license Go Report Card

About

iSMC is an Apple System Management Controller (SMC) CLI tool that attempts to query SMC for a number of well known keys and determine their type and value, classifying them into temperature, power, current, voltage, fan and battery readouts.

Typically various desktop and server Apple hardware should work and most definitely all Intel-based Mac computers.

I am not maintaining this for any use other than within gotop, and so provide no how-to or help. I recommend using the upstream project if you want something user-friendly.

A word about dependencies

This fork removes all of the command-line code of the upstream project and strips it down to a more lightweight library. Eliminating Cobra alone saves 9,522 LOC and 404Kb of source code. However, Cobra also pulls in a bunch of other libraries, some of which are utterly unnecessary and which are nothing but bloat in a library:

  • github.com/spf13/pflag
  • go.mongodb.org/mongo-driver (!!)

In addition, the CLI imports logrus, which sucks in even more dependencies:

  • github.com/sirupsen/logrus
  • github.com/asaskevich/govalidator
  • github.com/go-openapi/errors
  • github.com/go-openapi/strfmt
  • github.com/konsorten/go-windows-terminal-sequences
  • github.com/mattn/go-runewidth

This illustrates the wise Go philosophy:

A little copying is better than a little dependency.

Documentation

Rendered for darwin/amd64

Index

Constants

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

Variables

View Source
var AppleCurrent = []SensorStat{
	{Key: "IC0C", Desc: "CPU Core"},
	{Key: "IC1C", Desc: "CPU VccIO"},
	{Key: "IC2C", Desc: "CPU VccSA"},
	{Key: "IC0R", Desc: "CPU Rail"},
	{Key: "IC5R", Desc: "CPU DRAM"},
	{Key: "IC8R", Desc: "CPU PLL"},
	{Key: "IC0G", Desc: "CPU GFX"},
	{Key: "IC0M", Desc: "CPU Memory"},
	{Key: "IG0C", Desc: "GPU Rail"},
	{Key: "IM0C", Desc: "Memory Controller"},
	{Key: "IM0R", Desc: "Memory Rail"},
	{Key: "IN0C", Desc: "MCH"},
	{Key: "ID0R", Desc: "Mainboard S0 Rail"},
	{Key: "ID5R", Desc: "Mainboard S5 Rail"},
	{Key: "IO0R", Desc: "Misc. Rail"},
	{Key: "IB0R", Desc: "Battery Rail"},
	{Key: "IPBR", Desc: "Charger BMON"},
	{Key: "I50R", Desc: "5V Low-Side"},
	{Key: "IAPC", Desc: "WLAN Low-Side"},
	{Key: "IBAC", Desc: "Battery"},
	{Key: "IBLC", Desc: "Backlight"},
	{Key: "IC0I", Desc: "CPU I/O High-Side"},
	{Key: "IC0S", Desc: "CPU SA High-Side"},
	{Key: "IC1R", Desc: "CPU High-Side From EMC1704"},
	{Key: "IC3C", Desc: "CPU DDR"},
	{Key: "ICMC", Desc: "Camera S2"},
	{Key: "ICS0", Desc: "CPU Core"},
	{Key: "ICS1", Desc: "CPU From CPU IMON"},
	{Key: "ICTR", Desc: "CPU Riser 12V High-Side"},
	{Key: "ID1R", Desc: "CPU 1V5 Average"},
	{Key: "ID2E", Desc: "Power Supply 12V Filtered"},
	{Key: "ID2I", Desc: "Power Supply 12V Filter Input S7.8"},
	{Key: "ID2J", Desc: "Power Supply 12V Max Error"},
	{Key: "ID2R", Desc: "Power Supply 12V"},
	{Key: "ID2T", Desc: "Power Supply 12V Trend"},
	{Key: "IG0F", Desc: "GPU FB Input-Side"},
	{Key: "IG0I", Desc: "GPU VDDCI Load-Side"},
	{Key: "IG0R", Desc: "GPU High-Side Average"},
	{Key: "IG0S", Desc: "GPU A VDDCI Low-Side"},
	{Key: "IG0U", Desc: "GPU Uncore High-Side"},
	{Key: "IG1A", Desc: "GPU Aux Input-Side"},
	{Key: "IG1C", Desc: "GPU Core Input-Side"},
	{Key: "IG1F", Desc: "GPU FB Input-Side"},
	{Key: "IG1R", Desc: "GFX B Riser 12V High-Side"},
	{Key: "IG1S", Desc: "GPU B VDDCI Low-Side"},
	{Key: "IG2C", Desc: "Ext GPU 1.05V"},
	{Key: "IG3C", Desc: "Ext GPU VRAM & I/O"},
	{Key: "IH02", Desc: "HDD 12V Low-Side"},
	{Key: "IH05", Desc: "Drive 0 5V Load-Side"},
	{Key: "IH0R", Desc: "SSD 3V3 Low-Side"},
	{Key: "IH1R", Desc: "SSD 3.3V Low-Side"},
	{Key: "IHDC", Desc: "SSD"},
	{Key: "IHSC", Desc: "Thunderbolt"},
	{Key: "IHSP", Desc: "Thunderbolt"},
	{Key: "II0R", Desc: "TBT IO High-Side"},
	{Key: "ILDC", Desc: "LCD Panel"},
	{Key: "IM1C", Desc: "1.8V S3 Low-Side"},
	{Key: "IM2C", Desc: "LPDDR 1.8V"},
	{Key: "IM3C", Desc: "DDR S3"},
	{Key: "IMTR", Desc: "Memory 1V5 High-Side"},
	{Key: "IN0R", Desc: "GFX Vcore Average"},
	{Key: "IN1C", Desc: "MCP DDR"},
	{Key: "IN1R", Desc: "PCH Low-Side"},
	{Key: "IO3R", Desc: "Current Other 3.3V High"},
	{Key: "IO5R", Desc: "Battery BMON"},
	{Key: "IODC", Desc: "ODD"},
	{Key: "IP0R", Desc: "Battery Discrete"},
	{Key: "IPB1", Desc: "Discrete Battery"},
	{Key: "IR0C", Desc: "3.3V S0"},
	{Key: "IR1C", Desc: "Other High-Side"},
	{Key: "IR1R", Desc: "PCH/GPU/TBT 1.05V High-Side"},
	{Key: "IR2C", Desc: "S3 5.0V"},
	{Key: "IR3C", Desc: "3.3V S0"},
	{Key: "IR5C", Desc: "5.0V S0"},
	{Key: "IS2C", Desc: "S2 Camera"},
	{Key: "ISBC", Desc: "PCH Core"},
	{Key: "ISDC", Desc: "SSD"},
	{Key: "ITPC", Desc: "Trackpad Actuator"},
	{Key: "IW0R", Desc: "Wifi Low-Side"},
	{Key: "IZAP", Desc: "WLAN"},
	{Key: "IZBL", Desc: "LCD Backlight"},
	{Key: "IZDM", Desc: "1V5S3"},
	{Key: "IZHD", Desc: "HDD"},
	{Key: "IZOD", Desc: "ODD"},
	{Key: "IZOP", Desc: "Airport"},
	{Key: "Ic0R", Desc: "CSreg"},
}
View Source
var AppleFPConv = map[string]FPConv{
	"fp1f": FPConv{Div: 32768.0},
	"fp2e": FPConv{Div: 16384.0},
	"fp3d": FPConv{Div: 8192.0},
	"fp4c": FPConv{Div: 4096.0},
	"fp5b": FPConv{Div: 2048.0},
	"fp6a": FPConv{Div: 1024.0},
	"fp79": FPConv{Div: 512.0},
	"fp88": FPConv{Div: 256.0},
	"fpa6": FPConv{Div: 64.0},
	"fpc4": FPConv{Div: 16.0},
	"fpe2": FPConv{Div: 4.0},
	"sp1e": FPConv{Div: 16384.0, Signed: true},
	"sp2d": FPConv{Div: 8192.0, Signed: true},
	"sp3c": FPConv{Div: 4096.0, Signed: true},
	"sp4b": FPConv{Div: 2048.0, Signed: true},
	"sp5a": FPConv{Div: 1024.0, Signed: true},
	"sp69": FPConv{Div: 512.0, Signed: true},
	"sp78": FPConv{Div: 256.0, Signed: true},
	"sp87": FPConv{Div: 128.0, Signed: true},
	"sp96": FPConv{Div: 64.0, Signed: true},
	"spa5": FPConv{Div: 32.0, Signed: true},
	"spb4": FPConv{Div: 16.0, Signed: true},
	"spf0": FPConv{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"},
	{Key: "F%dMn", Desc: "Fan %d Minimal Speed"},
	{Key: "F%dMx", Desc: "Fan %d Maximum Speed"},
	{Key: "F%dSf", Desc: "Fan %d Safe Speed"},
	{Key: "F%dTg", Desc: "Fan %d Target Speed"},
}
View Source
var ApplePower = []SensorStat{}/* 134 elements not displayed */
View Source
var AppleTemp = []SensorStat{}/* 222 elements not displayed */
View Source
var AppleVoltage = []SensorStat{
	{Key: "VC0C", Desc: "CPU Core 1"},
	{Key: "VC1C", Desc: "CPU Core 2"},
	{Key: "VC2C", Desc: "CPU Core 3"},
	{Key: "VC3C", Desc: "CPU Core 4"},
	{Key: "VC4C", Desc: "CPU Core 5"},
	{Key: "VC5C", Desc: "CPU Core 6"},
	{Key: "VC6C", Desc: "CPU Core 7"},
	{Key: "VC7C", Desc: "CPU Core 8"},
	{Key: "VV1R", Desc: "CPU VTT"},
	{Key: "VG0C", Desc: "GPU Core"},
	{Key: "VM0R", Desc: "Memory"},
	{Key: "VN1R", Desc: "PCH"},
	{Key: "VN0C", Desc: "MCH"},
	{Key: "VD0R", Desc: "Mainboard S0 Rail"},
	{Key: "VD5R", Desc: "Mainboard S5 Rail"},
	{Key: "VP0R", Desc: "12V Rail"},
	{Key: "Vp0C", Desc: "12V Vcc"},
	{Key: "VV2S", Desc: "Main 3V"},
	{Key: "VR3R", Desc: "Main 3.3V"},
	{Key: "VV1S", Desc: "Main 5V"},
	{Key: "VH05", Desc: "Main 5V"},
	{Key: "VV9S", Desc: "Main 12V"},
	{Key: "VD2R", Desc: "Main 12V"},
	{Key: "VV7S", Desc: "Auxiliary 3V"},
	{Key: "VV3S", Desc: "Standby 3V"},
	{Key: "VV8S", Desc: "Standby 5V"},
	{Key: "VeES", Desc: "PCIe 12V"},
	{Key: "VBAT", Desc: "Battery"},
	{Key: "Vb0R", Desc: "CMOS Battery"},
	{Key: "V50R", Desc: "5V Low-Side"},
	{Key: "VACC", Desc: "ACC"},
	{Key: "VAPC", Desc: "Wireless"},
	{Key: "VBLC", Desc: "Backlight Output Boosted"},
	{Key: "VC0G", Desc: "CPU AXG Low-Side"},
	{Key: "VC0M", Desc: "CPU Mem Load-Side"},
	{Key: "VC0S", Desc: "CPU VSA Low-Side"},
	{Key: "VC1R", Desc: "CPU High Side From EMC1704"},
	{Key: "VCFR", Desc: "FIVR CPU Supply"},
	{Key: "VCRC", Desc: "CPU Ripple"},
	{Key: "VCRP", Desc: "CPU Ripple"},
	{Key: "VCS0", Desc: "CPU Core"},
	{Key: "VG0F", Desc: "GPU Frame Buffer Input-Side"},
	{Key: "VG0I", Desc: "GPU VDDCI Load-Side"},
	{Key: "VG0S", Desc: "GPU A VDDCI Low-Side"},
	{Key: "VG0U", Desc: "GPU Uncore High-Side"},
	{Key: "VG1C", Desc: "GPU B Core Low-Side"},
	{Key: "VG1F", Desc: "GPU Frame Buffer Input-Side"},
	{Key: "VG1S", Desc: "GPU B VDDCI Low-Side"},
	{Key: "VH0R", Desc: "SSD 3V3 Low-Side"},
	{Key: "VH1R", Desc: "SSD 3.3V Low-Side"},
	{Key: "VL3t", Desc: "LCD IR"},
	{Key: "VM0C", Desc: "1.2V To CPU/MEM Low-Side"},
	{Key: "VM1C", Desc: "1.8V S3 Low-Side"},
	{Key: "VN0R", Desc: "Average GFX Vcore"},
	{Key: "VN1C", Desc: "MCP Memory"},
	{Key: "VODC", Desc: "ODD"},
	{Key: "VP0T", Desc: "PSU"},
	{Key: "VR1R", Desc: "PCH/GPU/TBT Load-Side"},
	{Key: "VSDC", Desc: "SD Card"},
	{Key: "VTPC", Desc: "T101 Accuator"},
	{Key: "VZAP", Desc: "WIFI"},
	{Key: "VZBL", Desc: "Backlight(VZBL)"},
	{Key: "VZDM", Desc: "Memory"},
	{Key: "VZHD", Desc: "SSD"},
	{Key: "VZOD", Desc: "ODD"},
}

Functions

func GetBatt

func GetBatt() (uint32, uint32, bool, error)

GetBatt prints detected battery results TODO: Needs battery info decoding (hex_ SMC key type)

func GetCurrent

func GetCurrent(values map[string]float32) error

GetCurrent prints detected current sensor results Current: A

func GetFans

func GetFans(values map[string]float32) error

GetFans prints detected fan results

func GetPower

func GetPower(values map[string]float32) error

GetPower prints detected power sensor results Power: W

func GetTemp

func GetTemp(values map[string]float32) error

PrintTemp prints detected temperature sensor results Temperature: °C

func GetVoltage

func GetVoltage(values map[string]float32) error

GetVoltage prints detected voltage sensor results Voltage: V

Types

type FPConv

type FPConv struct {
	Div    float32
	Signed bool
}

FPConv type used for AppleFPConv map

type SensorStat

type SensorStat struct {
	Key  string // SMC key name
	Desc string // SMC key description
}

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