plugin: let plugins decide if they want echo removal during AT probing
This is the port to git master of the following patch: commit 21e66dfa1774ac2ee037ac8b6e8bb4d71a6f7931 Author: Dan Williams <dcbw@redhat.com> Date: Thu Aug 23 21:13:35 2012 -0500 core: add function to open probe ports without removing echo Some devices (Sierra GSM ones) return stuff we need but don't bother to prefix it with <CR><LF>, so we need to optionally turn off the echo removal at probe time.
This commit is contained in:
@@ -69,6 +69,7 @@ struct _MMPluginPrivate {
|
|||||||
MMPortProbeAtCommand *custom_at_probe;
|
MMPortProbeAtCommand *custom_at_probe;
|
||||||
MMAsyncMethod *custom_init;
|
MMAsyncMethod *custom_init;
|
||||||
guint64 send_delay;
|
guint64 send_delay;
|
||||||
|
gboolean remove_echo;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -93,6 +94,7 @@ enum {
|
|||||||
PROP_CUSTOM_AT_PROBE,
|
PROP_CUSTOM_AT_PROBE,
|
||||||
PROP_CUSTOM_INIT,
|
PROP_CUSTOM_INIT,
|
||||||
PROP_SEND_DELAY,
|
PROP_SEND_DELAY,
|
||||||
|
PROP_REMOVE_ECHO,
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -658,6 +660,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
mm_port_probe_run (probe,
|
mm_port_probe_run (probe,
|
||||||
ctx->flags,
|
ctx->flags,
|
||||||
self->priv->send_delay,
|
self->priv->send_delay,
|
||||||
|
self->priv->remove_echo,
|
||||||
self->priv->custom_at_probe,
|
self->priv->custom_at_probe,
|
||||||
self->priv->custom_init,
|
self->priv->custom_init,
|
||||||
(GAsyncReadyCallback)port_probe_run_ready,
|
(GAsyncReadyCallback)port_probe_run_ready,
|
||||||
@@ -737,6 +740,7 @@ mm_plugin_init (MMPlugin *self)
|
|||||||
|
|
||||||
/* Defaults */
|
/* Defaults */
|
||||||
self->priv->send_delay = 100000;
|
self->priv->send_delay = 100000;
|
||||||
|
self->priv->remove_echo = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -828,6 +832,10 @@ set_property (GObject *object,
|
|||||||
/* Construct only */
|
/* Construct only */
|
||||||
self->priv->send_delay = (guint64)g_value_get_uint64 (value);
|
self->priv->send_delay = (guint64)g_value_get_uint64 (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_REMOVE_ECHO:
|
||||||
|
/* Construct only */
|
||||||
|
self->priv->remove_echo = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -903,6 +911,9 @@ get_property (GObject *object,
|
|||||||
case PROP_SEND_DELAY:
|
case PROP_SEND_DELAY:
|
||||||
g_value_set_uint64 (value, self->priv->send_delay);
|
g_value_set_uint64 (value, self->priv->send_delay);
|
||||||
break;
|
break;
|
||||||
|
case PROP_REMOVE_ECHO:
|
||||||
|
g_value_set_boolean (value, self->priv->remove_echo);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -1104,4 +1115,12 @@ mm_plugin_class_init (MMPluginClass *klass)
|
|||||||
"in microseconds",
|
"in microseconds",
|
||||||
0, G_MAXUINT64, 100000,
|
0, G_MAXUINT64, 100000,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_REMOVE_ECHO,
|
||||||
|
g_param_spec_boolean (MM_PLUGIN_REMOVE_ECHO,
|
||||||
|
"Remove echo",
|
||||||
|
"Remove echo out of the AT responses",
|
||||||
|
TRUE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,7 @@
|
|||||||
#define MM_PLUGIN_CUSTOM_INIT "custom-init"
|
#define MM_PLUGIN_CUSTOM_INIT "custom-init"
|
||||||
#define MM_PLUGIN_CUSTOM_AT_PROBE "custom-at-probe"
|
#define MM_PLUGIN_CUSTOM_AT_PROBE "custom-at-probe"
|
||||||
#define MM_PLUGIN_SEND_DELAY "send-delay"
|
#define MM_PLUGIN_SEND_DELAY "send-delay"
|
||||||
|
#define MM_PLUGIN_REMOVE_ECHO "remove-echo"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED = 0x0,
|
MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED = 0x0,
|
||||||
|
@@ -78,6 +78,8 @@ typedef struct {
|
|||||||
GCancellable *at_probing_cancellable;
|
GCancellable *at_probing_cancellable;
|
||||||
/* Send delay for AT commands */
|
/* Send delay for AT commands */
|
||||||
guint64 at_send_delay;
|
guint64 at_send_delay;
|
||||||
|
/* Flag to leave/remove echo in AT responses */
|
||||||
|
gboolean at_remove_echo;
|
||||||
/* Number of times we tried to open the AT port */
|
/* Number of times we tried to open the AT port */
|
||||||
guint at_open_tries;
|
guint at_open_tries;
|
||||||
/* Custom initialization setup */
|
/* Custom initialization setup */
|
||||||
@@ -905,6 +907,7 @@ serial_open_at (MMPortProbe *self)
|
|||||||
|
|
||||||
g_object_set (task->serial,
|
g_object_set (task->serial,
|
||||||
MM_SERIAL_PORT_SEND_DELAY, task->at_send_delay,
|
MM_SERIAL_PORT_SEND_DELAY, task->at_send_delay,
|
||||||
|
MM_AT_SERIAL_PORT_REMOVE_ECHO, task->at_remove_echo,
|
||||||
MM_PORT_CARRIER_DETECT, FALSE,
|
MM_PORT_CARRIER_DETECT, FALSE,
|
||||||
MM_SERIAL_PORT_SPEW_CONTROL, TRUE,
|
MM_SERIAL_PORT_SPEW_CONTROL, TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
@@ -1025,6 +1028,7 @@ void
|
|||||||
mm_port_probe_run (MMPortProbe *self,
|
mm_port_probe_run (MMPortProbe *self,
|
||||||
MMPortProbeFlag flags,
|
MMPortProbeFlag flags,
|
||||||
guint64 at_send_delay,
|
guint64 at_send_delay,
|
||||||
|
gboolean at_remove_echo,
|
||||||
const MMPortProbeAtCommand *at_custom_probe,
|
const MMPortProbeAtCommand *at_custom_probe,
|
||||||
const MMAsyncMethod *at_custom_init,
|
const MMAsyncMethod *at_custom_init,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
@@ -1043,6 +1047,7 @@ mm_port_probe_run (MMPortProbe *self,
|
|||||||
|
|
||||||
task = g_new0 (PortProbeRunTask, 1);
|
task = g_new0 (PortProbeRunTask, 1);
|
||||||
task->at_send_delay = at_send_delay;
|
task->at_send_delay = at_send_delay;
|
||||||
|
task->at_remove_echo = at_remove_echo;
|
||||||
task->flags = MM_PORT_PROBE_NONE;
|
task->flags = MM_PORT_PROBE_NONE;
|
||||||
task->at_custom_probe = at_custom_probe;
|
task->at_custom_probe = at_custom_probe;
|
||||||
task->at_custom_init = at_custom_init ? (MMPortProbeAtCustomInit)at_custom_init->async : NULL;
|
task->at_custom_init = at_custom_init ? (MMPortProbeAtCustomInit)at_custom_init->async : NULL;
|
||||||
|
@@ -103,6 +103,7 @@ void mm_port_probe_set_result_qmi (MMPortProbe *self,
|
|||||||
void mm_port_probe_run (MMPortProbe *self,
|
void mm_port_probe_run (MMPortProbe *self,
|
||||||
MMPortProbeFlag flags,
|
MMPortProbeFlag flags,
|
||||||
guint64 at_send_delay,
|
guint64 at_send_delay,
|
||||||
|
gboolean at_remove_echo,
|
||||||
const MMPortProbeAtCommand *at_custom_probe,
|
const MMPortProbeAtCommand *at_custom_probe,
|
||||||
const MMAsyncMethod *at_custom_init,
|
const MMAsyncMethod *at_custom_init,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
|
Reference in New Issue
Block a user