Skip to content

Commit

Permalink
Identify unhandled dsme message types in human readable form
Browse files Browse the repository at this point in the history
Running mce in debug verbosity causes unhandled dsme messages to be
reported. Evaluating what those are and should they be handled takes
time as libdsme & co make the raw numeric values obscure on purpose.

As the existing values are carved in stone, we can use custom lookup
function to print human readable message type names too.
  • Loading branch information
spiiroin committed Feb 12, 2015
1 parent b007450 commit 5f4c0b5
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion mce-dsme.c
Expand Up @@ -88,6 +88,7 @@ static void mce_dsme_schedule_state_report(void);
static bool mce_dsme_shutting_down(void);
static system_state_t mce_dsme_normalise_system_state(dsme_state_t dsmestate);

static const char *mce_dsme_msg_type_repr(int type);
static gboolean mce_dsme_iowatch_cb(GIOChannel *source, GIOCondition condition, gpointer data);
static gboolean mce_dsme_init_done_cb(DBusMessage *const msg);
static void mce_dsme_charger_state_cb(gconstpointer const data);
Expand Down Expand Up @@ -414,6 +415,54 @@ static system_state_t mce_dsme_normalise_system_state(dsme_state_t dsmestate)
return state;
}

/** Lookup dsme message type name by id
*
* Note: This is ugly hack, but the way these are defined in libdsme and
* libiphb makes it difficult to gauge the type without involving the type
* conversion macros - and those we *really* do not want to do use just to
* report unhandled stuff in debug verbosity.
*
* @param type private type id from dsme message header
*
* @return human readable name of the type
*/
static const char *mce_dsme_msg_type_repr(int type)
{
#define X(name,value) if( type == value ) return #name

X(CLOSE, 0x00000001);
X(STATE_CHANGE_IND, 0x00000301);
X(STATE_QUERY, 0x00000302);
X(SAVE_DATA_IND, 0x00000304);
X(POWERUP_REQ, 0x00000305);
X(SHUTDOWN_REQ, 0x00000306);
X(SET_ALARM_STATE, 0x00000307);
X(REBOOT_REQ, 0x00000308);
X(STATE_REQ_DENIED_IND, 0x00000309);
X(THERMAL_SHUTDOWN_IND, 0x00000310);
X(SET_CHARGER_STATE, 0x00000311);
X(SET_THERMAL_STATE, 0x00000312);
X(SET_EMERGENCY_CALL_STATE, 0x00000313);
X(SET_BATTERY_STATE, 0x00000314);
X(BATTERY_EMPTY_IND, 0x00000315);
X(PROCESSWD_CREATE, 0x00000500);
X(PROCESSWD_DELETE, 0x00000501);
X(PROCESSWD_CLEAR, 0x00000502);
X(PROCESSWD_SET_INTERVAL, 0x00000503);
X(PROCESSWD_PING, 0x00000504);
X(PROCESSWD_PONG, 0x00000504);
X(PROCESSWD_MANUAL_PING, 0x00000505);
X(WAIT, 0x00000600);
X(WAKEUP, 0x00000601);
X(GET_VERSION, 0x00001100);
X(DSME_VERSION, 0x00001101);
X(SET_TA_TEST_MODE, 0x00001102);

#undef X

return "UNKNOWN";
}

/**
* Callback for pending I/O from dsmesock
*
Expand Down Expand Up @@ -494,7 +543,8 @@ static gboolean mce_dsme_iowatch_cb(GIOChannel *source,
USE_INDATA, CACHE_INDATA);
}
else {
mce_log(LL_DEBUG, "Unknown message type (%x) received from DSME!",
mce_log(LL_DEBUG, "Unhandled message type %s (0x%x) received from DSME",
mce_dsme_msg_type_repr(msg->type_),
msg->type_); /* <- unholy access of a private member */
}

Expand Down

0 comments on commit 5f4c0b5

Please sign in to comment.