qcdm: add bits for getting/setting the log mask
No code to actually start logging yet, just sets the mask.
This commit is contained in:
@@ -992,6 +992,108 @@ qcdm_cmd_hdr_subsys_state_info_result (const char *buf, gsize len, GError **erro
|
|||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
gsize
|
||||||
|
qcdm_cmd_ext_logmask_new (char *buf,
|
||||||
|
gsize len,
|
||||||
|
GSList *items,
|
||||||
|
guint16 maxlog,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
char cmdbuf[sizeof (DMCmdExtLogMask) + 2];
|
||||||
|
DMCmdExtLogMask *cmd = (DMCmdExtLogMask *) &cmdbuf[0];
|
||||||
|
GSList *iter;
|
||||||
|
guint16 highest = 0;
|
||||||
|
gsize total = 3;
|
||||||
|
|
||||||
|
g_return_val_if_fail (buf != NULL, 0);
|
||||||
|
g_return_val_if_fail (len >= sizeof (*cmd) + DIAG_TRAILER_LEN, 0);
|
||||||
|
|
||||||
|
memset (cmd, 0, sizeof (*cmd));
|
||||||
|
cmd->code = DIAG_CMD_EXT_LOGMASK;
|
||||||
|
|
||||||
|
for (iter = items; iter; iter = g_slist_next (iter)) {
|
||||||
|
guint32 item = GPOINTER_TO_UINT (iter->data);
|
||||||
|
|
||||||
|
g_warn_if_fail (item > 0);
|
||||||
|
g_warn_if_fail (item < 4095);
|
||||||
|
cmd->mask[item / 8] |= 1 << item % 8;
|
||||||
|
|
||||||
|
if (item > highest)
|
||||||
|
highest = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_return_val_if_fail (highest <= maxlog, 0);
|
||||||
|
cmd->len = GUINT16_TO_LE (maxlog);
|
||||||
|
total += maxlog / 8;
|
||||||
|
if (maxlog && maxlog % 8)
|
||||||
|
total++;
|
||||||
|
|
||||||
|
return dm_encapsulate_buffer (cmdbuf, total, sizeof (cmdbuf), buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
QCDMResult *
|
||||||
|
qcdm_cmd_ext_logmask_result (const char *buf,
|
||||||
|
gsize len,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
QCDMResult *result = NULL;
|
||||||
|
DMCmdExtLogMask *rsp = (DMCmdExtLogMask *) buf;
|
||||||
|
guint32 masklen = 0, maxlog = 0;
|
||||||
|
gsize minlen = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (buf != NULL, NULL);
|
||||||
|
|
||||||
|
/* Ensure size is at least enough for the command header */
|
||||||
|
if (len < 1) {
|
||||||
|
g_set_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_LENGTH,
|
||||||
|
"DM command %d response not long enough (got %zu, expected "
|
||||||
|
"at least %d).", DIAG_CMD_EXT_LOGMASK, len, 3);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Result of a 'set' operation will be only 1 byte in size; result of
|
||||||
|
* a 'get' operation (ie setting len to 0x0000 in the request) will be
|
||||||
|
* the size of the header (3) plus the max log length.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (len == 1)
|
||||||
|
minlen = 1;
|
||||||
|
else {
|
||||||
|
/* Ensure size is equal to max # of log items + 3 */
|
||||||
|
maxlog = GUINT16_FROM_LE (rsp->len);
|
||||||
|
masklen = maxlog / 8;
|
||||||
|
if (maxlog % 8)
|
||||||
|
masklen++;
|
||||||
|
|
||||||
|
if (len < (masklen + 3)) {
|
||||||
|
g_set_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_LENGTH,
|
||||||
|
"DM command %d response not long enough (got %zu, expected "
|
||||||
|
"at least %d).", DIAG_CMD_EXT_LOGMASK, len, masklen + 3);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
minlen = masklen + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!check_command (buf, len, DIAG_CMD_EXT_LOGMASK, minlen, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
result = qcdm_result_new ();
|
||||||
|
|
||||||
|
if (minlen != 4)
|
||||||
|
qcdm_result_add_uint32 (result, QCDM_CMD_EXT_LOGMASK_ITEM_MAX_ITEMS, maxlog);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
qcmd_cmd_ext_logmask_result_get_item (QCDMResult *result,
|
||||||
|
guint16 item)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************/
|
||||||
|
|
||||||
gsize
|
gsize
|
||||||
qcdm_cmd_zte_subsys_status_new (char *buf, gsize len, GError **error)
|
qcdm_cmd_zte_subsys_status_new (char *buf, gsize len, GError **error)
|
||||||
{
|
{
|
||||||
|
@@ -440,6 +440,25 @@ QCDMResult *qcdm_cmd_hdr_subsys_state_info_result (const char *buf,
|
|||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
/* Max # of log items this device supports */
|
||||||
|
#define QCDM_CMD_EXT_LOGMASK_ITEM_MAX_ITEMS "max-items"
|
||||||
|
|
||||||
|
gsize qcdm_cmd_ext_logmask_new (char *buf,
|
||||||
|
gsize len,
|
||||||
|
GSList *items,
|
||||||
|
guint16 maxlog,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
QCDMResult *qcdm_cmd_ext_logmask_result (const char *buf,
|
||||||
|
gsize len,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/* Returns TRUE if 'item' is set in the log mask */
|
||||||
|
gboolean qcmd_cmd_ext_logmask_result_get_item (QCDMResult *result,
|
||||||
|
guint16 item);
|
||||||
|
|
||||||
|
/**********************************************************************/
|
||||||
|
|
||||||
#define QCDM_CMD_ZTE_SUBSYS_STATUS_ITEM_SIGNAL_INDICATOR "signal-indicator"
|
#define QCDM_CMD_ZTE_SUBSYS_STATUS_ITEM_SIGNAL_INDICATOR "signal-indicator"
|
||||||
|
|
||||||
gsize qcdm_cmd_zte_subsys_status_new (char *buf,
|
gsize qcdm_cmd_zte_subsys_status_new (char *buf,
|
||||||
|
@@ -368,6 +368,15 @@ struct DMCmdPilotSetsRsp {
|
|||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct DMCmdPilotSetsRsp DMCmdPilotSetsRsp;
|
typedef struct DMCmdPilotSetsRsp DMCmdPilotSetsRsp;
|
||||||
|
|
||||||
|
struct DMCmdExtLogMask {
|
||||||
|
guint8 code;
|
||||||
|
/* Bit number of highest '1' in 'mask'; set to 0 to get current mask. */
|
||||||
|
guint16 len;
|
||||||
|
/* Bitfield of log messages to receive */
|
||||||
|
guint8 mask[512];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
typedef struct DMCmdExtLogMask DMCmdExtLogMask;
|
||||||
|
|
||||||
/* DIAG_SUBSYS_NW_CONTROL_* subsys command */
|
/* DIAG_SUBSYS_NW_CONTROL_* subsys command */
|
||||||
struct DMCmdSubsysNwSnapshotReq {
|
struct DMCmdSubsysNwSnapshotReq {
|
||||||
DMCmdSubsysHeader hdr;
|
DMCmdSubsysHeader hdr;
|
||||||
|
@@ -1194,6 +1194,65 @@ test_com_hdr_subsys_state_info (void *f, void *data)
|
|||||||
qcdm_result_unref (result);
|
qcdm_result_unref (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_com_ext_logmask (void *f, void *data)
|
||||||
|
{
|
||||||
|
TestComData *d = data;
|
||||||
|
gboolean success;
|
||||||
|
GError *error = NULL;
|
||||||
|
char buf[520];
|
||||||
|
gint len;
|
||||||
|
QCDMResult *result;
|
||||||
|
gsize reply_len;
|
||||||
|
GSList *items = NULL;
|
||||||
|
guint32 maxlog = 0;
|
||||||
|
|
||||||
|
/* First get # of items the device supports */
|
||||||
|
len = qcdm_cmd_ext_logmask_new (buf, sizeof (buf), NULL, 0, NULL);
|
||||||
|
|
||||||
|
/* Send the command */
|
||||||
|
success = send_command (d, buf, len);
|
||||||
|
g_assert (success);
|
||||||
|
|
||||||
|
/* Get a response */
|
||||||
|
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||||
|
|
||||||
|
g_print ("\n");
|
||||||
|
|
||||||
|
/* Parse the response into a result structure */
|
||||||
|
result = qcdm_cmd_ext_logmask_result (buf, reply_len, &error);
|
||||||
|
g_assert (result);
|
||||||
|
|
||||||
|
qcdm_result_get_uint32 (result, QCDM_CMD_EXT_LOGMASK_ITEM_MAX_ITEMS, &maxlog);
|
||||||
|
g_message ("%s: Max # Log Items: %u (0x%X)", __func__, maxlog, maxlog);
|
||||||
|
|
||||||
|
qcdm_result_unref (result);
|
||||||
|
|
||||||
|
/* Now enable some log items */
|
||||||
|
items = g_slist_append (items, GUINT_TO_POINTER (0x002C));
|
||||||
|
items = g_slist_append (items, GUINT_TO_POINTER (0x002E));
|
||||||
|
len = qcdm_cmd_ext_logmask_new (buf, sizeof (buf), items, (guint16) maxlog, NULL);
|
||||||
|
g_slist_free (items);
|
||||||
|
|
||||||
|
/* Send the command */
|
||||||
|
success = send_command (d, buf, len);
|
||||||
|
g_assert (success);
|
||||||
|
|
||||||
|
/* Get a response */
|
||||||
|
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||||
|
|
||||||
|
g_print ("\n");
|
||||||
|
|
||||||
|
/* Parse the response into a result structure */
|
||||||
|
result = qcdm_cmd_ext_logmask_result (buf, reply_len, &error);
|
||||||
|
g_assert (result);
|
||||||
|
|
||||||
|
qcdm_result_unref (result);
|
||||||
|
|
||||||
|
/* Wait for a log packet */
|
||||||
|
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_com_zte_subsys_status (void *f, void *data)
|
test_com_zte_subsys_status (void *f, void *data)
|
||||||
{
|
{
|
||||||
|
@@ -45,6 +45,8 @@ void test_com_cm_subsys_state_info (void *f, void *data);
|
|||||||
|
|
||||||
void test_com_hdr_subsys_state_info (void *f, void *data);
|
void test_com_hdr_subsys_state_info (void *f, void *data);
|
||||||
|
|
||||||
|
void test_com_ext_logmask (void *f, void *data);
|
||||||
|
|
||||||
void test_com_zte_subsys_status (void *f, void *data);
|
void test_com_zte_subsys_status (void *f, void *data);
|
||||||
|
|
||||||
void test_com_nw_subsys_modem_snapshot_cdma (void *f, void *data);
|
void test_com_nw_subsys_modem_snapshot_cdma (void *f, void *data);
|
||||||
|
@@ -107,6 +107,7 @@ int main (int argc, char **argv)
|
|||||||
g_test_suite_add (suite, TESTCASE (test_com_pilot_sets, data->com_data));
|
g_test_suite_add (suite, TESTCASE (test_com_pilot_sets, data->com_data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_com_cm_subsys_state_info, data->com_data));
|
g_test_suite_add (suite, TESTCASE (test_com_cm_subsys_state_info, data->com_data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_com_hdr_subsys_state_info, data->com_data));
|
g_test_suite_add (suite, TESTCASE (test_com_hdr_subsys_state_info, data->com_data));
|
||||||
|
g_test_suite_add (suite, TESTCASE (test_com_ext_logmask, data->com_data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_com_zte_subsys_status, data->com_data));
|
g_test_suite_add (suite, TESTCASE (test_com_zte_subsys_status, data->com_data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_com_nw_subsys_modem_snapshot_cdma, data->com_data));
|
g_test_suite_add (suite, TESTCASE (test_com_nw_subsys_modem_snapshot_cdma, data->com_data));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user