All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Extended  modem.conf
@ 2009-10-26 11:02 Ryan Raasch
  2009-10-26 13:33 ` Ryan Raasch
  2009-10-26 17:46 ` Denis Kenzior
  0 siblings, 2 replies; 7+ messages in thread
From: Ryan Raasch @ 2009-10-26 11:02 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 206 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: generic_atgen_opts.patch --]
[-- Type: text/x-patch, Size: 4855 bytes --]

diff --git a/gatchat/gattty.c b/gatchat/gattty.c
index f18eca4..64dd8ab 100644
--- a/gatchat/gattty.c
+++ b/gatchat/gattty.c
@@ -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)
diff --git a/plugins/atgen.c b/plugins/atgen.c
index c0fbbb2..133472b 100644
--- a/plugins/atgen.c
+++ b/plugins/atgen.c
@@ -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;
 }
 
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 192faa6..71aad81 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -72,16 +72,80 @@ static int set_address(struct ofono_modem *modem,
 static int set_device(struct ofono_modem *modem,
 					GKeyFile *keyfile, const char *group)
 {
-	char *device;
+	char *device, *value;
 
 	device = g_key_file_get_string(keyfile, group, "Device", NULL);
 	if (!device)
 		return -EINVAL;
 
 	ofono_modem_set_string(modem, "Device", device);
-
 	g_free(device);
 
+	value = g_key_file_get_string(keyfile, group, "Baud", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Baud", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "Baud", "115200");
+
+	value = g_key_file_get_string(keyfile, group, "Read", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Read", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "Read", "on");
+
+	value = g_key_file_get_string(keyfile, group, "Local", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Local", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "Local", "none");
+
+	value = g_key_file_get_string(keyfile, group, "StopBits", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "StopBits", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "StopBits", "1");
+
+	value = g_key_file_get_string(keyfile, group, "DataBits", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "DataBits", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "Databits", "8");
+
+	value = g_key_file_get_string(keyfile, group, "Parity", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Parity", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "Parity", "none");
+
+	value = g_key_file_get_string(keyfile, group, "XonXoff", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "XonXoff", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "XonXoff", "off");
+
+	value = g_key_file_get_string(keyfile, group, "Rtscts", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Rtscts", value);
+		g_free(value);
+	}
+	else
+		ofono_modem_set_string(modem, "Rtscts", "on");
+
+
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] Extended modem.conf
@ 2009-10-27  9:42 Ryan Raasch
  2009-10-27 11:20 ` Marcel Holtmann
  0 siblings, 1 reply; 7+ messages in thread
From: Ryan Raasch @ 2009-10-27  9:42 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 5862 bytes --]

Allright. This is the one to consider. I used the checkpatch.pl, which
informed me of my wayward ways.

I read from previous mails that the signed-off is not needed, is that
still in effect?

Sorry for the noise.

Regards,
Ryan

---
 gatchat/gattty.c    |   16 +++++++-------
 plugins/atgen.c     |   48 ++++++++++++++++++++++++++++++++++++++--
 plugins/modemconf.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 111 insertions(+), 12 deletions(-)

diff --git a/gatchat/gattty.c b/gatchat/gattty.c
index f18eca4..64dd8ab 100644
--- a/gatchat/gattty.c
+++ b/gatchat/gattty.c
@@ -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)
diff --git a/plugins/atgen.c b/plugins/atgen.c
index c0fbbb2..db59e36 100644
--- a/plugins/atgen.c
+++ b/plugins/atgen.c
@@ -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_tty_option(gpointer data)
+{
+	g_free(data);
+}
+
 static int atgen_probe(struct ofono_modem *modem)
 {
 	return 0;
@@ -68,6 +86,9 @@ static int atgen_enable(struct ofono_modem *modem)
 	GIOChannel *channel;
 	GAtSyntax *syntax;
 	const char *device;
+	const char *value;
+	GHashTable *options;
+	int i = 0;

 	DBG("%p", modem);

@@ -75,23 +96,44 @@ static int atgen_enable(struct ofono_modem *modem)
 	if (!device)
 		return -EINVAL;

-	channel = g_at_tty_open(device, NULL);
-	if (!channel)
+	options = g_hash_table_new_full(g_str_hash, g_str_equal,
+					g_free, unregister_tty_option);
+	if (!options)
+		return -ENOMEM;
+
+	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) {
+		g_hash_table_destroy(options);
 		return -EIO;
+	}

 	syntax = g_at_syntax_new_gsmv1();
 	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
 	g_io_channel_unref(channel);

-	if (!chat)
+	if (!chat) {
+		g_hash_table_destroy(options);
 		return -ENOMEM;
+	}

 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(chat, atgen_debug, NULL);

 	ofono_modem_set_data(modem, chat);

+	g_hash_table_destroy(options);
+
 	return 0;
 }

diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 192faa6..6b317e6 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -72,7 +72,7 @@ static int set_address(struct ofono_modem *modem,
 static int set_device(struct ofono_modem *modem,
 					GKeyFile *keyfile, const char *group)
 {
-	char *device;
+	char *device, *value;

 	device = g_key_file_get_string(keyfile, group, "Device", NULL);
 	if (!device)
@@ -82,6 +82,63 @@ static int set_device(struct ofono_modem *modem,

 	g_free(device);

+	value = g_key_file_get_string(keyfile, group, "Baud", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Baud", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "Baud", "115200");
+
+	value = g_key_file_get_string(keyfile, group, "Read", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Read", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "Read", "on");
+
+	value = g_key_file_get_string(keyfile, group, "Local", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Local", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "Local", "none");
+
+	value = g_key_file_get_string(keyfile, group, "StopBits", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "StopBits", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "StopBits", "1");
+
+	value = g_key_file_get_string(keyfile, group, "DataBits", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "DataBits", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "Databits", "8");
+
+	value = g_key_file_get_string(keyfile, group, "Parity", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Parity", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "Parity", "none");
+
+	value = g_key_file_get_string(keyfile, group, "XonXoff", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "XonXoff", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "XonXoff", "off");
+
+	value = g_key_file_get_string(keyfile, group, "Rtscts", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "Rtscts", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "Rtscts", "on");
+
+
 	return 0;
 }

-- 
1.6.4.GIT

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-10-27 11:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-26 11:02 [PATCH 1/1] Extended modem.conf Ryan Raasch
2009-10-26 13:33 ` Ryan Raasch
2009-10-26 17:46 ` Denis Kenzior
2009-10-27  4:38   ` Andres Salomon
2009-10-27  8:45     ` Ryan Raasch
  -- strict thread matches above, loose matches on Subject: below --
2009-10-27  9:42 Ryan Raasch
2009-10-27 11:20 ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.