* [PATCH v2 0/1] Add telephony_str_to_error to decode error code @ 2010-05-12 8:12 Zhenhua Zhang 2010-05-12 8:12 ` [PATCH v2 1/1] " Zhenhua Zhang 0 siblings, 1 reply; 4+ messages in thread From: Zhenhua Zhang @ 2010-05-12 8:12 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 123 bytes --] Please ignore my previous patch. It's the update version to fix a bug in array size. Thanks Gu Yang to point out that. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/1] Add telephony_str_to_error to decode error code 2010-05-12 8:12 [PATCH v2 0/1] Add telephony_str_to_error to decode error code Zhenhua Zhang @ 2010-05-12 8:12 ` Zhenhua Zhang 2010-05-12 19:02 ` Denis Kenzior 0 siblings, 1 reply; 4+ messages in thread From: Zhenhua Zhang @ 2010-05-12 8:12 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2705 bytes --] Use to decode a final error string to error code. --- drivers/atmodem/atutil.c | 7 +++---- src/common.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/common.h | 1 + 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c index 5a409b8..5b0f3fd 100644 --- a/drivers/atmodem/atutil.c +++ b/drivers/atmodem/atutil.c @@ -34,16 +34,15 @@ #include "atutil.h" #include "vendor.h" +#include "common.h" void decode_at_error(struct ofono_error *error, const char *final) { if (!strcmp(final, "OK")) { error->type = OFONO_ERROR_TYPE_NO_ERROR; error->error = 0; - } else { - error->type = OFONO_ERROR_TYPE_FAILURE; - error->error = 0; - } + } else + telephony_str_to_error(final, error); } gint at_util_call_compare_by_status(gconstpointer a, gconstpointer b) diff --git a/src/common.c b/src/common.c index 4eaff5e..b693dd9 100644 --- a/src/common.c +++ b/src/common.c @@ -290,6 +290,47 @@ const char *telephony_error_to_str(const struct ofono_error *error) return "Unknown error"; } +static gboolean search_entry(const char *str, struct error_entry *e, + int maxentries, + enum ofono_error_type type, + struct ofono_error *error) +{ + int i; + + for (i = 0; i < maxentries; i++) { + if (!strcmp(e[i].str, str)) { + error->type = type; + error->error = e[i].error; + return TRUE; + } + } + + return FALSE; +} + +void telephony_str_to_error(const char *str, struct ofono_error *error) +{ + int maxentries; + + maxentries = sizeof(cme_errors) / sizeof(struct error_entry); + if (search_entry(str, cme_errors, maxentries, OFONO_ERROR_TYPE_CME, + error)) + return; + + maxentries = sizeof(cms_errors) / sizeof(struct error_entry); + if (search_entry(str, cms_errors, maxentries, OFONO_ERROR_TYPE_CMS, + error)) + return; + + maxentries = sizeof(ceer_errors) / sizeof(struct error_entry); + if (search_entry(str, ceer_errors, maxentries, OFONO_ERROR_TYPE_CEER, + error)) + return; + + error->type = OFONO_ERROR_TYPE_FAILURE; + error->error = 0; +} + int mmi_service_code_to_bearer_class(int code) { int cls = 0; diff --git a/src/common.h b/src/common.h index c43e46d..ec917d1 100644 --- a/src/common.h +++ b/src/common.h @@ -123,6 +123,7 @@ enum pin_type { }; const char *telephony_error_to_str(const struct ofono_error *error); +void telephony_str_to_error(const char *str, struct ofono_error *error); gboolean valid_phone_number_format(const char *number); const char *phone_number_to_string(const struct ofono_phone_number *ph); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] Add telephony_str_to_error to decode error code 2010-05-12 8:12 ` [PATCH v2 1/1] " Zhenhua Zhang @ 2010-05-12 19:02 ` Denis Kenzior 2010-05-13 2:09 ` Zhang, Zhenhua 0 siblings, 1 reply; 4+ messages in thread From: Denis Kenzior @ 2010-05-12 19:02 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 802 bytes --] Hi Zhenhua, > +static gboolean search_entry(const char *str, struct error_entry *e, > + int maxentries, > + enum ofono_error_type type, > + struct ofono_error *error) > +{ > + int i; > + > + for (i = 0; i < maxentries; i++) { > + if (!strcmp(e[i].str, str)) { > + error->type = type; > + error->error = e[i].error; > + return TRUE; > + } > + } > + > + return FALSE; > +} This doesn't really make sense, the errors from the modem usually come in the form of +CMS ERROR: 123 assuming we enabled +CMEE=1. If we enabled +CMEE=2 then the numeric error code gets converted to a string. The former is preferable as the string might be different from what oFono has. What you're matching here will always result in an unknown error. Regards, -Denis ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2 1/1] Add telephony_str_to_error to decode error code 2010-05-12 19:02 ` Denis Kenzior @ 2010-05-13 2:09 ` Zhang, Zhenhua 0 siblings, 0 replies; 4+ messages in thread From: Zhang, Zhenhua @ 2010-05-13 2:09 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 943 bytes --] Hi Denis, Denis Kenzior wrote: > Hi Zhenhua, > >> +static gboolean search_entry(const char *str, struct error_entry >> *e, + int maxentries, + enum > ofono_error_type type, >> + struct > ofono_error *error) >> +{ >> + int i; >> + >> + for (i = 0; i < maxentries; i++) { >> + if (!strcmp(e[i].str, str)) { >> + error->type = type; >> + error->error = e[i].error; >> + return TRUE; >> + } >> + } >> + >> + return FALSE; >> +} > > This doesn't really make sense, the errors from the modem > usually come in the form of +CMS ERROR: 123 assuming we > enabled +CMEE=1. If we enabled +CMEE=2 then the numeric error > code gets converted to a string. The former is preferable as > the string might be different from what oFono has. What > you're matching here will always result in an unknown error. > > Regards, > -Denis My wrong. I will resend the patch soon. Regards, Zhenhua ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-13 2:09 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-05-12 8:12 [PATCH v2 0/1] Add telephony_str_to_error to decode error code Zhenhua Zhang 2010-05-12 8:12 ` [PATCH v2 1/1] " Zhenhua Zhang 2010-05-12 19:02 ` Denis Kenzior 2010-05-13 2:09 ` Zhang, Zhenhua
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.