aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplugins/mm-modem-samsung-gsm.c5
-rw-r--r--src/mm-serial-port.c24
2 files changed, 21 insertions, 8 deletions
diff --git a/plugins/mm-modem-samsung-gsm.c b/plugins/mm-modem-samsung-gsm.c
index 19b6ba63..2f28c054 100755
--- a/plugins/mm-modem-samsung-gsm.c
+++ b/plugins/mm-modem-samsung-gsm.c
@@ -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);
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index 7f10beb1..f05a1aea 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -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,