Skip to content
This repository was archived by the owner on Oct 12, 2018. It is now read-only.

Commit 23758d6

Browse files
committed
Insane sensors values hotfix
1 parent 1687d61 commit 23758d6

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

HWMonitor/HWMonitorEngine.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ - (void)updateSmcSensor:(HWMonitorSensor*)sensor addToArray:(NSMutableArray*)upd
730730
if (![sensor genericDevice]) {
731731
SMCVal_t val;
732732

733-
if (kIOReturnSuccess == SMCReadKey(_connection, sensor.key, &val)) {
733+
if (kIOReturnSuccess == SMCReadKey(_connection, sensor.rawKey, &val)) {
734734

735735
//[sensor setType:[NSString stringWithCString:val.dataType encoding:NSASCIIStringEncoding]];
736736
[sensor setData:[NSData dataWithBytes:val.bytes length:val.dataSize]];

HWMonitor/HWMonitorSensor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,22 @@ typedef enum {
5959

6060
@interface HWMonitorSensor : NSObject
6161
{
62-
const char* _key;
62+
char _rawKey[5];
6363
NSNumber *_rawValue;
6464
NSMutableDictionary *_localizationCache;
6565
}
6666

6767
@property (nonatomic, strong) HWMonitorEngine* engine;
6868

6969
@property (nonatomic, strong) NSString* name;
70-
@property (readonly) const char * key;
7170
@property (nonatomic, strong) NSString* type;
7271
@property (nonatomic, assign) NSUInteger group;
7372
@property (nonatomic, strong) NSString* title;
7473
@property (nonatomic, strong) NSData* data;
7574
@property (nonatomic, strong) id genericDevice;
7675

7776
@property (nonatomic, assign) HWSensorLevel level;
77+
@property (readonly) const char *rawKey;
7878
@property (readonly) NSNumber* rawValue;
7979
@property (readonly) NSString* stringValue;
8080
@property (readonly) NSInteger intValue;

HWMonitor/HWMonitorSensor.m

+7-1
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,20 @@ + (HWMonitorSensor*)sensor
178178
return nil;
179179
}
180180

181+
181182
-(void)setName:(NSString *)name
182183
{
183184
if (name != _name) {
184185
_name = name;
185-
_key = [name cStringUsingEncoding:NSASCIIStringEncoding];
186+
[name getCString:_rawKey maxLength:5 encoding:NSASCIIStringEncoding];
186187
}
187188
}
188189

190+
-(const char *)rawKey
191+
{
192+
return _rawKey;
193+
}
194+
189195
- (void)setType:(NSString *)newType
190196
{
191197
if (!_type || ![_type isEqualToString:newType]) {

0 commit comments

Comments
 (0)