beltex / SMCKit

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

Xcode 8.1 - Can't return anything with SMCKit #28

Closed PKBeam closed 7 years ago

PKBeam commented 7 years ago

Running this code (on MacBookPro13,2 with 10.12.1):

import Cocoa
import SMCKit

do {
    let fans = try SMCKit.fanCount()
    print(fans)
} catch {
    print("Error")
}

Prints "Error". It happens with fan speed, fan names, etc. What am I doing wrong?

beltex commented 7 years ago

Hello @PKBeam!

open() must be called first to get a connection to the SMC driver (and make sure to call close() when your done!). See SMCKitTool for an example. README/docs should be updated to make that clear, since a number of folks have asked about this, (so my bad!).

Hope that helps!

P.S New Macbook? Nice! :)

PKBeam commented 7 years ago

Ah, I see. Thanks.