port-serial-qcdm: use GIO Async API like methods
This commit is contained in:
@@ -452,23 +452,26 @@ snapshot_context_complete_and_free (SnapshotContext *ctx, guint hdr_revision)
|
||||
|
||||
static void
|
||||
nw_snapshot_old_cb (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
SnapshotContext *ctx)
|
||||
{
|
||||
SnapshotContext *ctx = user_data;
|
||||
QcdmResult *result;
|
||||
guint8 hdr_revision = QCDM_HDR_REV_UNKNOWN;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
/* Just ignore the error and complete with the input info */
|
||||
mm_dbg ("Couldn't run QCDM Novatel Modem MSM6500 snapshot: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
snapshot_context_complete_and_free (ctx, QCDM_HDR_REV_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Parse the response */
|
||||
result = qcdm_cmd_nw_subsys_modem_snapshot_cdma_result ((const gchar *) response->data, response->len, NULL);
|
||||
g_byte_array_unref (response);
|
||||
if (result) {
|
||||
qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_HDR_REV, &hdr_revision);
|
||||
qcdm_result_unref (result);
|
||||
@@ -480,23 +483,26 @@ nw_snapshot_old_cb (MMPortSerialQcdm *port,
|
||||
|
||||
static void
|
||||
nw_snapshot_new_cb (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
SnapshotContext *ctx)
|
||||
{
|
||||
SnapshotContext *ctx = user_data;
|
||||
QcdmResult *result;
|
||||
GByteArray *nwsnap;
|
||||
guint8 hdr_revision = QCDM_HDR_REV_UNKNOWN;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
mm_dbg ("Couldn't run QCDM Novatel Modem MSM6800 snapshot: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
snapshot_context_complete_and_free (ctx, QCDM_HDR_REV_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Parse the response */
|
||||
result = qcdm_cmd_nw_subsys_modem_snapshot_cdma_result ((const gchar *) response->data, response->len, NULL);
|
||||
g_byte_array_unref (response);
|
||||
if (result) {
|
||||
qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_HDR_REV, &hdr_revision);
|
||||
qcdm_result_unref (result);
|
||||
@@ -510,7 +516,14 @@ nw_snapshot_new_cb (MMPortSerialQcdm *port,
|
||||
nwsnap = g_byte_array_sized_new (25);
|
||||
nwsnap->len = qcdm_cmd_nw_subsys_modem_snapshot_cdma_new ((char *) nwsnap->data, 25, QCDM_NW_CHIPSET_6500);
|
||||
g_assert (nwsnap->len);
|
||||
mm_port_serial_qcdm_queue_command (port, nwsnap, 3, NULL, nw_snapshot_old_cb, ctx);
|
||||
mm_port_serial_qcdm_command (port,
|
||||
nwsnap,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)nw_snapshot_old_cb,
|
||||
ctx);
|
||||
g_byte_array_unref (nwsnap);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -539,7 +552,14 @@ get_nw_modem_snapshot (MMBaseModem *self,
|
||||
nwsnap = g_byte_array_sized_new (25);
|
||||
nwsnap->len = qcdm_cmd_nw_subsys_modem_snapshot_cdma_new ((char *) nwsnap->data, 25, QCDM_NW_CHIPSET_6800);
|
||||
g_assert (nwsnap->len);
|
||||
mm_port_serial_qcdm_queue_command (port, nwsnap, 3, NULL, nw_snapshot_new_cb, ctx);
|
||||
mm_port_serial_qcdm_command (port,
|
||||
nwsnap,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)nw_snapshot_new_cb,
|
||||
ctx);
|
||||
g_byte_array_unref (nwsnap);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -967,19 +987,22 @@ parse_modem_eri (DetailedRegistrationStateContext *ctx, QcdmResult *result)
|
||||
|
||||
static void
|
||||
reg_eri_6500_cb (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
DetailedRegistrationStateContext *ctx)
|
||||
{
|
||||
DetailedRegistrationStateContext *ctx = user_data;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
/* Just ignore the error and complete with the input info */
|
||||
mm_dbg ("Couldn't run QCDM MSM6500 ERI: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
} else {
|
||||
QcdmResult *result;
|
||||
|
||||
result = qcdm_cmd_nw_subsys_eri_result ((const gchar *) response->data, response->len, NULL);
|
||||
g_byte_array_unref (response);
|
||||
if (result) {
|
||||
parse_modem_eri (ctx, result);
|
||||
qcdm_result_unref (result);
|
||||
@@ -993,30 +1016,41 @@ reg_eri_6500_cb (MMPortSerialQcdm *port,
|
||||
|
||||
static void
|
||||
reg_eri_6800_cb (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
DetailedRegistrationStateContext *ctx)
|
||||
{
|
||||
DetailedRegistrationStateContext *ctx = user_data;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
/* Just ignore the error and complete with the input info */
|
||||
mm_dbg ("Couldn't run QCDM MSM6800 ERI: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
} else {
|
||||
QcdmResult *result;
|
||||
GByteArray *nweri;
|
||||
|
||||
/* Parse the response */
|
||||
result = qcdm_cmd_nw_subsys_eri_result ((const gchar *) response->data, response->len, NULL);
|
||||
g_byte_array_unref (response);
|
||||
if (result) {
|
||||
parse_modem_eri (ctx, result);
|
||||
qcdm_result_unref (result);
|
||||
} else {
|
||||
GByteArray *nweri;
|
||||
|
||||
/* Try for MSM6500 */
|
||||
nweri = g_byte_array_sized_new (25);
|
||||
nweri->len = qcdm_cmd_nw_subsys_eri_new ((char *) nweri->data, 25, QCDM_NW_CHIPSET_6500);
|
||||
g_assert (nweri->len);
|
||||
mm_port_serial_qcdm_queue_command (port, nweri, 3, NULL, reg_eri_6500_cb, ctx);
|
||||
mm_port_serial_qcdm_command (port,
|
||||
nweri,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)reg_eri_6500_cb,
|
||||
ctx);
|
||||
g_byte_array_unref (nweri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1087,14 @@ modem_cdma_get_detailed_registration_state (MMIfaceModemCdma *self,
|
||||
nweri = g_byte_array_sized_new (25);
|
||||
nweri->len = qcdm_cmd_nw_subsys_eri_new ((char *) nweri->data, 25, QCDM_NW_CHIPSET_6800);
|
||||
g_assert (nweri->len);
|
||||
mm_port_serial_qcdm_queue_command (port, nweri, 3, NULL, reg_eri_6800_cb, ctx);
|
||||
mm_port_serial_qcdm_command (port,
|
||||
nweri,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)reg_eri_6800_cb,
|
||||
ctx);
|
||||
g_byte_array_unref (nweri);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@@ -581,30 +581,36 @@ load_current_capabilities_at (LoadCapabilitiesContext *ctx)
|
||||
|
||||
static void
|
||||
mode_pref_qcdm_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
LoadCapabilitiesContext *ctx)
|
||||
{
|
||||
QcdmResult *result;
|
||||
gint err = QCDM_SUCCESS;
|
||||
u_int8_t pref = 0;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
/* Fall back to AT checking */
|
||||
mm_dbg ("Failed to load NV ModePref: %s", error->message);
|
||||
g_error_free (error);
|
||||
goto at_caps;
|
||||
}
|
||||
|
||||
/* Parse the response */
|
||||
result = qcdm_cmd_nv_get_mode_pref_result ((const gchar *) response->data,
|
||||
result = qcdm_cmd_nv_get_mode_pref_result ((const gchar *)response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (!result) {
|
||||
mm_dbg ("Failed to parse NV ModePref result: %d", err);
|
||||
g_byte_array_unref (response);
|
||||
goto at_caps;
|
||||
}
|
||||
|
||||
err = qcdm_result_get_u8 (result, QCDM_CMD_NV_GET_MODE_PREF_ITEM_MODE_PREF, &pref);
|
||||
qcdm_result_unref (result);
|
||||
if (err) {
|
||||
mm_dbg ("Failed to read NV ModePref: %d", err);
|
||||
qcdm_result_unref (result);
|
||||
@@ -677,12 +683,14 @@ load_current_capabilities_qcdm (LoadCapabilitiesContext *ctx)
|
||||
cmd->len = qcdm_cmd_nv_get_mode_pref_new ((char *) cmd->data, 300, 0);
|
||||
g_assert (cmd->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (ctx->qcdm_port,
|
||||
cmd,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn) mode_pref_qcdm_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (ctx->qcdm_port,
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)mode_pref_qcdm_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cmd);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1026,16 +1034,18 @@ modem_load_own_numbers_finish (MMIfaceModem *self,
|
||||
|
||||
static void
|
||||
mdn_qcdm_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
OwnNumbersContext *ctx)
|
||||
{
|
||||
QcdmResult *result;
|
||||
gint err = QCDM_SUCCESS;
|
||||
const char *numbers[2] = { NULL, NULL };
|
||||
GByteArray *response;
|
||||
GError *error = NULL;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_set_from_error (ctx->result, error);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
own_numbers_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
@@ -1112,12 +1122,14 @@ modem_load_own_numbers_done (MMIfaceModem *self,
|
||||
mdn->len = qcdm_cmd_nv_get_mdn_new ((char *) mdn->data, 200, 0);
|
||||
g_assert (mdn->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (ctx->qcdm,
|
||||
mdn,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)mdn_qcdm_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (ctx->qcdm,
|
||||
mdn,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)mdn_qcdm_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (mdn);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -1889,17 +1901,19 @@ signal_quality_cind (SignalQualityContext *ctx)
|
||||
|
||||
static void
|
||||
signal_quality_qcdm_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
SignalQualityContext *ctx)
|
||||
{
|
||||
QcdmResult *result;
|
||||
guint32 num = 0, quality = 0, i;
|
||||
gfloat best_db = -28;
|
||||
gint err = QCDM_SUCCESS;
|
||||
GByteArray *response;
|
||||
GError *error = NULL;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_set_from_error (ctx->result, error);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
signal_quality_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
@@ -1908,6 +1922,7 @@ signal_quality_qcdm_ready (MMPortSerialQcdm *port,
|
||||
result = qcdm_cmd_pilot_sets_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (!result) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
@@ -1961,12 +1976,14 @@ signal_quality_qcdm (SignalQualityContext *ctx)
|
||||
pilot_sets->len = qcdm_cmd_pilot_sets_new ((char *) pilot_sets->data, 25);
|
||||
g_assert (pilot_sets->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (MM_PORT_SERIAL_QCDM (ctx->port),
|
||||
pilot_sets,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)signal_quality_qcdm_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (MM_PORT_SERIAL_QCDM (ctx->port),
|
||||
pilot_sets,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)signal_quality_qcdm_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (pilot_sets);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2136,16 +2153,18 @@ done:
|
||||
|
||||
static void
|
||||
access_tech_qcdm_wcdma_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
AccessTechContext *ctx)
|
||||
{
|
||||
QcdmResult *result;
|
||||
gint err = QCDM_SUCCESS;
|
||||
guint8 l1;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
access_tech_context_complete_and_free (ctx, g_error_copy (error), FALSE);
|
||||
access_tech_context_complete_and_free (ctx, error, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2153,6 +2172,7 @@ access_tech_qcdm_wcdma_ready (MMPortSerialQcdm *port,
|
||||
result = qcdm_cmd_wcdma_subsys_state_info_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (result) {
|
||||
qcdm_result_get_u8 (result, QCDM_CMD_WCDMA_SUBSYS_STATE_INFO_ITEM_L1_STATE, &l1);
|
||||
qcdm_result_unref (result);
|
||||
@@ -2168,8 +2188,7 @@ access_tech_qcdm_wcdma_ready (MMPortSerialQcdm *port,
|
||||
|
||||
static void
|
||||
access_tech_qcdm_gsm_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
AccessTechContext *ctx)
|
||||
{
|
||||
GByteArray *cmd;
|
||||
@@ -2177,9 +2196,12 @@ access_tech_qcdm_gsm_ready (MMPortSerialQcdm *port,
|
||||
gint err = QCDM_SUCCESS;
|
||||
guint8 opmode = 0;
|
||||
guint8 sysmode = 0;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
access_tech_context_complete_and_free (ctx, g_error_copy (error), FALSE);
|
||||
access_tech_context_complete_and_free (ctx, error, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2187,6 +2209,7 @@ access_tech_qcdm_gsm_ready (MMPortSerialQcdm *port,
|
||||
result = qcdm_cmd_gsm_subsys_state_info_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (!result) {
|
||||
error = g_error_new (MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
@@ -2208,27 +2231,31 @@ access_tech_qcdm_gsm_ready (MMPortSerialQcdm *port,
|
||||
cmd->len = qcdm_cmd_wcdma_subsys_state_info_new ((char *) cmd->data, 50);
|
||||
g_assert (cmd->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (port,
|
||||
cmd,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn) access_tech_qcdm_wcdma_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (port,
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)access_tech_qcdm_wcdma_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cmd);
|
||||
}
|
||||
|
||||
static void
|
||||
access_tech_qcdm_hdr_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
AccessTechContext *ctx)
|
||||
{
|
||||
QcdmResult *result;
|
||||
gint err = QCDM_SUCCESS;
|
||||
guint8 session = 0;
|
||||
guint8 almp = 0;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
access_tech_context_complete_and_free (ctx, g_error_copy (error), FALSE);
|
||||
access_tech_context_complete_and_free (ctx, error, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2236,6 +2263,7 @@ access_tech_qcdm_hdr_ready (MMPortSerialQcdm *port,
|
||||
result = qcdm_cmd_hdr_subsys_state_info_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (result) {
|
||||
qcdm_result_get_u8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_SESSION_STATE, &session);
|
||||
qcdm_result_get_u8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE, &almp);
|
||||
@@ -2252,17 +2280,19 @@ access_tech_qcdm_hdr_ready (MMPortSerialQcdm *port,
|
||||
|
||||
static void
|
||||
access_tech_qcdm_cdma_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
AccessTechContext *ctx)
|
||||
{
|
||||
GByteArray *cmd;
|
||||
QcdmResult *result;
|
||||
gint err = QCDM_SUCCESS;
|
||||
guint32 hybrid;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
access_tech_context_complete_and_free (ctx, g_error_copy (error), FALSE);
|
||||
access_tech_context_complete_and_free (ctx, error, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2270,6 +2300,7 @@ access_tech_qcdm_cdma_ready (MMPortSerialQcdm *port,
|
||||
result = qcdm_cmd_cm_subsys_state_info_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (!result) {
|
||||
error = g_error_new (MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
@@ -2291,12 +2322,14 @@ access_tech_qcdm_cdma_ready (MMPortSerialQcdm *port,
|
||||
cmd->len = qcdm_cmd_hdr_subsys_state_info_new ((char *) cmd->data, 50);
|
||||
g_assert (cmd->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (port,
|
||||
cmd,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn) access_tech_qcdm_hdr_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (port,
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)access_tech_qcdm_hdr_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cmd);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2373,25 +2406,34 @@ modem_load_access_technologies (MMIfaceModem *self,
|
||||
cmd->len = qcdm_cmd_gsm_subsys_state_info_new ((char *) cmd->data, 50);
|
||||
g_assert (cmd->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (ctx->port,
|
||||
cmd,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn) access_tech_qcdm_gsm_ready,
|
||||
ctx);
|
||||
} else if (mm_iface_modem_is_cdma (self)) {
|
||||
mm_port_serial_qcdm_command (ctx->port,
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)access_tech_qcdm_gsm_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mm_iface_modem_is_cdma (self)) {
|
||||
cmd = g_byte_array_sized_new (50);
|
||||
cmd->len = qcdm_cmd_cm_subsys_state_info_new ((char *) cmd->data, 50);
|
||||
g_assert (cmd->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (ctx->port,
|
||||
cmd,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn) access_tech_qcdm_cdma_ready,
|
||||
ctx);
|
||||
} else
|
||||
g_assert_not_reached ();
|
||||
mm_port_serial_qcdm_command (ctx->port,
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)access_tech_qcdm_cdma_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -6367,12 +6409,14 @@ modem_cdma_get_hdr_state (MMIfaceModemCdma *self,
|
||||
hdrstate->len = qcdm_cmd_hdr_subsys_state_info_new ((gchar *) hdrstate->data, 25);
|
||||
g_assert (hdrstate->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (ctx->qcdm,
|
||||
hdrstate,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)hdr_subsys_state_info_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (ctx->qcdm,
|
||||
hdrstate,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)hdr_subsys_state_info_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (hdrstate);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -6419,16 +6463,18 @@ modem_cdma_get_call_manager_state_finish (MMIfaceModemCdma *self,
|
||||
|
||||
static void
|
||||
cm_subsys_state_info_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
CallManagerStateContext *ctx)
|
||||
{
|
||||
QcdmResult *result;
|
||||
CallManagerStateResults *results;
|
||||
gint err = QCDM_SUCCESS;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_set_from_error (ctx->result, error);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
call_manager_state_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
@@ -6437,6 +6483,7 @@ cm_subsys_state_info_ready (MMPortSerialQcdm *port,
|
||||
result = qcdm_cmd_cm_subsys_state_info_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
&err);
|
||||
g_byte_array_unref (response);
|
||||
if (!result) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
@@ -6491,12 +6538,14 @@ modem_cdma_get_call_manager_state (MMIfaceModemCdma *self,
|
||||
cmstate->len = qcdm_cmd_cm_subsys_state_info_new ((gchar *) cmstate->data, 25);
|
||||
g_assert (cmstate->len);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (ctx->qcdm,
|
||||
cmstate,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)cm_subsys_state_info_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (ctx->qcdm,
|
||||
cmstate,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)cm_subsys_state_info_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cmstate);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -6687,17 +6736,19 @@ css_query_ready (MMIfaceModemCdma *self,
|
||||
|
||||
static void
|
||||
qcdm_cdma_status_ready (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
Cdma1xServingSystemContext *ctx)
|
||||
{
|
||||
Cdma1xServingSystemResults *results;
|
||||
QcdmResult *result;
|
||||
QcdmResult *result = NULL;
|
||||
guint32 sid = MM_MODEM_CDMA_SID_UNKNOWN;
|
||||
guint32 nid = MM_MODEM_CDMA_NID_UNKNOWN;
|
||||
guint32 rxstate = 0;
|
||||
gint err = QCDM_SUCCESS;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
if (error ||
|
||||
(result = qcdm_cmd_cdma_status_result ((const gchar *) response->data,
|
||||
response->len,
|
||||
@@ -6711,9 +6762,15 @@ qcdm_cdma_status_ready (MMPortSerialQcdm *port,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback)css_query_ready,
|
||||
ctx);
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
if (response)
|
||||
g_byte_array_unref (response);
|
||||
return;
|
||||
}
|
||||
|
||||
g_byte_array_unref (response);
|
||||
|
||||
qcdm_result_get_u32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, &rxstate);
|
||||
qcdm_result_get_u32 (result, QCDM_CMD_CDMA_STATUS_ITEM_SID, &sid);
|
||||
qcdm_result_get_u32 (result, QCDM_CMD_CDMA_STATUS_ITEM_NID, &nid);
|
||||
@@ -6764,12 +6821,14 @@ modem_cdma_get_cdma1x_serving_system (MMIfaceModemCdma *self,
|
||||
cdma_status = g_byte_array_sized_new (25);
|
||||
cdma_status->len = qcdm_cmd_cdma_status_new ((char *) cdma_status->data, 25);
|
||||
g_assert (cdma_status->len);
|
||||
mm_port_serial_qcdm_queue_command (ctx->qcdm,
|
||||
cdma_status,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)qcdm_cdma_status_ready,
|
||||
ctx);
|
||||
mm_port_serial_qcdm_command (ctx->qcdm,
|
||||
cdma_status,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)qcdm_cdma_status_ready,
|
||||
ctx);
|
||||
g_byte_array_unref (cdma_status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -576,8 +576,7 @@ wdm_probe (MMPortProbe *self)
|
||||
|
||||
static void
|
||||
serial_probe_qcdm_parse_response (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GAsyncResult *res,
|
||||
MMPortProbe *self)
|
||||
{
|
||||
QcdmResult *result;
|
||||
@@ -585,10 +584,14 @@ serial_probe_qcdm_parse_response (MMPortSerialQcdm *port,
|
||||
gboolean is_qcdm = FALSE;
|
||||
gboolean retry = FALSE;
|
||||
PortProbeRunTask *task = self->priv->task;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
|
||||
/* If already cancelled, do nothing else */
|
||||
if (port_probe_run_is_cancelled (self))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (!error) {
|
||||
/* Parse the response */
|
||||
@@ -604,7 +607,6 @@ serial_probe_qcdm_parse_response (MMPortSerialQcdm *port,
|
||||
} else {
|
||||
/* yay, probably a QCDM port */
|
||||
is_qcdm = TRUE;
|
||||
|
||||
qcdm_result_unref (result);
|
||||
}
|
||||
} else {
|
||||
@@ -619,13 +621,15 @@ serial_probe_qcdm_parse_response (MMPortSerialQcdm *port,
|
||||
cmd2 = g_object_steal_data (G_OBJECT (self), "cmd2");
|
||||
if (cmd2) {
|
||||
/* second try */
|
||||
mm_port_serial_qcdm_queue_command (MM_PORT_SERIAL_QCDM (task->serial),
|
||||
cmd2,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)serial_probe_qcdm_parse_response,
|
||||
self);
|
||||
return;
|
||||
mm_port_serial_qcdm_command (MM_PORT_SERIAL_QCDM (task->serial),
|
||||
cmd2,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)serial_probe_qcdm_parse_response,
|
||||
self);
|
||||
g_byte_array_unref (cmd2);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* no more retries left */
|
||||
@@ -636,6 +640,12 @@ serial_probe_qcdm_parse_response (MMPortSerialQcdm *port,
|
||||
|
||||
/* Reschedule probing */
|
||||
serial_probe_schedule (self);
|
||||
|
||||
out:
|
||||
if (response)
|
||||
g_byte_array_unref (response);
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -707,7 +717,7 @@ serial_probe_qcdm (MMPortProbe *self)
|
||||
g_byte_array_append (verinfo, &marker, 1);
|
||||
len = qcdm_cmd_version_info_new ((char *) (verinfo->data + 1), 9);
|
||||
if (len <= 0) {
|
||||
g_byte_array_free (verinfo, TRUE);
|
||||
g_byte_array_unref (verinfo);
|
||||
port_probe_run_task_complete (
|
||||
task,
|
||||
FALSE,
|
||||
@@ -725,12 +735,14 @@ serial_probe_qcdm (MMPortProbe *self)
|
||||
g_byte_array_append (verinfo2, verinfo->data, verinfo->len);
|
||||
g_object_set_data_full (G_OBJECT (self), "cmd2", verinfo2, (GDestroyNotify) g_byte_array_unref);
|
||||
|
||||
mm_port_serial_qcdm_queue_command (MM_PORT_SERIAL_QCDM (task->serial),
|
||||
verinfo,
|
||||
3,
|
||||
NULL,
|
||||
(MMPortSerialQcdmResponseFn)serial_probe_qcdm_parse_response,
|
||||
self);
|
||||
mm_port_serial_qcdm_command (MM_PORT_SERIAL_QCDM (task->serial),
|
||||
verinfo,
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)serial_probe_qcdm_parse_response,
|
||||
self);
|
||||
g_byte_array_unref (verinfo);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ handle_response (MMPortSerial *port,
|
||||
GCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
MMPortSerialQcdmResponseFn response_callback = (MMPortSerialQcdmResponseFn) callback;
|
||||
MMSerialResponseFn response_callback = (MMSerialResponseFn) callback;
|
||||
GByteArray *unescaped = NULL;
|
||||
guint8 *unescaped_buffer;
|
||||
GError *dm_error = NULL;
|
||||
@@ -123,7 +123,7 @@ handle_response (MMPortSerial *port,
|
||||
}
|
||||
|
||||
callback:
|
||||
response_callback (MM_PORT_SERIAL_QCDM (port),
|
||||
response_callback (MM_PORT_SERIAL (port),
|
||||
unescaped,
|
||||
dm_error ? dm_error : error,
|
||||
callback_data);
|
||||
@@ -137,48 +137,73 @@ callback:
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
mm_port_serial_qcdm_queue_command (MMPortSerialQcdm *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
GCancellable *cancellable,
|
||||
MMPortSerialQcdmResponseFn callback,
|
||||
gpointer user_data)
|
||||
GByteArray *
|
||||
mm_port_serial_qcdm_command_finish (MMPortSerialQcdm *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (MM_IS_PORT_SERIAL_QCDM (self));
|
||||
g_return_if_fail (command != NULL);
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
/* 'command' is expected to be already CRC-ed and escaped */
|
||||
mm_port_serial_queue_command (MM_PORT_SERIAL (self),
|
||||
command,
|
||||
TRUE,
|
||||
timeout_seconds,
|
||||
cancellable,
|
||||
(MMSerialResponseFn) callback,
|
||||
user_data);
|
||||
return g_byte_array_ref ((GByteArray *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
|
||||
}
|
||||
|
||||
static void
|
||||
serial_command_ready (MMPortSerial *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
GSimpleAsyncResult *simple)
|
||||
{
|
||||
if (error)
|
||||
g_simple_async_result_set_from_error (simple, error);
|
||||
else if (response)
|
||||
g_simple_async_result_set_op_res_gpointer (simple,
|
||||
g_byte_array_ref (response),
|
||||
(GDestroyNotify)g_byte_array_unref);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
void
|
||||
mm_port_serial_qcdm_queue_command_cached (MMPortSerialQcdm *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
GCancellable *cancellable,
|
||||
MMPortSerialQcdmResponseFn callback,
|
||||
gpointer user_data)
|
||||
mm_port_serial_qcdm_command (MMPortSerialQcdm *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
gboolean allow_cached,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
g_return_if_fail (MM_IS_PORT_SERIAL_QCDM (self));
|
||||
g_return_if_fail (command != NULL);
|
||||
|
||||
simple = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
mm_port_serial_qcdm_command);
|
||||
|
||||
/* 'command' is expected to be already CRC-ed and escaped */
|
||||
mm_port_serial_queue_command_cached (MM_PORT_SERIAL (self),
|
||||
command,
|
||||
TRUE,
|
||||
timeout_seconds,
|
||||
cancellable,
|
||||
(MMSerialResponseFn) callback,
|
||||
user_data);
|
||||
|
||||
if (!allow_cached)
|
||||
mm_port_serial_queue_command (MM_PORT_SERIAL (self),
|
||||
g_byte_array_ref (command),
|
||||
TRUE,
|
||||
timeout_seconds,
|
||||
cancellable,
|
||||
(MMSerialResponseFn)serial_command_ready,
|
||||
simple);
|
||||
else
|
||||
mm_port_serial_queue_command_cached (MM_PORT_SERIAL (self),
|
||||
g_byte_array_ref (command),
|
||||
TRUE,
|
||||
timeout_seconds,
|
||||
cancellable,
|
||||
(MMSerialResponseFn)serial_command_ready,
|
||||
simple);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -32,11 +32,6 @@
|
||||
typedef struct _MMPortSerialQcdm MMPortSerialQcdm;
|
||||
typedef struct _MMPortSerialQcdmClass MMPortSerialQcdmClass;
|
||||
|
||||
typedef void (*MMPortSerialQcdmResponseFn) (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
|
||||
struct _MMPortSerialQcdm {
|
||||
MMPortSerial parent;
|
||||
};
|
||||
@@ -50,18 +45,15 @@ GType mm_port_serial_qcdm_get_type (void);
|
||||
MMPortSerialQcdm *mm_port_serial_qcdm_new (const char *name);
|
||||
MMPortSerialQcdm *mm_port_serial_qcdm_new_fd (int fd);
|
||||
|
||||
void mm_port_serial_qcdm_queue_command (MMPortSerialQcdm *self,
|
||||
void mm_port_serial_qcdm_command (MMPortSerialQcdm *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
gboolean allow_cached,
|
||||
GCancellable *cancellable,
|
||||
MMPortSerialQcdmResponseFn callback,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_port_serial_qcdm_queue_command_cached (MMPortSerialQcdm *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
GCancellable *cancellable,
|
||||
MMPortSerialQcdmResponseFn callback,
|
||||
gpointer user_data);
|
||||
GByteArray *mm_port_serial_qcdm_command_finish (MMPortSerialQcdm *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
#endif /* MM_PORT_SERIAL_QCDM_H */
|
||||
|
@@ -594,7 +594,7 @@ mm_port_serial_got_response (MMPortSerial *self, GError *error)
|
||||
}
|
||||
|
||||
g_clear_object (&info->cancellable);
|
||||
g_byte_array_free (info->command, TRUE);
|
||||
g_byte_array_unref (info->command);
|
||||
g_slice_free (MMQueueData, info);
|
||||
}
|
||||
|
||||
@@ -1102,11 +1102,11 @@ mm_port_serial_close (MMPortSerial *self)
|
||||
item->callback,
|
||||
item->user_data);
|
||||
g_error_free (error);
|
||||
g_byte_array_free (response, TRUE);
|
||||
g_byte_array_unref (response);
|
||||
}
|
||||
|
||||
g_clear_object (&item->cancellable);
|
||||
g_byte_array_free (item->command, TRUE);
|
||||
g_byte_array_unref (item->command);
|
||||
g_slice_free (MMQueueData, item);
|
||||
}
|
||||
g_queue_clear (priv->queue);
|
||||
@@ -1595,7 +1595,7 @@ ba_hash (gconstpointer v)
|
||||
static void
|
||||
ba_free (gpointer v)
|
||||
{
|
||||
g_byte_array_free ((GByteArray *) v, TRUE);
|
||||
g_byte_array_unref ((GByteArray *) v);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1721,7 +1721,7 @@ finalize (GObject *object)
|
||||
MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
|
||||
|
||||
g_hash_table_destroy (priv->reply_cache);
|
||||
g_byte_array_free (priv->response, TRUE);
|
||||
g_byte_array_unref (priv->response);
|
||||
g_queue_free (priv->queue);
|
||||
|
||||
G_OBJECT_CLASS (mm_port_serial_parent_class)->finalize (object);
|
||||
|
@@ -122,7 +122,7 @@ server_wait_request (int fd, char *buf, gsize len)
|
||||
FD_ZERO (&in);
|
||||
FD_SET (fd, &in);
|
||||
result = select (fd + 1, &in, NULL, NULL, &timeout);
|
||||
g_assert (result == 1);
|
||||
g_assert_cmpint (result, ==, 1);
|
||||
g_assert (FD_ISSET (fd, &in));
|
||||
|
||||
do {
|
||||
@@ -170,26 +170,26 @@ server_wait_request (int fd, char *buf, gsize len)
|
||||
return decap_len;
|
||||
}
|
||||
|
||||
typedef void (*VerInfoCb) (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
|
||||
static void
|
||||
qcdm_verinfo_expect_success_cb (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
GMainLoop *loop)
|
||||
{
|
||||
GMainLoop *loop = user_data;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
|
||||
g_assert_no_error (error);
|
||||
g_assert (response->len > 0);
|
||||
g_byte_array_unref (response);
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
static void
|
||||
qcdm_request_verinfo (MMPortSerialQcdm *port, VerInfoCb cb, GMainLoop *loop)
|
||||
qcdm_request_verinfo (MMPortSerialQcdm *port,
|
||||
GAsyncReadyCallback cb,
|
||||
GMainLoop *loop)
|
||||
{
|
||||
GByteArray *verinfo;
|
||||
gint len;
|
||||
@@ -201,11 +201,12 @@ qcdm_request_verinfo (MMPortSerialQcdm *port, VerInfoCb cb, GMainLoop *loop)
|
||||
g_byte_array_free (verinfo, TRUE);
|
||||
verinfo->len = len;
|
||||
|
||||
mm_port_serial_qcdm_queue_command (port, verinfo, 3, NULL, cb, loop);
|
||||
mm_port_serial_qcdm_command (port, verinfo, 3, FALSE, NULL, cb, loop);
|
||||
g_byte_array_unref (verinfo);
|
||||
}
|
||||
|
||||
static void
|
||||
qcdm_test_child (int fd, VerInfoCb cb)
|
||||
qcdm_test_child (int fd, GAsyncReadyCallback cb)
|
||||
{
|
||||
MMPortSerialQcdm *port;
|
||||
GMainLoop *loop;
|
||||
@@ -235,9 +236,8 @@ qcdm_test_child (int fd, VerInfoCb cb)
|
||||
* make sure things in general are working.
|
||||
*/
|
||||
static void
|
||||
test_verinfo (void *f)
|
||||
test_verinfo (TestData *d)
|
||||
{
|
||||
TestData *d = f;
|
||||
char req[512];
|
||||
gsize req_len;
|
||||
pid_t cpid;
|
||||
@@ -255,7 +255,7 @@ test_verinfo (void *f)
|
||||
|
||||
if (cpid == 0) {
|
||||
/* In the child */
|
||||
qcdm_test_child (d->slave, qcdm_verinfo_expect_success_cb);
|
||||
qcdm_test_child (d->slave, (GAsyncReadyCallback)qcdm_verinfo_expect_success_cb);
|
||||
exit (0);
|
||||
}
|
||||
/* Parent */
|
||||
@@ -271,13 +271,18 @@ test_verinfo (void *f)
|
||||
|
||||
static void
|
||||
qcdm_verinfo_expect_fail_cb (MMPortSerialQcdm *port,
|
||||
GByteArray *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
GMainLoop *loop)
|
||||
{
|
||||
GMainLoop *loop = user_data;
|
||||
GError *error = NULL;
|
||||
GByteArray *response;
|
||||
|
||||
response = mm_port_serial_qcdm_command_finish (port, res, &error);
|
||||
|
||||
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
|
||||
g_error_free (error);
|
||||
g_assert (response == NULL);
|
||||
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
@@ -285,9 +290,8 @@ qcdm_verinfo_expect_fail_cb (MMPortSerialQcdm *port,
|
||||
* raises an error in the child's response handler.
|
||||
*/
|
||||
static void
|
||||
test_sierra_cns_rejected (void *f)
|
||||
test_sierra_cns_rejected (TestData *d)
|
||||
{
|
||||
TestData *d = f;
|
||||
char req[512];
|
||||
gsize req_len;
|
||||
pid_t cpid;
|
||||
@@ -302,7 +306,7 @@ test_sierra_cns_rejected (void *f)
|
||||
|
||||
if (cpid == 0) {
|
||||
/* In the child */
|
||||
qcdm_test_child (d->slave, qcdm_verinfo_expect_fail_cb);
|
||||
qcdm_test_child (d->slave, (GAsyncReadyCallback)qcdm_verinfo_expect_fail_cb);
|
||||
exit (0);
|
||||
}
|
||||
/* Parent */
|
||||
@@ -322,9 +326,8 @@ test_sierra_cns_rejected (void *f)
|
||||
* raises an error in the child's response handler.
|
||||
*/
|
||||
static void
|
||||
test_random_data_rejected (void *f)
|
||||
test_random_data_rejected (TestData *d)
|
||||
{
|
||||
TestData *d = f;
|
||||
char req[512];
|
||||
gsize req_len;
|
||||
pid_t cpid;
|
||||
@@ -339,7 +342,7 @@ test_random_data_rejected (void *f)
|
||||
|
||||
if (cpid == 0) {
|
||||
/* In the child */
|
||||
qcdm_test_child (d->slave, qcdm_verinfo_expect_fail_cb);
|
||||
qcdm_test_child (d->slave, (GAsyncReadyCallback)qcdm_verinfo_expect_fail_cb);
|
||||
exit (0);
|
||||
}
|
||||
/* Parent */
|
||||
@@ -359,9 +362,8 @@ test_random_data_rejected (void *f)
|
||||
* to a Version Info command is parsed correctly.
|
||||
*/
|
||||
static void
|
||||
test_leading_frame_markers (void *f)
|
||||
test_leading_frame_markers (TestData *d)
|
||||
{
|
||||
TestData *d = f;
|
||||
char req[512];
|
||||
gsize req_len;
|
||||
pid_t cpid;
|
||||
@@ -380,7 +382,7 @@ test_leading_frame_markers (void *f)
|
||||
|
||||
if (cpid == 0) {
|
||||
/* In the child */
|
||||
qcdm_test_child (d->slave, qcdm_verinfo_expect_success_cb);
|
||||
qcdm_test_child (d->slave, (GAsyncReadyCallback)qcdm_verinfo_expect_success_cb);
|
||||
exit (0);
|
||||
}
|
||||
/* Parent */
|
||||
@@ -397,9 +399,8 @@ test_leading_frame_markers (void *f)
|
||||
}
|
||||
|
||||
static void
|
||||
test_pty_create (gpointer user_data)
|
||||
test_pty_create (TestData *d)
|
||||
{
|
||||
TestData *d = user_data;
|
||||
struct termios stbuf;
|
||||
int ret, err;
|
||||
|
||||
@@ -421,10 +422,8 @@ test_pty_create (gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
test_pty_cleanup (gpointer user_data)
|
||||
test_pty_cleanup (TestData *d)
|
||||
{
|
||||
TestData *d = user_data;
|
||||
|
||||
/* For some reason the cleanup function gets called more times
|
||||
* than the setup function does...
|
||||
*/
|
||||
@@ -439,11 +438,6 @@ test_pty_cleanup (gpointer user_data)
|
||||
}
|
||||
}
|
||||
|
||||
typedef GTestFixtureFunc TCFunc;
|
||||
|
||||
#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL)
|
||||
#define TESTCASE_PTY(t, d) g_test_create_case (#t, sizeof (*d), d, (TCFunc) test_pty_create, (TCFunc) t, (TCFunc) test_pty_cleanup)
|
||||
|
||||
void
|
||||
_mm_log (const char *loc,
|
||||
const char *func,
|
||||
@@ -464,22 +458,17 @@ _mm_log (const char *loc,
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef void (*TCFunc) (TestData *, gconstpointer);
|
||||
#define TESTCASE_PTY(s, t) g_test_add (s, TestData, NULL, (TCFunc)test_pty_create, (TCFunc)t, (TCFunc)test_pty_cleanup);
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GTestSuite *suite;
|
||||
gint result;
|
||||
TestData *data = NULL;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
suite = g_test_get_root ();
|
||||
TESTCASE_PTY ("/MM/QCDM/Verinfo", test_verinfo);
|
||||
TESTCASE_PTY ("/MM/QCDM/Sierra-Cns-Rejected", test_sierra_cns_rejected);
|
||||
TESTCASE_PTY ("/MM/QCDM/Random-Data-Rejected", test_random_data_rejected);
|
||||
TESTCASE_PTY ("/MM/QCDM/Leading-Frame-Markers", test_leading_frame_markers);
|
||||
|
||||
g_test_suite_add (suite, TESTCASE_PTY (test_verinfo, data));
|
||||
g_test_suite_add (suite, TESTCASE_PTY (test_sierra_cns_rejected, data));
|
||||
g_test_suite_add (suite, TESTCASE_PTY (test_random_data_rejected, data));
|
||||
g_test_suite_add (suite, TESTCASE_PTY (test_leading_frame_markers, data));
|
||||
|
||||
result = g_test_run ();
|
||||
|
||||
return result;
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user