Skip to contentSkip to conversation

Extended modem.conf

PATCH In review Ryan Raasch 3 participants 5 messages Oct 26, 2009 – Oct 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Extended modem.conf

Hello,

This a patch for allowing the addition of more options to the generic atgen driver. Comments :) ?

[generic]
Driver=atgen
Device=/dev/ttyS0
Baud=115200
Read=on
Local=on

Thanks,
Ryan

gatchat/gattty.c +8 -8
index f18eca4..64dd8ab 100644
@@ -208,21 +208,21 @@ static int open_device(const char *tty, GHashTable *options)
 							(void *) &value)) {
 			gboolean ok = FALSE;
 
-			if (g_str_equal(key, "baud"))
+			if (g_str_equal(key, "Baud"))
 				ok = set_baud(value, &ti);
-			else if (g_str_equal(key, "stopbits"))
+			else if (g_str_equal(key, "StopBits"))
 				ok = set_stop_bits(value, &ti);
-			else if (g_str_equal(key, "databits"))
+			else if (g_str_equal(key, "DataBits"))
 				ok = set_data_bits(value, &ti);
-			else if (g_str_equal(key, "parity"))
+			else if (g_str_equal(key, "Parity"))
 				ok = set_parity(value, &ti);
-			else if (g_str_equal(key, "xonxoff"))
+			else if (g_str_equal(key, "XonXoff"))
 				ok = set_xonxoff(value, &ti);
-			else if (g_str_equal(key, "rtscts"))
+			else if (g_str_equal(key, "Rtscts"))
 				ok = set_rtscts(value, &ti);
-			else if (g_str_equal(key, "local"))
+			else if (g_str_equal(key, "Local"))
 				ok = set_local(value, &ti);
-			else if (g_str_equal(key, "read"))
+			else if (g_str_equal(key, "Read"))
 				ok = set_read(value, &ti);
 
 			if (ok == FALSE)
plugins/atgen.c +35 -1
index c0fbbb2..133472b 100644
@@ -48,6 +48,24 @@
 #include <ofono/ussd.h>
 #include <ofono/voicecall.h>
 
+static const char* _tty_opts[] =
+  {
+    "Baud",
+    "Read",
+    "Local",
+    "StopBits",
+    "DataBits",
+    "Parity",
+    "XonXoff",
+    "Rtscts",
+    NULL,
+  };
+
+static void _unregister_option(gpointer data)
+{
+	g_free(data);
+}
+
 static int atgen_probe(struct ofono_modem *modem)
 {
 	return 0;
@@ -68,14 +86,28 @@ static int atgen_enable(struct ofono_modem *modem)
 	GIOChannel *channel;
 	GAtSyntax *syntax;
 	const char *device;
+	const char *value;
+	GHashTable *options = NULL;
+	int i = 0;
 
 	DBG("%p", modem);
 
+	options = g_hash_table_new_full(g_str_hash, g_str_equal,
+					g_free, _unregister_option);
+
 	device = ofono_modem_get_string(modem, "Device");
 	if (!device)
 		return -EINVAL;
 
-	channel = g_at_tty_open(device, NULL);
+	while(_tty_opts[i])
+	  {
+	    value = ofono_modem_get_string(modem, _tty_opts[i]);
+	    if(value)
+	      g_hash_table_replace(options, g_strdup(_tty_opts[i]), g_strdup(value));
+	    i++;
+	  };
+
+	channel = g_at_tty_open(device, options);
 	if (!channel)
 		return -EIO;
 
@@ -92,6 +124,8 @@ static int atgen_enable(struct ofono_modem *modem)
 
 	ofono_modem_set_data(modem, chat);
 
+	g_hash_table_destroy(options);
+
 	return 0;
 }
 
plugins/modemconf.c +66 -2

82 lines not on this page · raw message

#1 lore raw

I found a few improvements.

plugins/atgen.c

* Added check of null pointer
* Release dynamic memory upon all exits

BTW. Pardon for possibly replying to the wrong thread. My gmail settings (if i remember correctly), do not send me a copy of the email, so i cannot reply to it, ugggh. So i use my mail reader.

Ryan

Quoted 12 lines · Ryan Raasch

Hello,

This a patch for allowing the addition of more options to the generic atgen driver. Comments :) ?

[generic]
Driver=atgen
Device=/dev/ttyS0
Baud=115200
Read=on
Local=on

Quoted 3 lines

Thanks,
Ryan

