Re: [MM] [PATCH v3] serial: Add support to optionally send line-feed at the end of AT commands.



On Thu, 2013-02-28 at 16:34 +0100, Aleksander Morgado wrote:
On 02/28/2013 03:20 PM, Dan Williams wrote:
Also, are you going to suggest a new plugin for MM using this property
set to TRUE? If so, it may be a good idea to send all relevant commits,
including this one, in the same patch series, along with the plugin.
Now that I think about it, is there any reason we're not doing this for
*all* devices?  Do you think any devices would care?  I'm not near my
pile-of-modems at this time, but at least the E362 and my
Longcheer-based Zoom 4597 don't care whether there's a <LF> at the end
of every command.

Good point, it probably isn't a big deal if we add that by default. Ori,
are you able to provide a patch for that?

I did hack that up already when testing with my Zoom and the E362, so
here we go as a first-pass.  Ori, can you test this and make sure it
works on your device?

Thanks!
Dan

diff --git a/src/mm-at-serial-port.c b/src/mm-at-serial-port.c
index 7962622..7e3da4c 100644
--- a/src/mm-at-serial-port.c
+++ b/src/mm-at-serial-port.c
@@ -306,8 +306,10 @@ at_command_to_byte_array (const char *command, gboolean is_raw)
 
     if (!is_raw) {
         /* Make sure there's a trailing carriage return */
-        if (command[cmdlen - 1] != '\r')
+        if (command[cmdlen - 1] != '\r' && command[cmdlen - 2] != '\r')
             g_byte_array_append (buf, (const guint8 *) "\r", 1);
+        if (command[cmdlen - 1] != '\n' && command[cmdlen - 2] != '\n')
+            g_byte_array_append (buf, (const guint8 *) "\n", 1);
     }
 
     return buf;




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]