serial: send entire command in one write if send_delay is 0 (chromium:13506)
Avoids additional USB latency and groups the whole command into one USB packet. BUG=chromium-os:13506
This commit is contained in:
@@ -1112,7 +1112,10 @@ grab_port (MMModem *modem,
|
||||
if (port && MM_IS_AT_SERIAL_PORT (port)) {
|
||||
GRegex *regex;
|
||||
|
||||
g_object_set (port, MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
g_object_set (port,
|
||||
MM_PORT_CARRIER_DETECT, FALSE,
|
||||
MM_SERIAL_PORT_SEND_DELAY, (guint64) 0,
|
||||
NULL);
|
||||
|
||||
/* %NWSTATE: <rssi>,<mccmnc>,<tech>,<connected>,<regulation> */
|
||||
regex = g_regex_new ("\\r\\n\\%NWSTATE: (\\d),(\\d+),\\s*([^,\\s]*)\\s*,(.+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
|
@@ -373,7 +373,7 @@ mm_serial_port_process_command (MMSerialPort *self,
|
||||
{
|
||||
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
|
||||
const guint8 *p;
|
||||
int status;
|
||||
int status, expected_status, send_len;
|
||||
|
||||
if (priv->fd < 0) {
|
||||
g_set_error_literal (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||
@@ -393,14 +393,24 @@ mm_serial_port_process_command (MMSerialPort *self,
|
||||
serial_debug (self, "-->", (const char *) info->command->data, info->command->len);
|
||||
}
|
||||
|
||||
if (priv->send_delay == 0) {
|
||||
/* Send the whole command in one write */
|
||||
send_len = expected_status = info->command->len;
|
||||
p = info->command->data;
|
||||
} else {
|
||||
/* Send just one byte of the command */
|
||||
send_len = expected_status = 1;
|
||||
p = &info->command->data[info->idx];
|
||||
}
|
||||
|
||||
/* Send a single byte of the command */
|
||||
p = &info->command->data[info->idx];
|
||||
errno = 0;
|
||||
status = write (priv->fd, p, 1);
|
||||
if (status == 1)
|
||||
info->idx++;
|
||||
else if (status < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
status = write (priv->fd, p, send_len);
|
||||
if (status > 0)
|
||||
info->idx += status;
|
||||
else {
|
||||
/* Error or no bytes written */
|
||||
if (errno == EAGAIN || status == 0) {
|
||||
info->eagain_count--;
|
||||
if (info->eagain_count <= 0) {
|
||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||
|
Reference in New Issue
Block a user