wd and cc

— Happy every day

debian下面解决gnokii读取短信的bug

Posted at — Dec 6, 2006
上一篇文章提到过gnokii读取AT模式下设备的短信的时候会有问题,从xh那里看到了解决方法,自己也goolgle了一下,总结一下debian(sarge)下面解决这个问题的方法。
故障现象如下:
[...]
Message sent: 0x12 / 0x0009
41 54 2b 43 50 4d 53 3f 0d                      | AT+CPMS?
write: [AT+CPMS?]
read : [AT+CPMS?+CPMS:
"SM",2,30,"SM",2,30OK]
Message received: 0x12 / 0x002d
02 41 54 2b 43 50 4d 53 3f 0d 0d 0a 2b 43 50 4d |  AT+CPMS?   +CPM
53 3a 20 22 53 4d 22 2c 32 2c 33 30 2c 22 53 4d | S: "SM",2,30,"SM
22 2c 32 2c 33 30 0d 0a 0d 0a 4f 4b 0d          | ",2,30    OK
Received message type 12
GetSMS SM 1 failed! (Command failed.)
Serial device: closing device
还有一个smsd的问题:
解决这个问题需要给gnokii打一个补丁,debian下面就需要自己来制作一个包,参考 构建 Debian 软件包 这篇文章,操作如下。

首先下载包的源代码:
此时他会在当前目录下面下载并解压gnokii的源代码包,并且打上debian需要的patch。此时需要将下面的patch给gnokii打上,修改都是针对common/phones/atgen.c的。
+++ atgen.c     2006-12-06 12:40:59.201314062 +0800
@@ -537,22 +537,15 @@
{
at_driver_instance *drvinst = AT_DRVINST(state);
gn_data data;
-       gn_sms_status sms_status;
char req[32];
gn_error ret = GN_ERR_NONE;

if (mt != drvinst->smsmemorytype) {
gn_data_clear(&data);
-               data.sms_status = &sms_status;
-               ret = AT_GetSMSStatus(&data, state);
+               sprintf(req, "AT+CPMS=\"%s\"r", memorynames[mt]);
+               ret = sm_message_send(13, GN_OP_Init, req, state);
if (ret != GN_ERR_NONE)
return ret;
-
-               sprintf(req, "AT+CPMS=\"%s\",\"%s\",\"%s\"r", memorynames[mt], memorynames[mt],
-                       memorynames[data.sms_status->new_message_store]);
-               ret = sm_message_send(23, GN_OP_Init, req, state);
-               if (ret != GN_ERR_NONE)
-                       return GN_ERR_NOTREADY;
ret = sm_block_no_retry(GN_OP_Init, &data, state);
if (ret == GN_ERR_NONE)
drvinst->smsmemorytype = mt;
@@ -1355,7 +1348,10 @@

if (sscanf(buf.line2, "+CPMS: \"%*c%*c\",%d,%*d,\"%*c%*c\",%*d,%*d,\"%c%c\",%*d,%*d",
&data->sms_status->number, &store[0], &store[1]) != 3)
-               return GN_ERR_FAILED;
+
+               if (sscanf(buf.line2, "+CPMS: \"%c%c\",%d,%*d,\"%*c%*c\",%*d,%*d",
+                                       &store[0], &store[1], &data->sms_status->number) != 3)
+                       return GN_ERR_FAILED;

data->sms_status->unread = 0;
data->sms_status->changed = 0;
把上面的内容保存一下,比如取名为cant_get_sms.patch,或者来这里下载,然后执行下面的命令:
apt-get -b source gnokii
此时会看到debian正在编译gnokii(编译之前可能需要下载编译需要的dev库,按照提示来就可以了),编译完成之后会将打包成6个deb文件,用dpkg -i命令重装一下你需要的就可以了。 此时再试试看gnokii --getsms SM 1命令,是不是没问题了?
comments powered by Disqus