Skip to contentSkip to conversation

Inserted the GSM syntax option in modem.conf.

PATCH In review Ryan M. Raasch 3 participants 4 messages Oct 29, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Inserted the GSM syntax option in modem.conf.

Hello,

Since the modems need to be setup in particular ways, this patch allows for the GSM syntax to be specified by the configuration file.

Regards,
Ryan

---
 plugins/atgen.c     |    9 ++++++++-
 plugins/modemconf.c |    6 ++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
plugins/atgen.c +8 -1
index db59e36..67a1e8c 100644
@@ -117,7 +117,14 @@ static int atgen_enable(struct ofono_modem *modem)
 		return -EIO;
 	}
 
-	syntax = g_at_syntax_new_gsmv1();
+	value = ofono_modem_get_string(modem, "GsmSyntax");
+	if (value && g_str_equal(value, "GSM_V1"))
+		syntax = g_at_syntax_new_gsmv1();
+	else if (value && g_str_equal(value, "GSM_Permissive"))
+		syntax = g_at_syntax_new_gsm_permissive();
+	else if (value)
+		return -EINVAL;
+
 	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
 	g_io_channel_unref(channel);
plugins/modemconf.c +6 -0
index 6b317e6..a5e5824 100644
@@ -138,6 +138,12 @@ static int set_device(struct ofono_modem *modem,
 	} else
 		ofono_modem_set_string(modem, "Rtscts", "on");
 
+	value = g_key_file_get_string(keyfile, group, "GsmSyntax", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "GsmSyntax", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "GsmSyntax", "GSM_V1");
 
 	return 0;
 }
Signature · 1 line
1.6.4.GIT
#1 lore raw
Quoted 6 lines · On Thu, 29 Oct 2009 12:04:23 +0100 "Ryan M. Raasch" <[email protected]>…

Hello,

Since the modems need to be setup in particular ways, this patch allows for the GSM syntax to be specified by the configuration file.

I like this a whole lot better than having to write a new plugin for every piece of hardware that doesn't work with the strict parser.

#2 lore raw
In reply to Ryan M. Raasch

Hi Ryan,

Quoted 14 lines

Since the modems need to be setup in particular ways, this patch allows for the GSM syntax to be specified by the configuration file.

---
 plugins/atgen.c     |    9 ++++++++-
 plugins/modemconf.c |    6 ++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
plugins/atgen.c +0 -0
index db59e36..67a1e8c 100644
@@ -117,7 +117,14 @@ static int atgen_enable(struct ofono_modem *modem)
 		return -EIO;
 	}

plugins/atgen.c static int atgen_enable(struct ofono_modem *modem) · line 127

Quoted 10 lines
plugins/atgen.c +8 -1
 
-	syntax = g_at_syntax_new_gsmv1();
+	value = ofono_modem_get_string(modem, "GsmSyntax");
+	if (value && g_str_equal(value, "GSM_V1"))
+		syntax = g_at_syntax_new_gsmv1();
+	else if (value && g_str_equal(value, "GSM_Permissive"))
+		syntax = g_at_syntax_new_gsm_permissive();
+	else if (value)
+		return -EINVAL;
+

first of all, stop checking value all the time. It is fine to have nested ifs here. And second you duplicate GSM in the parameter name and also in the value. So just call it V1 and Permissive.

Quoted 8 lines
plugins/atgen.c +0 -0
 	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
 	g_io_channel_unref(channel);
plugins/modemconf.c +0 -0
index 6b317e6..a5e5824 100644

plugins/modemconf.c static int set_device(struct ofono_modem *modem, · line 147

Quoted 10 lines
plugins/modemconf.c +6 -0
@@ -138,6 +138,12 @@ static int set_device(struct ofono_modem *modem,
 	} else
 		ofono_modem_set_string(modem, "Rtscts", "on");
 
+	value = g_key_file_get_string(keyfile, group, "GsmSyntax", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "GsmSyntax", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "GsmSyntax", "GSM_V1");
 

Did you check that this applies cleanly against latest GIT tree?

Regards

Marcel

#3 lore raw
Quoted 17 lines · Marcel Holtmann

Hi Ryan,

Quoted 15 lines

Since the modems need to be setup in particular ways, this patch allows for the GSM syntax to be specified by the configuration file.

---
 plugins/atgen.c     |    9 ++++++++-
 plugins/modemconf.c |    6 ++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
plugins/atgen.c +0 -0
index db59e36..67a1e8c 100644
@@ -117,7 +117,14 @@ static int atgen_enable(struct ofono_modem *modem)
 		return -EIO;
 	}
 
Quoted 14 lines

plugins/atgen.c static int atgen_enable(struct ofono_modem *modem) · line 127

Quoted 9 lines
plugins/atgen.c +8 -1
-	syntax = g_at_syntax_new_gsmv1();
+	value = ofono_modem_get_string(modem, "GsmSyntax");
+	if (value && g_str_equal(value, "GSM_V1"))
+		syntax = g_at_syntax_new_gsmv1();
+	else if (value && g_str_equal(value, "GSM_Permissive"))
+		syntax = g_at_syntax_new_gsm_permissive();
+	else if (value)
+		return -EINVAL;
+

first of all, stop checking value all the time. It is fine to have nested ifs here. And second you duplicate GSM in the parameter name and also in the value. So just call it V1 and Permissive.

Will do.

Quoted 11 lines
Quoted 11 lines
plugins/atgen.c +0 -0
 	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
 	g_io_channel_unref(channel);
plugins/modemconf.c +0 -0
index 6b317e6..a5e5824 100644
@@ -138,6 +138,12 @@ static int set_device(struct ofono_modem *modem,
 	} else
 		ofono_modem_set_string(modem, "Rtscts", "on");
 
Quoted 10 lines

plugins/modemconf.c static int set_device(struct ofono_modem *modem, · line 147

Quoted 7 lines
plugins/modemconf.c +6 -0
+	value = g_key_file_get_string(keyfile, group, "GsmSyntax", NULL);
+	if (value) {
+		ofono_modem_set_string(modem, "GsmSyntax", value);
+		g_free(value);
+	} else
+		ofono_modem_set_string(modem, "GsmSyntax", "GSM_V1");
 

Did you check that this applies cleanly against latest GIT tree?

You got me there. The 2 outstanding patches for modemconf need to be applied first (wooops). I will make a new set of patches for all the modemconf changes.

Greetings,
Ryan

Quoted 5 lines

Regards

Marcel