Skip to content

Commit

Permalink
Apply hacks from issue edorfaus#51
Browse files Browse the repository at this point in the history
  • Loading branch information
hughesr committed Apr 25, 2018
1 parent e77ee06 commit 75aa1e2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
37 changes: 35 additions & 2 deletions libtempered/temper_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ struct temper_type known_temper_types[]={
},
{
.name="TEMPerV1.2 or TEMPer2V1.3",
.vendor_id=0x0c45,
.product_id=0x7401,
.vendor_id=0x413d,
.product_id=0x2107,
.interface_number=1,
.open = tempered_type_hid_open,
.close = tempered_type_hid_close,
Expand Down Expand Up @@ -229,6 +229,39 @@ struct temper_type known_temper_types[]={
}
}
},
(struct temper_subtype*)&(struct temper_subtype_hid){
.base = {
.id = 4,
.name = "TEMPer2V1.3",
.open = tempered_type_hid_subtype_open,
.read_sensors = tempered_type_hid_read_sensors,
.get_sensor_count = tempered_type_hid_get_sensor_count,
.get_temperature = tempered_type_hid_get_temperature,
},
.sensor_group_count = 1,
.sensor_groups = (struct tempered_type_hid_sensor_group[]){
{
.query = {
.length = 9,
.data = (unsigned char[]){ 0, 1, 0x80, 0x33, 1, 0, 0, 0, 0 }
},
.read_sensors = tempered_type_hid_read_sensor_group,
.sensor_count = 2,
.sensors = (struct tempered_type_hid_sensor[]){
{
.get_temperature = tempered_type_hid_get_temperature_fm75,
.temperature_high_byte_offset = 2,
.temperature_low_byte_offset = 3
},
{
.get_temperature = tempered_type_hid_get_temperature_fm75,
.temperature_high_byte_offset = 10,
.temperature_low_byte_offset = 11
}
}
}
}
},
NULL // List terminator for subtypes
}
},
Expand Down
19 changes: 17 additions & 2 deletions libtempered/type_hid/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,29 @@ bool tempered_type_hid_query(
result->length = 0;
return false;
}
result->length = size;
if ( size == 0 )
else if ( size == 0 )
{
tempered_set_error(
device, strdup( "No data was read from the sensor (timeout)." )
);
return false;
}
else
{
result->length = 0;
while (size > 0)
{
result->length += size;
size = hid_read_timeout(
hid_dev, &result->data[result->length], sizeof( result->data - result->length), 200
);
}

if (size > 0)
{
result->length += size;
}
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libtempered/type_hid/fm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool tempered_type_hid_get_temperature_fm75(
// This temperature formula is taken from the FM75 datasheet.
// This is the same as dividing by 256; basically moving the
// decimal point into place.
*tempC = temp * 125.0 / 32000.0;
*tempC = temp / 100.0; // temp * 125.0 / 32000.0;

return true;
}

0 comments on commit 75aa1e2

Please sign in to comment.