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:
Alfonso Sánchez-Beato
2018-09-03 09:09:17 +02:00
committed by Dan Williams
parent 94879ce1ce
commit e3c2f0e9cc

View File

@@ -3313,6 +3313,9 @@ ifc_test_ready (MMBaseModem *_self,
const gchar *response;
MMFlowControl mask;
const gchar *cmd;
MMFlowControl flow_control = MM_FLOW_CONTROL_UNKNOWN;
MMPortSerialAt *port;
const gchar *err_str = NULL;
self = MM_BROADBAND_MODEM (_self);
@@ -3326,7 +3329,37 @@ ifc_test_ready (MMBaseModem *_self,
if (mask == MM_FLOW_CONTROL_UNKNOWN)
goto out;
/* We prefer the methods in this order:
port = mm_base_modem_peek_best_at_port (_self, &error);
if (!port)
goto out;
flow_control = mm_port_serial_get_flow_control (MM_PORT_SERIAL (port));
switch (flow_control) {
case MM_FLOW_CONTROL_RTS_CTS:
if (mask & MM_FLOW_CONTROL_RTS_CTS) {
self->priv->flow_control = MM_FLOW_CONTROL_RTS_CTS;
cmd = "+IFC=2,2";
} else
err_str = "RTS/CTS";
break;
case MM_FLOW_CONTROL_XON_XOFF:
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.
@@ -3342,6 +3375,17 @@ ifc_test_ready (MMBaseModem *_self,
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 */
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FLOW_CONTROL]);
@@ -3358,6 +3402,11 @@ out:
g_task_return_boolean (task, TRUE);
g_object_unref (task);
return;
fatal:
g_task_return_error (task, error);
g_object_unref (task);
}
static void