ports: port to object logging
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
|
|
||||||
#include "mm-port-mbim.h"
|
#include "mm-port-mbim.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log-object.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMPortMbim, mm_port_mbim, MM_TYPE_PORT)
|
G_DEFINE_TYPE (MMPortMbim, mm_port_mbim, MM_TYPE_PORT)
|
||||||
|
|
||||||
@@ -176,18 +176,14 @@ qmi_device_open_ready (QmiDevice *dev,
|
|||||||
self = g_task_get_source_object (task);
|
self = g_task_get_source_object (task);
|
||||||
|
|
||||||
if (!qmi_device_open_finish (dev, res, &error)) {
|
if (!qmi_device_open_finish (dev, res, &error)) {
|
||||||
mm_dbg ("[%s] error: couldn't open QmiDevice: %s",
|
mm_obj_dbg (self, "error: couldn't open QmiDevice: %s", error->message);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_clear_object (&self->priv->qmi_device);
|
g_clear_object (&self->priv->qmi_device);
|
||||||
/* Ignore error and complete */
|
/* Ignore error and complete */
|
||||||
mm_info ("[%s] MBIM device is not QMI capable",
|
mm_obj_info (self, "MBIM device is not QMI capable");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
self->priv->qmi_supported = FALSE;
|
self->priv->qmi_supported = FALSE;
|
||||||
} else {
|
} else {
|
||||||
mm_info ("[%s] MBIM device is QMI capable",
|
mm_obj_info (self, "MBIM device is QMI capable");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self->priv->in_progress = FALSE;
|
self->priv->in_progress = FALSE;
|
||||||
@@ -207,13 +203,10 @@ qmi_device_new_ready (GObject *unused,
|
|||||||
|
|
||||||
self->priv->qmi_device = qmi_device_new_finish (res, &error);
|
self->priv->qmi_device = qmi_device_new_finish (res, &error);
|
||||||
if (!self->priv->qmi_device) {
|
if (!self->priv->qmi_device) {
|
||||||
mm_dbg ("[%s] error: couldn't create QmiDevice: %s",
|
mm_obj_dbg (self, "error: couldn't create QmiDevice: %s", error->message);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
/* Ignore error and complete */
|
/* Ignore error and complete */
|
||||||
mm_info ("[%s] MBIM device is not QMI capable",
|
mm_obj_info (self, "MBIM device is not QMI capable");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
self->priv->qmi_supported = FALSE;
|
self->priv->qmi_supported = FALSE;
|
||||||
self->priv->in_progress = FALSE;
|
self->priv->in_progress = FALSE;
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
@@ -222,8 +215,7 @@ qmi_device_new_ready (GObject *unused,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Try to open using QMI over MBIM */
|
/* Try to open using QMI over MBIM */
|
||||||
mm_dbg ("[%s] trying to open QMI over MBIM device...",
|
mm_obj_dbg (self, "trying to open QMI over MBIM device...");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
qmi_device_open (self->priv->qmi_device,
|
qmi_device_open (self->priv->qmi_device,
|
||||||
(QMI_DEVICE_OPEN_FLAGS_PROXY |
|
(QMI_DEVICE_OPEN_FLAGS_PROXY |
|
||||||
QMI_DEVICE_OPEN_FLAGS_MBIM |
|
QMI_DEVICE_OPEN_FLAGS_MBIM |
|
||||||
@@ -272,7 +264,7 @@ mbim_query_device_services_ready (MbimDevice *device,
|
|||||||
mbim_device_service_element_array_free (device_services);
|
mbim_device_service_element_array_free (device_services);
|
||||||
} else {
|
} else {
|
||||||
/* Ignore error */
|
/* Ignore error */
|
||||||
mm_dbg ("Couldn't query device services, will attempt QMI open anyway: %s", error->message);
|
mm_obj_dbg (self, "Couldn't query device services, will attempt QMI open anyway: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +275,7 @@ mbim_query_device_services_ready (MbimDevice *device,
|
|||||||
file = G_FILE (g_task_get_task_data (task));
|
file = G_FILE (g_task_get_task_data (task));
|
||||||
|
|
||||||
if (!file || !self->priv->qmi_supported) {
|
if (!file || !self->priv->qmi_supported) {
|
||||||
mm_info ("[%s] MBIM device is not QMI capable",
|
mm_obj_info (self, "MBIM device is not QMI capable");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
self->priv->in_progress = FALSE;
|
self->priv->in_progress = FALSE;
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
@@ -292,8 +283,7 @@ mbim_query_device_services_ready (MbimDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to create and open the QMI device */
|
/* Attempt to create and open the QMI device */
|
||||||
mm_dbg ("[%s] checking if QMI over MBIM is supported",
|
mm_obj_dbg (self, "checking if QMI over MBIM is supported...");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
qmi_device_new (file,
|
qmi_device_new (file,
|
||||||
g_task_get_cancellable (task),
|
g_task_get_cancellable (task),
|
||||||
(GAsyncReadyCallback) qmi_device_new_ready,
|
(GAsyncReadyCallback) qmi_device_new_ready,
|
||||||
@@ -338,8 +328,7 @@ mbim_device_open_ready (MbimDevice *mbim_device,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_dbg ("[%s] MBIM device is now open",
|
mm_obj_dbg (self, "MBIM device is now open");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
|
|
||||||
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
if (self->priv->qmi_supported) {
|
if (self->priv->qmi_supported) {
|
||||||
@@ -507,10 +496,13 @@ qmi_device_close_ready (QmiDevice *qmi_device,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
MMPortMbim *self;
|
||||||
|
|
||||||
|
self = g_task_get_source_object (task);
|
||||||
|
|
||||||
if (!qmi_device_close_finish (qmi_device, res, &error)) {
|
if (!qmi_device_close_finish (qmi_device, res, &error)) {
|
||||||
mm_warn ("Couldn't properly close QMI device: %s", error->message);
|
mm_obj_warn (self, "Couldn't properly close QMI device: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +553,8 @@ mm_port_mbim_close (MMPortMbim *self,
|
|||||||
for (l = self->priv->qmi_clients; l; l = g_list_next (l)) {
|
for (l = self->priv->qmi_clients; l; l = g_list_next (l)) {
|
||||||
QmiClient *qmi_client = QMI_CLIENT (l->data);
|
QmiClient *qmi_client = QMI_CLIENT (l->data);
|
||||||
|
|
||||||
mm_dbg ("Releasing client for service '%s'...", qmi_service_get_string (qmi_client_get_service (qmi_client)));
|
mm_obj_dbg (self, "Releasing client for service '%s'...",
|
||||||
|
qmi_service_get_string (qmi_client_get_service (qmi_client)));
|
||||||
qmi_device_release_client (self->priv->qmi_device,
|
qmi_device_release_client (self->priv->qmi_device,
|
||||||
qmi_client,
|
qmi_client,
|
||||||
QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID,
|
QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID,
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
|
|
||||||
#include "mm-port-qmi.h"
|
#include "mm-port-qmi.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log-object.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMPortQmi, mm_port_qmi, MM_TYPE_PORT)
|
G_DEFINE_TYPE (MMPortQmi, mm_port_qmi, MM_TYPE_PORT)
|
||||||
|
|
||||||
@@ -254,10 +254,13 @@ qmi_device_close_on_error_ready (QmiDevice *qmi_device,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
MMPortQmi *self;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
self = g_task_get_source_object (task);
|
||||||
|
|
||||||
if (!qmi_device_close_finish (qmi_device, res, &error)) {
|
if (!qmi_device_close_finish (qmi_device, res, &error)) {
|
||||||
mm_warn ("Couldn't close QMI device after failed open sequence: %s", error->message);
|
mm_obj_warn (self, "Couldn't close QMI device after failed open sequence: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,12 +288,14 @@ qmi_device_close_to_reopen_ready (QmiDevice *qmi_device,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
MMPortQmi *self;
|
||||||
PortOpenContext *ctx;
|
PortOpenContext *ctx;
|
||||||
|
|
||||||
ctx = g_task_get_task_data (task);
|
self = g_task_get_source_object (task);
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
|
||||||
if (!qmi_device_close_finish (qmi_device, res, &ctx->error)) {
|
if (!qmi_device_close_finish (qmi_device, res, &ctx->error)) {
|
||||||
mm_warn ("Couldn't close QMI device to reopen it");
|
mm_obj_warn (self, "Couldn't close QMI device to reopen it");
|
||||||
ctx->step = PORT_OPEN_STEP_LAST;
|
ctx->step = PORT_OPEN_STEP_LAST;
|
||||||
} else
|
} else
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
@@ -302,10 +307,12 @@ get_data_format_ready (QmiClientWda *client,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
MMPortQmi *self;
|
||||||
PortOpenContext *ctx;
|
PortOpenContext *ctx;
|
||||||
QmiMessageWdaGetDataFormatOutput *output;
|
QmiMessageWdaGetDataFormatOutput *output;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
self = g_task_get_source_object (task);
|
||||||
ctx = g_task_get_task_data (task);
|
ctx = g_task_get_task_data (task);
|
||||||
output = qmi_client_wda_get_data_format_finish (client, res, NULL);
|
output = qmi_client_wda_get_data_format_finish (client, res, NULL);
|
||||||
if (!output ||
|
if (!output ||
|
||||||
@@ -316,7 +323,7 @@ get_data_format_ready (QmiClientWda *client,
|
|||||||
* When this happens, assume the device supports only raw-ip and be done
|
* When this happens, assume the device supports only raw-ip and be done
|
||||||
* with it. */
|
* with it. */
|
||||||
if (error && g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_MISSING_ARGUMENT)) {
|
if (error && g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_MISSING_ARGUMENT)) {
|
||||||
mm_dbg ("Querying data format failed: '%s', assuming raw-ip is only supported", error->message);
|
mm_obj_dbg (self, "Querying data format failed: '%s', assuming raw-ip is only supported", error->message);
|
||||||
ctx->llp = QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP;
|
ctx->llp = QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP;
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
} else {
|
} else {
|
||||||
@@ -406,12 +413,12 @@ port_open_step (GTask *task)
|
|||||||
ctx = g_task_get_task_data (task);
|
ctx = g_task_get_task_data (task);
|
||||||
switch (ctx->step) {
|
switch (ctx->step) {
|
||||||
case PORT_OPEN_STEP_FIRST:
|
case PORT_OPEN_STEP_FIRST:
|
||||||
mm_dbg ("Opening QMI device...");
|
mm_obj_dbg (self, "Opening QMI device...");
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
|
|
||||||
case PORT_OPEN_STEP_CHECK_OPENING:
|
case PORT_OPEN_STEP_CHECK_OPENING:
|
||||||
mm_dbg ("Checking if QMI device already opening...");
|
mm_obj_dbg (self, "Checking if QMI device already opening...");
|
||||||
if (self->priv->in_progress) {
|
if (self->priv->in_progress) {
|
||||||
g_task_return_new_error (task,
|
g_task_return_new_error (task,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
@@ -424,7 +431,7 @@ port_open_step (GTask *task)
|
|||||||
/* Fall through */
|
/* Fall through */
|
||||||
|
|
||||||
case PORT_OPEN_STEP_CHECK_ALREADY_OPEN:
|
case PORT_OPEN_STEP_CHECK_ALREADY_OPEN:
|
||||||
mm_dbg ("Checking if QMI device already open...");
|
mm_obj_dbg (self, "Checking if QMI device already open...");
|
||||||
if (self->priv->qmi_device) {
|
if (self->priv->qmi_device) {
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
@@ -445,7 +452,7 @@ port_open_step (GTask *task)
|
|||||||
* that all callbacks go through the LAST step for completing. */
|
* that all callbacks go through the LAST step for completing. */
|
||||||
self->priv->in_progress = TRUE;
|
self->priv->in_progress = TRUE;
|
||||||
|
|
||||||
mm_dbg ("Creating QMI device...");
|
mm_obj_dbg (self, "Creating QMI device...");
|
||||||
qmi_device_new (file,
|
qmi_device_new (file,
|
||||||
g_task_get_cancellable (task),
|
g_task_get_cancellable (task),
|
||||||
(GAsyncReadyCallback) qmi_device_new_ready,
|
(GAsyncReadyCallback) qmi_device_new_ready,
|
||||||
@@ -458,7 +465,7 @@ port_open_step (GTask *task)
|
|||||||
|
|
||||||
case PORT_OPEN_STEP_OPEN_WITHOUT_DATA_FORMAT:
|
case PORT_OPEN_STEP_OPEN_WITHOUT_DATA_FORMAT:
|
||||||
/* Now open the QMI device without any data format CTL flag */
|
/* Now open the QMI device without any data format CTL flag */
|
||||||
mm_dbg ("Opening device without data format update...");
|
mm_obj_dbg (self, "Opening device without data format update...");
|
||||||
qmi_device_open (ctx->device,
|
qmi_device_open (ctx->device,
|
||||||
(QMI_DEVICE_OPEN_FLAGS_VERSION_INFO |
|
(QMI_DEVICE_OPEN_FLAGS_VERSION_INFO |
|
||||||
QMI_DEVICE_OPEN_FLAGS_PROXY),
|
QMI_DEVICE_OPEN_FLAGS_PROXY),
|
||||||
@@ -469,7 +476,7 @@ port_open_step (GTask *task)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case PORT_OPEN_STEP_GET_KERNEL_DATA_FORMAT:
|
case PORT_OPEN_STEP_GET_KERNEL_DATA_FORMAT:
|
||||||
mm_dbg ("Querying kernel data format...");
|
mm_obj_dbg (self, "Querying kernel data format...");
|
||||||
/* Try to gather expected data format from the sysfs file */
|
/* Try to gather expected data format from the sysfs file */
|
||||||
ctx->kernel_data_format = qmi_device_get_expected_data_format (ctx->device, NULL);
|
ctx->kernel_data_format = qmi_device_get_expected_data_format (ctx->device, NULL);
|
||||||
/* If data format cannot be retrieved, we fallback to 802.3 via CTL */
|
/* If data format cannot be retrieved, we fallback to 802.3 via CTL */
|
||||||
@@ -483,7 +490,7 @@ port_open_step (GTask *task)
|
|||||||
|
|
||||||
case PORT_OPEN_STEP_ALLOCATE_WDA_CLIENT:
|
case PORT_OPEN_STEP_ALLOCATE_WDA_CLIENT:
|
||||||
/* Allocate WDA client */
|
/* Allocate WDA client */
|
||||||
mm_dbg ("Allocating WDA client...");
|
mm_obj_dbg (self, "Allocating WDA client...");
|
||||||
qmi_device_allocate_client (ctx->device,
|
qmi_device_allocate_client (ctx->device,
|
||||||
QMI_SERVICE_WDA,
|
QMI_SERVICE_WDA,
|
||||||
QMI_CID_NONE,
|
QMI_CID_NONE,
|
||||||
@@ -496,7 +503,7 @@ port_open_step (GTask *task)
|
|||||||
case PORT_OPEN_STEP_GET_WDA_DATA_FORMAT:
|
case PORT_OPEN_STEP_GET_WDA_DATA_FORMAT:
|
||||||
/* If we have WDA client, query current data format */
|
/* If we have WDA client, query current data format */
|
||||||
g_assert (ctx->wda);
|
g_assert (ctx->wda);
|
||||||
mm_dbg ("Querying device data format...");
|
mm_obj_dbg (self, "Querying device data format...");
|
||||||
qmi_client_wda_get_data_format (QMI_CLIENT_WDA (ctx->wda),
|
qmi_client_wda_get_data_format (QMI_CLIENT_WDA (ctx->wda),
|
||||||
NULL,
|
NULL,
|
||||||
10,
|
10,
|
||||||
@@ -508,9 +515,9 @@ port_open_step (GTask *task)
|
|||||||
case PORT_OPEN_STEP_CHECK_DATA_FORMAT:
|
case PORT_OPEN_STEP_CHECK_DATA_FORMAT:
|
||||||
/* We now have the WDA data format and the kernel data format, if they're
|
/* We now have the WDA data format and the kernel data format, if they're
|
||||||
* equal, we're done */
|
* equal, we're done */
|
||||||
mm_dbg ("Checking data format: kernel %s, device %s",
|
mm_obj_dbg (self, "Checking data format: kernel %s, device %s",
|
||||||
qmi_device_expected_data_format_get_string (ctx->kernel_data_format),
|
qmi_device_expected_data_format_get_string (ctx->kernel_data_format),
|
||||||
qmi_wda_link_layer_protocol_get_string (ctx->llp));
|
qmi_wda_link_layer_protocol_get_string (ctx->llp));
|
||||||
|
|
||||||
if (ctx->kernel_data_format == QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3 &&
|
if (ctx->kernel_data_format == QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3 &&
|
||||||
ctx->llp == QMI_WDA_LINK_LAYER_PROTOCOL_802_3) {
|
ctx->llp == QMI_WDA_LINK_LAYER_PROTOCOL_802_3) {
|
||||||
@@ -533,7 +540,7 @@ port_open_step (GTask *task)
|
|||||||
|
|
||||||
case PORT_OPEN_STEP_SET_KERNEL_DATA_FORMAT:
|
case PORT_OPEN_STEP_SET_KERNEL_DATA_FORMAT:
|
||||||
/* Update the data format to be expected by the kernel */
|
/* Update the data format to be expected by the kernel */
|
||||||
mm_dbg ("Updating kernel data format: %s", qmi_wda_link_layer_protocol_get_string (ctx->llp));
|
mm_obj_dbg (self, "Updating kernel data format: %s", qmi_wda_link_layer_protocol_get_string (ctx->llp));
|
||||||
if (ctx->llp == QMI_WDA_LINK_LAYER_PROTOCOL_802_3) {
|
if (ctx->llp == QMI_WDA_LINK_LAYER_PROTOCOL_802_3) {
|
||||||
ctx->kernel_data_format = QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3;
|
ctx->kernel_data_format = QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3;
|
||||||
self->priv->llp_is_raw_ip = FALSE;
|
self->priv->llp_is_raw_ip = FALSE;
|
||||||
@@ -552,7 +559,7 @@ port_open_step (GTask *task)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case PORT_OPEN_STEP_CLOSE_BEFORE_OPEN_WITH_DATA_FORMAT:
|
case PORT_OPEN_STEP_CLOSE_BEFORE_OPEN_WITH_DATA_FORMAT:
|
||||||
mm_dbg ("Closing device to reopen it right away...");
|
mm_obj_dbg (self, "Closing device to reopen it right away...");
|
||||||
qmi_device_close_async (ctx->device,
|
qmi_device_close_async (ctx->device,
|
||||||
5,
|
5,
|
||||||
g_task_get_cancellable (task),
|
g_task_get_cancellable (task),
|
||||||
@@ -562,7 +569,7 @@ port_open_step (GTask *task)
|
|||||||
|
|
||||||
case PORT_OPEN_STEP_OPEN_WITH_DATA_FORMAT:
|
case PORT_OPEN_STEP_OPEN_WITH_DATA_FORMAT:
|
||||||
/* Need to reopen setting 802.3 using CTL */
|
/* Need to reopen setting 802.3 using CTL */
|
||||||
mm_dbg ("Reopening device with data format...");
|
mm_obj_dbg (self, "Reopening device with data format...");
|
||||||
qmi_device_open (ctx->device,
|
qmi_device_open (ctx->device,
|
||||||
(QMI_DEVICE_OPEN_FLAGS_VERSION_INFO |
|
(QMI_DEVICE_OPEN_FLAGS_VERSION_INFO |
|
||||||
QMI_DEVICE_OPEN_FLAGS_PROXY |
|
QMI_DEVICE_OPEN_FLAGS_PROXY |
|
||||||
@@ -576,7 +583,7 @@ port_open_step (GTask *task)
|
|||||||
|
|
||||||
case PORT_OPEN_STEP_LAST:
|
case PORT_OPEN_STEP_LAST:
|
||||||
if (ctx->error) {
|
if (ctx->error) {
|
||||||
mm_dbg ("QMI port open operation failed: %s", ctx->error->message);
|
mm_obj_dbg (self, "QMI port open operation failed: %s", ctx->error->message);
|
||||||
|
|
||||||
if (ctx->device) {
|
if (ctx->device) {
|
||||||
qmi_device_close_async (ctx->device,
|
qmi_device_close_async (ctx->device,
|
||||||
@@ -591,7 +598,7 @@ port_open_step (GTask *task)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_dbg ("QMI port open operation finished successfully");
|
mm_obj_dbg (self, "QMI port open operation finished successfully");
|
||||||
|
|
||||||
/* Store device in private info */
|
/* Store device in private info */
|
||||||
g_assert (ctx->device);
|
g_assert (ctx->device);
|
||||||
@@ -721,7 +728,7 @@ mm_port_qmi_close (MMPortQmi *self,
|
|||||||
for (l = self->priv->services; l; l = g_list_next (l)) {
|
for (l = self->priv->services; l; l = g_list_next (l)) {
|
||||||
ServiceInfo *info = l->data;
|
ServiceInfo *info = l->data;
|
||||||
|
|
||||||
mm_dbg ("Releasing client for service '%s'...", qmi_service_get_string (info->service));
|
mm_obj_dbg (self, "Releasing client for service '%s'...", qmi_service_get_string (info->service));
|
||||||
qmi_device_release_client (ctx->qmi_device,
|
qmi_device_release_client (ctx->qmi_device,
|
||||||
info->client,
|
info->client,
|
||||||
QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID,
|
QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID,
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "mm-port-serial-at.h"
|
#include "mm-port-serial-at.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log-object.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMPortSerialAt, mm_port_serial_at, MM_TYPE_PORT_SERIAL)
|
G_DEFINE_TYPE (MMPortSerialAt, mm_port_serial_at, MM_TYPE_PORT_SERIAL)
|
||||||
|
|
||||||
@@ -435,10 +435,13 @@ mm_port_serial_at_command (MMPortSerialAt *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
|
debug_log (MMPortSerial *self,
|
||||||
|
const gchar *prefix,
|
||||||
|
const gchar *buf,
|
||||||
|
gsize len)
|
||||||
{
|
{
|
||||||
static GString *debug = NULL;
|
static GString *debug = NULL;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
if (!debug)
|
if (!debug)
|
||||||
debug = g_string_sized_new (256);
|
debug = g_string_sized_new (256);
|
||||||
@@ -461,7 +464,7 @@ debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_c (debug, '\'');
|
g_string_append_c (debug, '\'');
|
||||||
mm_dbg ("(%s): %s", mm_port_get_device (MM_PORT (port)), debug->str);
|
mm_obj_dbg (self, "%s", debug->str);
|
||||||
g_string_truncate (debug, 0);
|
g_string_truncate (debug, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +500,7 @@ mm_port_serial_at_run_init_sequence (MMPortSerialAt *self)
|
|||||||
if (!self->priv->init_sequence)
|
if (!self->priv->init_sequence)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mm_dbg ("(%s): running init sequence...", mm_port_get_device (MM_PORT (self)));
|
mm_obj_dbg (self, "running init sequence...");
|
||||||
|
|
||||||
/* Just queue the init commands, don't wait for reply */
|
/* Just queue the init commands, don't wait for reply */
|
||||||
for (i = 0; self->priv->init_sequence[i]; i++) {
|
for (i = 0; self->priv->init_sequence[i]; i++) {
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "mm-port-serial-gps.h"
|
#include "mm-port-serial-gps.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log-object.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMPortSerialGps, mm_port_serial_gps, MM_TYPE_PORT_SERIAL)
|
G_DEFINE_TYPE (MMPortSerialGps, mm_port_serial_gps, MM_TYPE_PORT_SERIAL)
|
||||||
|
|
||||||
@@ -135,10 +135,13 @@ parse_response (MMPortSerial *port,
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
|
debug_log (MMPortSerial *self,
|
||||||
|
const gchar *prefix,
|
||||||
|
const gchar *buf,
|
||||||
|
gsize len)
|
||||||
{
|
{
|
||||||
static GString *debug = NULL;
|
static GString *debug = NULL;
|
||||||
const char *s;
|
const gchar *s;
|
||||||
|
|
||||||
if (!debug)
|
if (!debug)
|
||||||
debug = g_string_sized_new (256);
|
debug = g_string_sized_new (256);
|
||||||
@@ -161,7 +164,7 @@ debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_c (debug, '\'');
|
g_string_append_c (debug, '\'');
|
||||||
mm_dbg ("(%s): %s", mm_port_get_device (MM_PORT (port)), debug->str);
|
mm_obj_dbg (self, "%s", debug->str);
|
||||||
g_string_truncate (debug, 0);
|
g_string_truncate (debug, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include "libqcdm/src/utils.h"
|
#include "libqcdm/src/utils.h"
|
||||||
#include "libqcdm/src/errors.h"
|
#include "libqcdm/src/errors.h"
|
||||||
#include "libqcdm/src/dm-commands.h"
|
#include "libqcdm/src/dm-commands.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log-object.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMPortSerialQcdm, mm_port_serial_qcdm, MM_TYPE_PORT_SERIAL)
|
G_DEFINE_TYPE (MMPortSerialQcdm, mm_port_serial_qcdm, MM_TYPE_PORT_SERIAL)
|
||||||
|
|
||||||
@@ -206,10 +206,13 @@ mm_port_serial_qcdm_command (MMPortSerialQcdm *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
|
debug_log (MMPortSerial *self,
|
||||||
|
const gchar *prefix,
|
||||||
|
const gchar *buf,
|
||||||
|
gsize len)
|
||||||
{
|
{
|
||||||
static GString *debug = NULL;
|
static GString *debug = NULL;
|
||||||
const char *s = buf;
|
const gchar *s = buf;
|
||||||
|
|
||||||
if (!debug)
|
if (!debug)
|
||||||
debug = g_string_sized_new (512);
|
debug = g_string_sized_new (512);
|
||||||
@@ -219,7 +222,7 @@ debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
|
|||||||
while (len--)
|
while (len--)
|
||||||
g_string_append_printf (debug, " %02x", (guint8) (*s++ & 0xFF));
|
g_string_append_printf (debug, " %02x", (guint8) (*s++ & 0xFF));
|
||||||
|
|
||||||
mm_dbg ("(%s): %s", mm_port_get_device (MM_PORT (port)), debug->str);
|
mm_obj_dbg (self, "%s", debug->str);
|
||||||
g_string_truncate (debug, 0);
|
g_string_truncate (debug, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
|
|
||||||
#include "mm-port-serial.h"
|
#include "mm-port-serial.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log-object.h"
|
||||||
#include "mm-helper-enums-types.h"
|
#include "mm-helper-enums-types.h"
|
||||||
|
|
||||||
static gboolean port_serial_queue_process (gpointer data);
|
static gboolean port_serial_queue_process (gpointer data);
|
||||||
@@ -398,11 +398,9 @@ internal_tcsetattr (MMPortSerial *self,
|
|||||||
memset (&other, 0, sizeof (struct termios));
|
memset (&other, 0, sizeof (struct termios));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (tcgetattr (fd, &other) != 0)
|
if (tcgetattr (fd, &other) != 0)
|
||||||
mm_dbg ("(%s): couldn't get serial port attributes after setting them: %s",
|
mm_obj_dbg (self, "couldn't get serial port attributes after setting them: %s", g_strerror (errno));
|
||||||
mm_port_get_device (MM_PORT (self)), g_strerror (errno));
|
|
||||||
else if (memcmp (options, &other, sizeof (struct termios)) != 0)
|
else if (memcmp (options, &other, sizeof (struct termios)) != 0)
|
||||||
mm_dbg ("(%s): port attributes not fully set",
|
mm_obj_dbg (self, "port attributes not fully set");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
|
|
||||||
#undef MAX_TCSETATTR_RETRIES
|
#undef MAX_TCSETATTR_RETRIES
|
||||||
|
|
||||||
@@ -430,19 +428,19 @@ set_flow_control_termios (MMPortSerial *self,
|
|||||||
/* setup the requested flags */
|
/* setup the requested flags */
|
||||||
switch (flow_control) {
|
switch (flow_control) {
|
||||||
case MM_FLOW_CONTROL_XON_XOFF:
|
case MM_FLOW_CONTROL_XON_XOFF:
|
||||||
mm_dbg ("(%s): enabling XON/XOFF flow control", mm_port_get_device (MM_PORT (self)));
|
mm_obj_dbg (self, "enabling XON/XOFF flow control");
|
||||||
options->c_iflag |= (IXON | IXOFF | IXANY);
|
options->c_iflag |= (IXON | IXOFF | IXANY);
|
||||||
break;
|
break;
|
||||||
case MM_FLOW_CONTROL_RTS_CTS:
|
case MM_FLOW_CONTROL_RTS_CTS:
|
||||||
mm_dbg ("(%s): enabling RTS/CTS flow control", mm_port_get_device (MM_PORT (self)));
|
mm_obj_dbg (self, "enabling RTS/CTS flow control");
|
||||||
options->c_cflag |= (CRTSCTS);
|
options->c_cflag |= (CRTSCTS);
|
||||||
break;
|
break;
|
||||||
case MM_FLOW_CONTROL_NONE:
|
case MM_FLOW_CONTROL_NONE:
|
||||||
case MM_FLOW_CONTROL_UNKNOWN:
|
case MM_FLOW_CONTROL_UNKNOWN:
|
||||||
if (had_xon_xoff)
|
if (had_xon_xoff)
|
||||||
mm_dbg ("(%s): disabling XON/XOFF flow control", mm_port_get_device (MM_PORT (self)));
|
mm_obj_dbg (self, "disabling XON/XOFF flow control");
|
||||||
if (had_rts_cts)
|
if (had_rts_cts)
|
||||||
mm_dbg ("(%s): disabling RTS/CTS flow control", mm_port_get_device (MM_PORT (self)));
|
mm_obj_dbg (self, "disabling RTS/CTS flow control");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
@@ -464,13 +462,9 @@ real_config_fd (MMPortSerial *self, int fd, GError **error)
|
|||||||
if (mm_port_get_subsys (MM_PORT (self)) != MM_PORT_SUBSYS_TTY)
|
if (mm_port_get_subsys (MM_PORT (self)) != MM_PORT_SUBSYS_TTY)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
mm_dbg ("(%s): setting up baudrate: %u",
|
mm_obj_dbg (self, "setting up baudrate: %u", self->priv->baud);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
self->priv->baud);
|
|
||||||
if (!parse_baudrate (self->priv->baud, &speed) || speed == B0) {
|
if (!parse_baudrate (self->priv->baud, &speed) || speed == B0) {
|
||||||
mm_warn ("(%s): baudrate invalid: %u; defaulting to 57600",
|
mm_obj_warn (self, "baudrate invalid: %u; defaulting to 57600", self->priv->baud);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
self->priv->baud);
|
|
||||||
speed = B57600;
|
speed = B57600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,11 +473,8 @@ real_config_fd (MMPortSerial *self, int fd, GError **error)
|
|||||||
stopbits = parse_stopbits (self->priv->stopbits);
|
stopbits = parse_stopbits (self->priv->stopbits);
|
||||||
|
|
||||||
memset (&stbuf, 0, sizeof (struct termios));
|
memset (&stbuf, 0, sizeof (struct termios));
|
||||||
if (tcgetattr (fd, &stbuf) != 0) {
|
if (tcgetattr (fd, &stbuf) != 0)
|
||||||
mm_warn ("(%s): tcgetattr() error: %d",
|
mm_obj_warn (self, "error getting serial port attributes: %s", g_strerror (errno));
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | PARENB | PARODD | CRTSCTS);
|
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | PARENB | PARODD | CRTSCTS);
|
||||||
stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXOFF | IXANY );
|
stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXOFF | IXANY );
|
||||||
@@ -523,13 +514,10 @@ real_config_fd (MMPortSerial *self, int fd, GError **error)
|
|||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
str = mm_flow_control_build_string_from_mask (self->priv->flow_control);
|
str = mm_flow_control_build_string_from_mask (self->priv->flow_control);
|
||||||
mm_dbg ("(%s): flow control explicitly requested for device is: %s",
|
mm_obj_dbg (self, "flow control explicitly requested for device is: %s", str ? str : "unknown");
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
str ? str : "unknown");
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
} else
|
} else
|
||||||
mm_dbg ("(%s): no flow control explicitly requested for device",
|
mm_obj_dbg (self, "no flow control explicitly requested for device");
|
||||||
mm_port_get_device (MM_PORT (self)));
|
|
||||||
|
|
||||||
set_flow_control_termios (self, self->priv->flow_control, &stbuf);
|
set_flow_control_termios (self, self->priv->flow_control, &stbuf);
|
||||||
|
|
||||||
@@ -537,7 +525,10 @@ real_config_fd (MMPortSerial *self, int fd, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
serial_debug (MMPortSerial *self, const char *prefix, const char *buf, gsize len)
|
serial_debug (MMPortSerial *self,
|
||||||
|
const gchar *prefix,
|
||||||
|
const gchar *buf,
|
||||||
|
gsize len)
|
||||||
{
|
{
|
||||||
g_return_if_fail (len > 0);
|
g_return_if_fail (len > 0);
|
||||||
|
|
||||||
@@ -569,7 +560,7 @@ port_serial_process_command (MMPortSerial *self,
|
|||||||
/* Only print command the first time */
|
/* Only print command the first time */
|
||||||
if (ctx->started == FALSE) {
|
if (ctx->started == FALSE) {
|
||||||
ctx->started = TRUE;
|
ctx->started = TRUE;
|
||||||
serial_debug (self, "-->", (const char *) ctx->command->data, ctx->command->len);
|
serial_debug (self, "-->", (const gchar *) ctx->command->data, ctx->command->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->priv->send_delay == 0 || mm_port_get_subsys (MM_PORT (self)) != MM_PORT_SUBSYS_TTY) {
|
if (self->priv->send_delay == 0 || mm_port_get_subsys (MM_PORT (self)) != MM_PORT_SUBSYS_TTY) {
|
||||||
@@ -616,7 +607,7 @@ port_serial_process_command (MMPortSerial *self,
|
|||||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
||||||
|
|
||||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||||
"Sending command failed: '%s'", strerror (errno));
|
"Sending command failed: '%s'", g_strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -651,7 +642,7 @@ port_serial_process_command (MMPortSerial *self,
|
|||||||
self->priv->n_consecutive_timeouts++;
|
self->priv->n_consecutive_timeouts++;
|
||||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
||||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||||
"Sending command failed: '%s'", strerror (errno));
|
"Sending command failed: '%s'", g_strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,15 +950,12 @@ common_input_available (MMPortSerial *self,
|
|||||||
gsize bytes_read;
|
gsize bytes_read;
|
||||||
GIOStatus status = G_IO_STATUS_NORMAL;
|
GIOStatus status = G_IO_STATUS_NORMAL;
|
||||||
CommandContext *ctx;
|
CommandContext *ctx;
|
||||||
const char *device;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean iterate = TRUE;
|
gboolean iterate = TRUE;
|
||||||
gboolean keep_source = G_SOURCE_CONTINUE;
|
gboolean keep_source = G_SOURCE_CONTINUE;
|
||||||
|
|
||||||
if (condition & G_IO_HUP) {
|
if (condition & G_IO_HUP) {
|
||||||
device = mm_port_get_device (MM_PORT (self));
|
mm_obj_dbg (self, "unexpected port hangup!");
|
||||||
mm_dbg ("(%s) unexpected port hangup!", device);
|
|
||||||
|
|
||||||
if (self->priv->response->len)
|
if (self->priv->response->len)
|
||||||
g_byte_array_remove_range (self->priv->response, 0, self->priv->response->len);
|
g_byte_array_remove_range (self->priv->response, 0, self->priv->response->len);
|
||||||
port_serial_close_force (self);
|
port_serial_close_force (self);
|
||||||
@@ -995,11 +983,8 @@ common_input_available (MMPortSerial *self,
|
|||||||
&bytes_read,
|
&bytes_read,
|
||||||
&error);
|
&error);
|
||||||
if (status == G_IO_STATUS_ERROR) {
|
if (status == G_IO_STATUS_ERROR) {
|
||||||
if (error) {
|
if (error)
|
||||||
mm_warn ("(%s): read error: %s",
|
mm_obj_warn (self, "read error: %s", error->message);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
error->message);
|
|
||||||
}
|
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
} else if (self->priv->socket) {
|
} else if (self->priv->socket) {
|
||||||
@@ -1016,9 +1001,7 @@ common_input_available (MMPortSerial *self,
|
|||||||
status = G_IO_STATUS_AGAIN;
|
status = G_IO_STATUS_AGAIN;
|
||||||
else
|
else
|
||||||
status = G_IO_STATUS_ERROR;
|
status = G_IO_STATUS_ERROR;
|
||||||
mm_warn ("(%s): receive error: %s",
|
mm_obj_warn (self, "receive error: %s", error->message);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
error->message);
|
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
} else {
|
} else {
|
||||||
bytes_read = (gsize) sbytes_read;
|
bytes_read = (gsize) sbytes_read;
|
||||||
@@ -1137,11 +1120,9 @@ port_connected (MMPortSerial *self, GParamSpec *pspec, gpointer user_data)
|
|||||||
connected = mm_port_get_connected (MM_PORT (self));
|
connected = mm_port_get_connected (MM_PORT (self));
|
||||||
|
|
||||||
if (self->priv->fd >= 0 && ioctl (self->priv->fd, (connected ? TIOCNXCL : TIOCEXCL)) < 0) {
|
if (self->priv->fd >= 0 && ioctl (self->priv->fd, (connected ? TIOCNXCL : TIOCEXCL)) < 0) {
|
||||||
mm_warn ("(%s): could not %s serial port lock: (%d) %s",
|
mm_obj_warn (self, "could not %s serial port lock: %s",
|
||||||
mm_port_get_device (MM_PORT (self)),
|
connected ? "drop" : "re-acquire",
|
||||||
connected ? "drop" : "re-acquire",
|
g_strerror (errno));
|
||||||
errno,
|
|
||||||
strerror (errno));
|
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
// FIXME: do something here, maybe try again in a few seconds or
|
// FIXME: do something here, maybe try again in a few seconds or
|
||||||
// close the port and error out?
|
// close the port and error out?
|
||||||
@@ -1197,7 +1178,7 @@ mm_port_serial_open (MMPortSerial *self, GError **error)
|
|||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_dbg ("(%s) opening serial port...", device);
|
mm_obj_dbg (self, "opening serial port...");
|
||||||
|
|
||||||
g_get_current_time (&tv_start);
|
g_get_current_time (&tv_start);
|
||||||
|
|
||||||
@@ -1221,7 +1202,6 @@ mm_port_serial_open (MMPortSerial *self, GError **error)
|
|||||||
MM_SERIAL_ERROR,
|
MM_SERIAL_ERROR,
|
||||||
(errno == ENODEV) ? MM_SERIAL_ERROR_OPEN_FAILED_NO_DEVICE : MM_SERIAL_ERROR_OPEN_FAILED,
|
(errno == ENODEV) ? MM_SERIAL_ERROR_OPEN_FAILED_NO_DEVICE : MM_SERIAL_ERROR_OPEN_FAILED,
|
||||||
"Could not open serial device %s: %s", device, strerror (errno_save));
|
"Could not open serial device %s: %s", device, strerror (errno_save));
|
||||||
mm_warn ("(%s) could not open serial device (%d)", device, errno_save);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1233,7 +1213,6 @@ mm_port_serial_open (MMPortSerial *self, GError **error)
|
|||||||
errno_save = errno;
|
errno_save = errno;
|
||||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_OPEN_FAILED,
|
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_OPEN_FAILED,
|
||||||
"Could not lock serial device %s: %s", device, strerror (errno_save));
|
"Could not lock serial device %s: %s", device, strerror (errno_save));
|
||||||
mm_warn ("(%s) could not lock serial device (%d)", device, errno_save);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1247,21 +1226,20 @@ mm_port_serial_open (MMPortSerial *self, GError **error)
|
|||||||
if (ioctl (self->priv->fd, TIOCGSERIAL, &sinfo) == 0) {
|
if (ioctl (self->priv->fd, TIOCGSERIAL, &sinfo) == 0) {
|
||||||
sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE;
|
sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE;
|
||||||
if (ioctl (self->priv->fd, TIOCSSERIAL, &sinfo) < 0)
|
if (ioctl (self->priv->fd, TIOCSSERIAL, &sinfo) < 0)
|
||||||
mm_warn ("(%s): couldn't set serial port closing_wait to none: %s",
|
mm_obj_warn (self, "couldn't set serial port closing_wait to none: %s", g_strerror (errno));
|
||||||
device, g_strerror (errno));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->config_fd);
|
g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->config_fd);
|
||||||
if (self->priv->fd >= 0 && !MM_PORT_SERIAL_GET_CLASS (self)->config_fd (self, self->priv->fd, error)) {
|
if (self->priv->fd >= 0 && !MM_PORT_SERIAL_GET_CLASS (self)->config_fd (self, self->priv->fd, error)) {
|
||||||
mm_dbg ("(%s) failed to configure serial device", device);
|
mm_obj_dbg (self, "failed to configure serial device");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_get_current_time (&tv_end);
|
g_get_current_time (&tv_end);
|
||||||
|
|
||||||
if (tv_end.tv_sec - tv_start.tv_sec > 7)
|
if (tv_end.tv_sec - tv_start.tv_sec > 7)
|
||||||
mm_warn ("(%s): open blocked by driver for more than 7 seconds!", device);
|
mm_obj_warn (self, "open blocked by driver for more than 7 seconds!");
|
||||||
|
|
||||||
if (mm_port_get_subsys (MM_PORT (self)) != MM_PORT_SUBSYS_UNIX) {
|
if (mm_port_get_subsys (MM_PORT (self)) != MM_PORT_SUBSYS_UNIX) {
|
||||||
/* Create new GIOChannel */
|
/* Create new GIOChannel */
|
||||||
@@ -1327,7 +1305,7 @@ mm_port_serial_open (MMPortSerial *self, GError **error)
|
|||||||
|
|
||||||
success:
|
success:
|
||||||
self->priv->open_count++;
|
self->priv->open_count++;
|
||||||
mm_dbg ("(%s) device open count is %d (open)", device, self->priv->open_count);
|
mm_obj_dbg (self, "device open count is %d (open)", self->priv->open_count);
|
||||||
|
|
||||||
/* Run additional port config if just opened */
|
/* Run additional port config if just opened */
|
||||||
if (self->priv->open_count == 1 && MM_PORT_SERIAL_GET_CLASS (self)->config)
|
if (self->priv->open_count == 1 && MM_PORT_SERIAL_GET_CLASS (self)->config)
|
||||||
@@ -1336,7 +1314,7 @@ success:
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
mm_warn ("(%s) failed to open serial device", device);
|
mm_obj_warn (self, "failed to open serial device");
|
||||||
|
|
||||||
if (self->priv->iochannel) {
|
if (self->priv->iochannel) {
|
||||||
g_io_channel_unref (self->priv->iochannel);
|
g_io_channel_unref (self->priv->iochannel);
|
||||||
@@ -1369,8 +1347,7 @@ mm_port_serial_is_open (MMPortSerial *self)
|
|||||||
static void
|
static void
|
||||||
_close_internal (MMPortSerial *self, gboolean force)
|
_close_internal (MMPortSerial *self, gboolean force)
|
||||||
{
|
{
|
||||||
const char *device;
|
guint i;
|
||||||
guint i;
|
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_PORT_SERIAL (self));
|
g_return_if_fail (MM_IS_PORT_SERIAL (self));
|
||||||
|
|
||||||
@@ -1381,9 +1358,7 @@ _close_internal (MMPortSerial *self, gboolean force)
|
|||||||
self->priv->open_count--;
|
self->priv->open_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
device = mm_port_get_device (MM_PORT (self));
|
mm_obj_dbg (self, "device open count is %d (close)", self->priv->open_count);
|
||||||
|
|
||||||
mm_dbg ("(%s) device open count is %d (close)", device, self->priv->open_count);
|
|
||||||
|
|
||||||
if (self->priv->open_count > 0)
|
if (self->priv->open_count > 0)
|
||||||
return;
|
return;
|
||||||
@@ -1402,7 +1377,7 @@ _close_internal (MMPortSerial *self, gboolean force)
|
|||||||
GTimeVal tv_start, tv_end;
|
GTimeVal tv_start, tv_end;
|
||||||
struct serial_struct sinfo = { 0 };
|
struct serial_struct sinfo = { 0 };
|
||||||
|
|
||||||
mm_dbg ("(%s) closing serial port...", device);
|
mm_obj_dbg (self, "closing serial port...");
|
||||||
|
|
||||||
mm_port_set_connected (MM_PORT (self), FALSE);
|
mm_port_set_connected (MM_PORT (self), FALSE);
|
||||||
|
|
||||||
@@ -1415,11 +1390,10 @@ _close_internal (MMPortSerial *self, gboolean force)
|
|||||||
*/
|
*/
|
||||||
if (ioctl (self->priv->fd, TIOCGSERIAL, &sinfo) == 0) {
|
if (ioctl (self->priv->fd, TIOCGSERIAL, &sinfo) == 0) {
|
||||||
if (sinfo.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
|
if (sinfo.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
|
||||||
mm_warn ("(%s): serial port closing_wait was reset!", device);
|
mm_obj_warn (self, "serial port closing_wait was reset!");
|
||||||
sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE;
|
sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE;
|
||||||
if (ioctl (self->priv->fd, TIOCSSERIAL, &sinfo) < 0)
|
if (ioctl (self->priv->fd, TIOCSSERIAL, &sinfo) < 0)
|
||||||
mm_warn ("(%s): couldn't set serial port closing_wait to none: %s",
|
mm_obj_warn (self, "couldn't set serial port closing_wait to none: %s", g_strerror (errno));
|
||||||
device, g_strerror (errno));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1452,7 +1426,7 @@ _close_internal (MMPortSerial *self, gboolean force)
|
|||||||
|
|
||||||
g_get_current_time (&tv_end);
|
g_get_current_time (&tv_end);
|
||||||
|
|
||||||
mm_dbg ("(%s) serial port closed", device);
|
mm_obj_dbg (self, "serial port closed");
|
||||||
|
|
||||||
/* Some ports don't respond to data and when close is called
|
/* Some ports don't respond to data and when close is called
|
||||||
* the serial layer waits up to 30 second (closing_wait) for
|
* the serial layer waits up to 30 second (closing_wait) for
|
||||||
@@ -1460,7 +1434,7 @@ _close_internal (MMPortSerial *self, gboolean force)
|
|||||||
* Log that. See GNOME bug #630670 for more details.
|
* Log that. See GNOME bug #630670 for more details.
|
||||||
*/
|
*/
|
||||||
if (tv_end.tv_sec - tv_start.tv_sec > 7)
|
if (tv_end.tv_sec - tv_start.tv_sec > 7)
|
||||||
mm_warn ("(%s): close blocked by driver for more than 7 seconds!", device);
|
mm_obj_warn (self, "close blocked by driver for more than 7 seconds!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the command queue */
|
/* Clear the command queue */
|
||||||
@@ -1514,7 +1488,7 @@ port_serial_close_force (MMPortSerial *self)
|
|||||||
if (self->priv->forced_close)
|
if (self->priv->forced_close)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mm_dbg ("(%s) forced to close port", mm_port_get_device (MM_PORT (self)));
|
mm_obj_dbg (self, "forced to close port");
|
||||||
|
|
||||||
/* Mark as having forced the close, so that we don't warn about incorrect
|
/* Mark as having forced the close, so that we don't warn about incorrect
|
||||||
* open counts */
|
* open counts */
|
||||||
@@ -1651,9 +1625,7 @@ mm_port_serial_reopen (MMPortSerial *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_dbg ("(%s) reopening port (%u)",
|
mm_obj_dbg (self, "reopening port (%u)", ctx->initial_open_count);
|
||||||
mm_port_get_device (MM_PORT (self)),
|
|
||||||
ctx->initial_open_count);
|
|
||||||
|
|
||||||
for (i = 0; i < ctx->initial_open_count; i++)
|
for (i = 0; i < ctx->initial_open_count; i++)
|
||||||
mm_port_serial_close (self);
|
mm_port_serial_close (self);
|
||||||
@@ -1896,16 +1868,14 @@ mm_port_serial_set_flow_control (MMPortSerial *self,
|
|||||||
|
|
||||||
/* Return if current settings are already what we want */
|
/* Return if current settings are already what we want */
|
||||||
if (!set_flow_control_termios (self, flow_control, &options)) {
|
if (!set_flow_control_termios (self, flow_control, &options)) {
|
||||||
mm_dbg ("(%s): no need to change flow control settings: already %s",
|
mm_obj_dbg (self, "no need to change flow control settings: already %s", flow_control_str);
|
||||||
mm_port_get_device (MM_PORT (self)), flow_control_str);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!internal_tcsetattr (self, self->priv->fd, &options, &inner_error))
|
if (!internal_tcsetattr (self, self->priv->fd, &options, &inner_error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
mm_dbg ("(%s): flow control settings updated to %s",
|
mm_obj_dbg (self, "flow control settings updated to %s", flow_control_str);
|
||||||
mm_port_get_device (MM_PORT (self)), flow_control_str);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (flow_control_str);
|
g_free (flow_control_str);
|
||||||
|
@@ -93,12 +93,12 @@ struct _MMPortSerialClass {
|
|||||||
|
|
||||||
/* Called to configure the serial port after it's opened. Errors, if any,
|
/* Called to configure the serial port after it's opened. Errors, if any,
|
||||||
* should get ignored. */
|
* should get ignored. */
|
||||||
void (*config) (MMPortSerial *self);
|
void (*config) (MMPortSerial *self);
|
||||||
|
|
||||||
void (*debug_log) (MMPortSerial *self,
|
void (*debug_log) (MMPortSerial *self,
|
||||||
const char *prefix,
|
const gchar *prefix,
|
||||||
const char *buf,
|
const gchar *buf,
|
||||||
gsize len);
|
gsize len);
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
|
void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
|
||||||
|
@@ -19,9 +19,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "mm-port.h"
|
#include "mm-port.h"
|
||||||
#include "mm-log.h"
|
#include "mm-port-enums-types.h"
|
||||||
|
#include "mm-log-object.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMPort, mm_port, G_TYPE_OBJECT)
|
static void log_object_iface_init (MMLogObjectInterface *iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_EXTENDED (MMPort, mm_port, G_TYPE_OBJECT, 0,
|
||||||
|
G_IMPLEMENT_INTERFACE (MM_TYPE_LOG_OBJECT, log_object_iface_init))
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@@ -88,10 +92,7 @@ mm_port_set_connected (MMPort *self, gboolean connected)
|
|||||||
if (self->priv->connected != connected) {
|
if (self->priv->connected != connected) {
|
||||||
self->priv->connected = connected;
|
self->priv->connected = connected;
|
||||||
g_object_notify (G_OBJECT (self), MM_PORT_CONNECTED);
|
g_object_notify (G_OBJECT (self), MM_PORT_CONNECTED);
|
||||||
|
mm_obj_dbg (self, "port now %s", connected ? "connected" : "disconnected");
|
||||||
mm_dbg ("(%s): port now %s",
|
|
||||||
self->priv->device,
|
|
||||||
connected ? "connected" : "disconnected");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +106,19 @@ mm_port_peek_kernel_device (MMPort *self)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
log_object_build_id (MMLogObject *_self)
|
||||||
|
{
|
||||||
|
MMPort *self;
|
||||||
|
|
||||||
|
self = MM_PORT (_self);
|
||||||
|
return g_strdup_printf ("%s/%s",
|
||||||
|
mm_port_get_device (self),
|
||||||
|
mm_modem_port_type_get_string (mm_port_get_port_type (self)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mm_port_init (MMPort *self)
|
mm_port_init (MMPort *self)
|
||||||
{
|
{
|
||||||
@@ -194,6 +208,12 @@ dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (mm_port_parent_class)->dispose (object);
|
G_OBJECT_CLASS (mm_port_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
log_object_iface_init (MMLogObjectInterface *iface)
|
||||||
|
{
|
||||||
|
iface->build_id = log_object_build_id;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mm_port_class_init (MMPortClass *klass)
|
mm_port_class_init (MMPortClass *klass)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user