beltex / SMCKit

Apple SMC library & tool
https://beltex.github.io/SMCKit
MIT License
475 stars 55 forks source link

Any way to update this code with more sensors? #35

Open larryqiann opened 6 years ago

larryqiann commented 6 years ago

Hi, I'm on a MacBook Pro 13,2 and I'm wondering what the process would be for adding sensors to the list/where to find the four character codes used. Is there any way perhaps to find out? In iStat Menus there are quite a few sensors; I'm not sure how they got it working

Thanks!

perfaram commented 6 years ago

You have a very complete list there : https://gist.github.com/perfaram/f886465e65b7851d17c1ba596ba742eb and there : https://gist.github.com/perfaram/fa3e374fee799ba370123068ccb08867

And the matching types there : https://gist.github.com/perfaram/7e96785609164cf238c6a4414d7b1edd

Data was compiled and formatted by myself, but mostly comes from parhelia.ch (+ a couple of other sources).

larryqiann commented 6 years ago

There are several that aren't in there. Trackpad Actuator (temp) and USBC/MPM In (W) come up off the top of my head.

perfaram commented 6 years ago

Which app reports these ? I'll take care of the rest. (And what is your MacBook model ?)

EDIT : Nevermind, iStats Menu.

perfaram commented 6 years ago

Okay, the FourCC key matching the "Trackpad actuator" is Ts1P. ~Feel free to make a PR adding this one to the known keys.~ I forked SMCKit and added Ts1P here but I'm not sure we should pull this in the main repo. Indeed, as the Ts1P sensor is only present in post-2014 MacBooks (before this the trackpad had no actuator – it just mechanically clicked) it could be misleading to just allow requesting this key on all models. There should be a check or at least a way to check whether the key is supposed to exist...

My suggestion is to keep the current TemperatureSensor struct (maybe add a similar VoltageSensor, etc...), and add a third variable : public let supportedModels: [Model] where Model is simply a typealias (allows for easier, later, expansion) for String, containing the model identifier (eg MacBookPro13_1). Alternatively, an enum could be used for Model, but would require more maintenance and updates.

@beltex, I'm pulling you in the loop since this seems like an important design decision and I don't want to spend time parsing data and inserting it into SMCKit if you don't think it's desirable / appropriate.

As a side note, I think I'm going to create a bot that automatically finds the new keys by reading and parsing the __TEXT segment of various apps that communicate with the SMC 😈 It's not as they could sue me for reverse-engineering data that was itself reverse-engineered, is it ?