broadband-modem: set flow control from port
Set the flow control used in the data connection from the one set in the port.
This commit is contained in:

committed by
Dan Williams

parent
94879ce1ce
commit
e3c2f0e9cc
@@ -3313,6 +3313,9 @@ ifc_test_ready (MMBaseModem *_self,
|
|||||||
const gchar *response;
|
const gchar *response;
|
||||||
MMFlowControl mask;
|
MMFlowControl mask;
|
||||||
const gchar *cmd;
|
const gchar *cmd;
|
||||||
|
MMFlowControl flow_control = MM_FLOW_CONTROL_UNKNOWN;
|
||||||
|
MMPortSerialAt *port;
|
||||||
|
const gchar *err_str = NULL;
|
||||||
|
|
||||||
self = MM_BROADBAND_MODEM (_self);
|
self = MM_BROADBAND_MODEM (_self);
|
||||||
|
|
||||||
@@ -3326,22 +3329,63 @@ ifc_test_ready (MMBaseModem *_self,
|
|||||||
if (mask == MM_FLOW_CONTROL_UNKNOWN)
|
if (mask == MM_FLOW_CONTROL_UNKNOWN)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* We prefer the methods in this order:
|
port = mm_base_modem_peek_best_at_port (_self, &error);
|
||||||
* RTS/CTS
|
if (!port)
|
||||||
* XON/XOFF
|
goto out;
|
||||||
* None.
|
|
||||||
*/
|
flow_control = mm_port_serial_get_flow_control (MM_PORT_SERIAL (port));
|
||||||
if (mask & MM_FLOW_CONTROL_RTS_CTS) {
|
|
||||||
self->priv->flow_control = MM_FLOW_CONTROL_RTS_CTS;
|
switch (flow_control) {
|
||||||
cmd = "+IFC=2,2";
|
case MM_FLOW_CONTROL_RTS_CTS:
|
||||||
} else if (mask & MM_FLOW_CONTROL_XON_XOFF) {
|
if (mask & MM_FLOW_CONTROL_RTS_CTS) {
|
||||||
self->priv->flow_control = MM_FLOW_CONTROL_XON_XOFF;
|
self->priv->flow_control = MM_FLOW_CONTROL_RTS_CTS;
|
||||||
cmd = "+IFC=1,1";
|
cmd = "+IFC=2,2";
|
||||||
} else if (mask & MM_FLOW_CONTROL_NONE) {
|
} else
|
||||||
self->priv->flow_control = MM_FLOW_CONTROL_NONE;
|
err_str = "RTS/CTS";
|
||||||
cmd = "+IFC=0,0";
|
break;
|
||||||
} else
|
case MM_FLOW_CONTROL_XON_XOFF:
|
||||||
g_assert_not_reached ();
|
if (mask & MM_FLOW_CONTROL_XON_XOFF) {
|
||||||
|
self->priv->flow_control = MM_FLOW_CONTROL_XON_XOFF;
|
||||||
|
cmd = "+IFC=1,1";
|
||||||
|
} else
|
||||||
|
err_str = "xon/xoff";
|
||||||
|
break;
|
||||||
|
case MM_FLOW_CONTROL_NONE:
|
||||||
|
if (mask & MM_FLOW_CONTROL_NONE) {
|
||||||
|
self->priv->flow_control = MM_FLOW_CONTROL_NONE;
|
||||||
|
cmd = "+IFC=0,0";
|
||||||
|
} else
|
||||||
|
err_str = "none";
|
||||||
|
break;
|
||||||
|
case MM_FLOW_CONTROL_UNKNOWN:
|
||||||
|
/* If flow control is not set explicitly by udev tags,
|
||||||
|
* we prefer the methods in this order:
|
||||||
|
* RTS/CTS
|
||||||
|
* XON/XOFF
|
||||||
|
* None.
|
||||||
|
*/
|
||||||
|
if (mask & MM_FLOW_CONTROL_RTS_CTS) {
|
||||||
|
self->priv->flow_control = MM_FLOW_CONTROL_RTS_CTS;
|
||||||
|
cmd = "+IFC=2,2";
|
||||||
|
} else if (mask & MM_FLOW_CONTROL_XON_XOFF) {
|
||||||
|
self->priv->flow_control = MM_FLOW_CONTROL_XON_XOFF;
|
||||||
|
cmd = "+IFC=1,1";
|
||||||
|
} else if (mask & MM_FLOW_CONTROL_NONE) {
|
||||||
|
self->priv->flow_control = MM_FLOW_CONTROL_NONE;
|
||||||
|
cmd = "+IFC=0,0";
|
||||||
|
} else
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err_str) {
|
||||||
|
g_set_error (&error,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_FAILED,
|
||||||
|
"%s: failed to set serial flow control to %s",
|
||||||
|
__func__, err_str);
|
||||||
|
goto fatal;
|
||||||
|
}
|
||||||
|
|
||||||
/* Notify the flow control property update */
|
/* Notify the flow control property update */
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FLOW_CONTROL]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FLOW_CONTROL]);
|
||||||
@@ -3358,6 +3402,11 @@ out:
|
|||||||
|
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
|
return;
|
||||||
|
|
||||||
|
fatal:
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user