qcdm: add status command and rework testcases a bit

Status command not completely working yet.
This commit is contained in:
Dan Williams
2010-02-22 13:27:25 -08:00
parent cb59d2e64d
commit c0e227a16b
6 changed files with 220 additions and 14 deletions

View File

@@ -218,6 +218,74 @@ qcdm_cmd_esn_result (const char *buf, gsize len, GError **error)
/**********************************************************************/
gsize
qcdm_cmd_cdma_status_new (char *buf, gsize len, GError **error)
{
char cmdbuf[3];
DMCmdHeader *cmd = (DMCmdHeader *) &cmdbuf[0];
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_STATUS;
return dm_encapsulate_buffer (cmdbuf, sizeof (*cmd), sizeof (cmdbuf), buf, len);
}
QCDMResult *
qcdm_cmd_cdma_status_result (const char *buf, gsize len, GError **error)
{
QCDMResult *result = NULL;
DMCmdStatusRsp *rsp = (DMCmdStatusRsp *) buf;
char *tmp;
guint8 swapped[4];
guint32 tmp_num;
g_return_val_if_fail (buf != NULL, NULL);
if (!check_command (buf, len, DIAG_CMD_STATUS, sizeof (DMCmdStatusRsp), error))
return NULL;
result = qcdm_result_new ();
/* Convert the ESN from binary to a hex string; it's LE so we have to
* swap it to get the correct ordering.
*/
swapped[0] = rsp->esn[3];
swapped[1] = rsp->esn[2];
swapped[2] = rsp->esn[1];
swapped[3] = rsp->esn[0];
tmp = bin2hexstr (&swapped[0], sizeof (swapped));
qcdm_result_add_string (result, QCDM_CMD_CDMA_STATUS_ITEM_ESN, tmp);
g_free (tmp);
tmp_num = (guint32) GUINT16_FROM_LE (rsp->cdma_rx_state);
qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, tmp_num);
tmp_num = (guint32) GUINT16_FROM_LE (rsp->entry_reason);
qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_ENTRY_REASON, tmp_num);
tmp_num = (guint32) GUINT16_FROM_LE (rsp->curr_chan);
qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_CURRENT_CHANNEL, tmp_num);
qcdm_result_add_uint8 (result, QCDM_CMD_CDMA_STATUS_ITEM_CODE_CHANNEL, rsp->cdma_code_chan);
tmp_num = (guint32) GUINT16_FROM_LE (rsp->pilot_base);
qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_PILOT_BASE, tmp_num);
tmp_num = (guint32) GUINT16_FROM_LE (rsp->sid);
qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, tmp_num);
tmp_num = (guint32) GUINT16_FROM_LE (rsp->nid);
qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, tmp_num);
return result;
}
/**********************************************************************/
gsize
qcdm_cmd_nv_get_mdn_new (char *buf, gsize len, guint8 profile, GError **error)
{