Skip to content

Commit

Permalink
Merge pull request #65 from plundstr/plu
Browse files Browse the repository at this point in the history
Added temperature and sensor name to logs. Fixes JB#17611
  • Loading branch information
Pekka Lundstrom committed Mar 26, 2014
2 parents 731931e + 6bde814 commit 366043f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,5 +1,5 @@
# Package name and version
AC_INIT(dsme, 0.66.0)
AC_INIT(dsme, 0.66.1)

AM_INIT_AUTOMAKE

Expand Down
7 changes: 4 additions & 3 deletions modules/bootreasonlogger.c
Expand Up @@ -258,6 +258,7 @@ DSME_HANDLER(DSM_MSGTYPE_SET_THERMAL_STATUS, conn, msg)
{
bool overheated = false;
const char *temp_status;
char str[80];

if (msg->status == DSM_THERMAL_STATUS_OVERHEATED) {
temp_status = "overheated";
Expand All @@ -268,9 +269,9 @@ DSME_HANDLER(DSM_MSGTYPE_SET_THERMAL_STATUS, conn, msg)
temp_status = "normal";

dsme_log(LOG_DEBUG,
PFIX"temp state: %s received", temp_status);

write_log("Received: device temp", temp_status);
PFIX"temp (%s) state: %s (%dC)", msg->sensor_name, temp_status, msg->temperature);
snprintf(str, sizeof(str), "device (%s) temp status %s (%dC)", msg->sensor_name, temp_status, msg->temperature);
write_log("Received:", str);
if (overheated)
saved_shutdown_reason = SD_DEVICE_OVERHEAT;
else // Device is no more overheated. Shutdown won't happen
Expand Down
26 changes: 15 additions & 11 deletions modules/thermalmanager.c
Expand Up @@ -51,7 +51,7 @@

#include <glib.h>
#include <stdlib.h>

#include <string.h>

static void receive_temperature_response(thermal_object_t* thermal_object,
int temperature);
Expand Down Expand Up @@ -123,17 +123,21 @@ static THERMAL_STATUS worst_current_thermal_object_status(void)
return overall_status;
}

static void send_thermal_status(dsme_thermal_status_t status)
static void send_thermal_status(dsme_thermal_status_t status,
const char *sensor_name, int temperature)
{
DSM_MSGTYPE_SET_THERMAL_STATUS msg =
DSME_MSG_INIT(DSM_MSGTYPE_SET_THERMAL_STATUS);

msg.status = status;
msg.temperature = temperature;
strncpy(msg.sensor_name, sensor_name, DSM_TEMP_SENSOR_MAX_NAME_LEN);
msg.sensor_name[DSM_TEMP_SENSOR_MAX_NAME_LEN - 1] = 0;

broadcast_internally(&msg);
}

static void send_thermal_indication(void)
static void send_thermal_indication(const char *sensor_name, int temperature)
{
/* first send an indication to D-Bus */
{
Expand All @@ -143,25 +147,25 @@ static void send_thermal_indication(void)
thermalmanager_state_change_ind);
dsme_dbus_message_append_string(sig, current_status_name());
dsme_dbus_signal_emit(sig);
dsme_log(LOG_NOTICE, "thermalmanager: Device thermal status: %s", current_status_name());
dsme_log(LOG_NOTICE, "thermalmanager: Device (%s) thermal status: %s (%dC)", sensor_name, current_status_name(), temperature);
}

/* then broadcast an indication internally */
{
static bool temp_warning_sent = false;

if (current_status == THERMAL_STATUS_FATAL) {
send_thermal_status(DSM_THERMAL_STATUS_OVERHEATED);
send_thermal_status(DSM_THERMAL_STATUS_OVERHEATED, sensor_name, temperature);
temp_warning_sent = true;
dsme_log(LOG_CRIT, "thermalmanager: Device overheated");
dsme_log(LOG_CRIT, "thermalmanager: Device (%s) overheated (%dC)", sensor_name, temperature);
} else if (current_status == THERMAL_STATUS_LOW) {
send_thermal_status(DSM_THERMAL_STATUS_LOWTEMP);
send_thermal_status(DSM_THERMAL_STATUS_LOWTEMP, sensor_name, temperature);
temp_warning_sent = true;
dsme_log(LOG_WARNING, "thermalmanager: Device temperature low");
dsme_log(LOG_WARNING, "thermalmanager: Device (%s) temperature low (%dC)", sensor_name, temperature);
} else if (temp_warning_sent) {
send_thermal_status(DSM_THERMAL_STATUS_NORMAL);
send_thermal_status(DSM_THERMAL_STATUS_NORMAL, sensor_name, temperature);
temp_warning_sent = false;
dsme_log(LOG_NOTICE, "thermalmanager: Device temperature back to normal");
dsme_log(LOG_NOTICE, "thermalmanager: Device (%s) temperature back to normal (%dC)", sensor_name, temperature);
}
}
}
Expand Down Expand Up @@ -253,7 +257,7 @@ static void receive_temperature_response(thermal_object_t* thermal_object,

if (current_status != previously_indicated_status) {
/* global thermal status has changed; send indication */
send_thermal_indication();
send_thermal_indication(thermal_object->conf->name, temperature);
}
}

Expand Down
4 changes: 2 additions & 2 deletions rpm/dsme.spec
@@ -1,6 +1,6 @@
Name: dsme
Summary: Device State Management Entity
Version: 0.66.0
Version: 0.66.1
Release: 0
Group: System/System Control
License: LGPLv2+
Expand All @@ -18,7 +18,7 @@ BuildRequires: pkgconfig(glib-2.0) >= 2.32.0
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(libiphb) >= 1.2.0
BuildRequires: pkgconfig(dsme) >= 0.62.0
BuildRequires: pkgconfig(dsme) >= 0.63.0
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(mce) >= 1.12.3
BuildRequires: pkgconfig(libngf0)
Expand Down

0 comments on commit 366043f

Please sign in to comment.