iStats 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/osx_stats/smc.c +27 -23
- data/ext/osx_stats/smc.h +8 -1
- data/lib/iStats/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d4524a43b23dc2f8c2ec7214001e9f167efdee9
|
4
|
+
data.tar.gz: d73cade1cc7a3cc4004e1fd39f6ac7b2d0e579a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43be157566d393bcaf162bf0f8609e7526f469c814dca9a1aad59453a9c124827b7893117a4f8190acee93cca0cf59038a2709ad49d6eb33293f2b81e23648c4
|
7
|
+
data.tar.gz: d5ddf3e45144678fa0b7f5fd8752ea1741660b3d7416ae521f67e02ba01dd54ebeb49d34cd7c2b3ec8b2eda53ad733facc6b4ca4224a18c979f3e371254102c6
|
data/ext/osx_stats/smc.c
CHANGED
@@ -44,22 +44,14 @@ UInt32 _strtoul(char *str, int size, int base)
|
|
44
44
|
return total;
|
45
45
|
}
|
46
46
|
|
47
|
-
float
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
total += (str[i] & 0xff) >> e;
|
56
|
-
else
|
57
|
-
total += str[i] << (size - 1 - i) * (8 - e);
|
58
|
-
}
|
59
|
-
|
60
|
-
total += (str[size-1] & 0x03) * 0.25;
|
61
|
-
|
62
|
-
return total;
|
47
|
+
float _flttof(unsigned char *str) {
|
48
|
+
fltUnion flt;
|
49
|
+
flt.b[0] = str[0];
|
50
|
+
flt.b[1] = str[1];
|
51
|
+
flt.b[2] = str[2];
|
52
|
+
flt.b[3] = str[3];
|
53
|
+
|
54
|
+
return flt.f;
|
63
55
|
}
|
64
56
|
|
65
57
|
void _ultostr(char *str, UInt32 val)
|
@@ -193,11 +185,25 @@ float SMCGetFanSpeed(int fanNum)
|
|
193
185
|
{
|
194
186
|
SMCVal_t val;
|
195
187
|
kern_return_t result;
|
196
|
-
|
197
188
|
UInt32Char_t key;
|
198
189
|
sprintf(key, SMC_KEY_FAN_SPEED, fanNum);
|
190
|
+
|
199
191
|
result = SMCReadKey(key, &val);
|
200
|
-
|
192
|
+
if (result == kIOReturnSuccess) {
|
193
|
+
// read succeeded - check returned value
|
194
|
+
if (val.dataSize > 0) {
|
195
|
+
if (strcmp(val.dataType, DATATYPE_FPE2) == 0) {
|
196
|
+
// convert fpe2 value to rpm
|
197
|
+
int intValue = (unsigned char)val.bytes[0] * 256 + (unsigned char)val.bytes[1];
|
198
|
+
return intValue / 4.0;
|
199
|
+
} else if (strcmp(val.dataType, DATATYPE_FLT) == 0) {
|
200
|
+
// 2018 models have the ftp type for this key
|
201
|
+
return _flttof((unsigned char *)val.bytes);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
// read failed
|
206
|
+
return 0.0;
|
201
207
|
}
|
202
208
|
|
203
209
|
int SMCGetFanNumber(char *key)
|
@@ -327,10 +333,9 @@ VALUE BATTERY_STATS = Qnil;
|
|
327
333
|
* We never call this, Ruby does.
|
328
334
|
*/
|
329
335
|
void Init_osx_stats() {
|
330
|
-
|
331
336
|
SMC_INFO = rb_define_module("SMC_INFO");
|
332
337
|
rb_define_method(SMC_INFO,"is_key_supported",method_SMCKeySupported,1);
|
333
|
-
|
338
|
+
|
334
339
|
CPU_STATS = rb_define_module("CPU_STATS");
|
335
340
|
rb_define_method(CPU_STATS, "get_cpu_temp", method_get_cpu_temp, 0);
|
336
341
|
|
@@ -347,13 +352,12 @@ void Init_osx_stats() {
|
|
347
352
|
rb_define_method(BATTERY_STATS, "get_battery_charge", method_get_battery_charge, 0);
|
348
353
|
}
|
349
354
|
|
350
|
-
VALUE method_SMCKeySupported(VALUE self, VALUE key)
|
351
|
-
{
|
355
|
+
VALUE method_SMCKeySupported(VALUE self, VALUE key) {
|
352
356
|
char *keyString = RSTRING_PTR(key);
|
353
357
|
SMCOpen();
|
354
358
|
double temp = SMCGetTemperature(keyString);
|
355
359
|
SMCClose();
|
356
|
-
|
360
|
+
|
357
361
|
return rb_float_new(temp);
|
358
362
|
}
|
359
363
|
|
data/ext/osx_stats/smc.h
CHANGED
@@ -36,14 +36,16 @@
|
|
36
36
|
#define DATATYPE_UINT16 "ui16"
|
37
37
|
#define DATATYPE_UINT32 "ui32"
|
38
38
|
#define DATATYPE_SP78 "sp78"
|
39
|
+
#define DATATYPE_FLT "flt "
|
39
40
|
|
40
41
|
// key values
|
41
42
|
#define SMC_KEY_CPU_TEMP "TC0P"
|
42
43
|
#define SMC_KEY_FAN_SPEED "F%dAc"
|
44
|
+
#define SMC_KEY_MIN_FAN_SPEED "F%dMn"
|
45
|
+
#define SMC_KEY_MAX_FAN_SPEED "F%dMx"
|
43
46
|
#define SMC_KEY_FAN_NUM "FNum"
|
44
47
|
#define SMC_KEY_BATTERY_TEMP "TB0T"
|
45
48
|
|
46
|
-
|
47
49
|
typedef struct {
|
48
50
|
char major;
|
49
51
|
char minor;
|
@@ -89,6 +91,11 @@ typedef struct {
|
|
89
91
|
SMCBytes_t bytes;
|
90
92
|
} SMCVal_t;
|
91
93
|
|
94
|
+
typedef union _data {
|
95
|
+
float f;
|
96
|
+
char b[4];
|
97
|
+
} fltUnion;
|
98
|
+
|
92
99
|
// prototypes
|
93
100
|
float SMCGetFanSpeed(int fanNum);
|
94
101
|
int SMCGetFanNumber(char *key);
|
data/lib/iStats/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iStats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris911
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sparkr
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.5.2
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Stats for your mac
|