Hi all,
while working on a simple SMS receiver project using Huawei modem, i got this Errors:
Exception in thread "SMSLib-AsyncMessageProcessor : " java.lang.StringIndexOutOfBoundsException: String index out of range: -12 at java.lang.String.substring(String.java:1937) at org.smslib.modem.ModemGateway.readMessagesPDU(ModemGateway.java:546) at org.smslib.modem.ModemGateway.readMessages(ModemGateway.java:208) at org.smslib.modem.AModemDriver$AsyncMessageProcessor.run(AModemDriver.java:878)
i tried my best to get rid of it, but the luck was not with me. so, i decided to go to the brute force method
i extracted the SMSLib source into my project folder. then i started the project.
i found that the problem occurred in file called ModemGateway.java at line 541:
memIndex = Integer.parseInt(line.substring(i + 1, j).trim());
but in fact the problem was not in the line itself, it was a problem with the variable (line). by looking above line 541 we will found two (if) statements as following:
if (line.length() < = 0 || line.equalsIgnoreCase("OK")) break; if (line.length() <= 0 || line.equalsIgnoreCase("ERROR")) break;
those two statements deals with non required lines. i used the Debugger in order to trace possible (line) values and i got the following possibilities:
CMGL: 0,1,,20 CMS ERROR: 321 OK Error
it is pretty clear that the case "CMS ERROR: 321" is the one that causes the problem since it has not been handled. so i added the following line to the code:
if (line.length() < = 0 || line.contains("CMS ERROR:")) break;
i think that this solves the problem for the time being
all the best
anti antivirus based box c++ change Client Computer create Easy email file free get gif html image imagebox install isp java lan linux make Microsoft Windows my net Network online operating system pass php pligg Send Server simple SMS system time to unix using virus windows your
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.