gatchat/gattty.c +8 -8
index f18eca4..64dd8ab 100644
@@ -208,21 +208,21 @@ static int open_device(const char *tty, GHashTable *options)
 							(void *) &value)) {
 			gboolean ok = FALSE;
 
-			if (g_str_equal(key, "baud"))
+			if (g_str_equal(key, "Baud"))
 				ok = set_baud(value, &ti);
-			else if (g_str_equal(key, "stopbits"))
+			else if (g_str_equal(key, "StopBits"))
 				ok = set_stop_bits(value, &ti);
-			else if (g_str_equal(key, "databits"))
+			else if (g_str_equal(key, "DataBits"))
 				ok = set_data_bits(value, &ti);
-			else if (g_str_equal(key, "parity"))
+			else if (g_str_equal(key, "Parity"))
 				ok = set_parity(value, &ti);
-			else if (g_str_equal(key, "xonxoff"))
+			else if (g_str_equal(key, "XonXoff"))
 				ok = set_xonxoff(value, &ti);
-			else if (g_str_equal(key, "rtscts"))
+			else if (g_str_equal(key, "Rtscts"))
 				ok = set_rtscts(value, &ti);
-			else if (g_str_equal(key, "local"))
+			else if (g_str_equal(key, "Local"))
 				ok = set_local(value, &ti);
-			else if (g_str_equal(key, "read"))
+			else if (g_str_equal(key, "Read"))
 				ok = set_read(value, &ti);
 
 			if (ok == FALSE)
plugins/atgen.c +44 -3

79 lines not on this page · raw message

plugins/modemconf.c +66 -2

82 lines not on this page · raw message

#2 lore raw
In reply to Ryan Raasch

Hi Ryan,

Quoted 4 lines

Hello,

This a patch for allowing the addition of more options to the generic atgen driver. Comments :) ?

Before I look further into this, please re-submit the patch and follow the oFono code style conventions. oFono uses kernel coding style and no maintainer will even look at patches that do not follow this convention.

Regards,
-Denis

#3 lore raw
Quoted 11 lines · On Mon, 26 Oct 2009 12:46:26 -0500 Denis Kenzior <[email protected]> wrote:

Hi Ryan,

Quoted 4 lines

Hello,

This a patch for allowing the addition of more options to the generic atgen driver. Comments :) ?

Before I look further into this, please re-submit the patch and follow the oFono code style conventions. oFono uses kernel coding style and no maintainer will even look at patches that do not follow this convention.

Also, it would be helpful if the patch was inline so that people could easily comment on various pieces of it in their replies.

#4 lore raw

An updated patch for the addition of serial options in the modem.conf file. I used the kernel coding style.

Quoted 9 lines · Andres Salomon
Quoted 6 lines · On Mon, 26 Oct 2009 12:46:26 -0500 Denis Kenzior <[email protected]> wrote:

Hi Ryan,

Quoted 4 lines

Hello,

This a patch for allowing the addition of more options to the generic atgen driver. Comments :) ?

Quoted 8 lines
Quoted 4 lines

Before I look further into this, please re-submit the patch and follow the oFono code style conventions. oFono uses kernel coding style and no maintainer will even look at patches that do not follow this convention.

Also, it would be helpful if the patch was inline so that people could easily comment on various pieces of it in their replies.

Using git imap-send, does anyone know how to use this with git-diff instead of making a commit, using
format-patch, then reversing the commit? It is a patch for approval.

---
  gatchat/gattty.c    |   16 ++++++------
  plugins/atgen.c     |   49 +++++++++++++++++++++++++++++++++++--
  plugins/modemconf.c |   67 
++++++++++++++++++++++++++++++++++++++++++++++++++-
  3 files changed, 120 insertions(+), 12 deletions(-)
gatchat/gattty.c +0 -0
index f18eca4..64dd8ab 100644
@@ -208,21 +208,21 @@ static int open_device(const char *tty, GHashTable 

*options)
(void *) &value)) {
gboolean ok = FALSE;

- if (g_str_equal(key, "baud"))
+ if (g_str_equal(key, "Baud"))
ok = set_baud(value, &ti);
- else if (g_str_equal(key, "stopbits"))
+ else if (g_str_equal(key, "StopBits"))
ok = set_stop_bits(value, &ti);
- else if (g_str_equal(key, "databits"))
+ else if (g_str_equal(key, "DataBits"))
ok = set_data_bits(value, &ti);
- else if (g_str_equal(key, "parity"))
+ else if (g_str_equal(key, "Parity"))
ok = set_parity(value, &ti);
- else if (g_str_equal(key, "xonxoff"))
+ else if (g_str_equal(key, "XonXoff"))
ok = set_xonxoff(value, &ti);
- else if (g_str_equal(key, "rtscts"))
+ else if (g_str_equal(key, "Rtscts"))
ok = set_rtscts(value, &ti);
- else if (g_str_equal(key, "local"))
+ else if (g_str_equal(key, "Local"))
ok = set_local(value, &ti);
- else if (g_str_equal(key, "read"))
+ else if (g_str_equal(key, "Read"))
ok = set_read(value, &ti);

if (ok == FALSE)

plugins/atgen.c +46 -3

81 lines not on this page · raw message

plugins/modemconf.c +66 -1

79 lines not on this page · raw message

Signature · 1 line
1.6.4.GIT
Quoted 4 lines

_______________________________________________
ofono mailing list
ofono(a)ofono.org
http://lists.ofono.org/listinfo/ofono