ATCommand.release throws IllegalStateException: There is currently no AT command running | Telit Cinterion IoT Developer Community
March 29, 2017 - 7:54pm, 3057 views
BGS5, FW21.
In our application, upon stopping the midlet we try to clean up resources. We call atCommand.release() and catch the following exception:
java.lang.IllegalStateException: There is currently no AT command running
That is correct, there is no AT command running, which is perfect in my opinion and makes releasing very easy. I've looked with a decompiler in cwmlib_1.0.jar and can see that it comes from cancelCommand(), which is called internally by release(). This exception from cancelCommand is what you'd expect, however, why isn't this exception caught and ignored by release()?
My conclusion is that it cannot come from cancelCommand() but must come from ATCommandHelper.nativeCloseATCommand() which also throws this exception?
public synchronized void cancelCommand()
throws ATCommandFailedException, IllegalStateException
{
synchronized (this.m_Sync)
{
switch (this.m_State)
{
case 0:
case 2:
throw new IllegalStateException("There is currently no AT command running");
public synchronized void release()
throws IOException, IllegalStateException
{
synchronized (this.m_Sync)
{
this.m_Listeners.clear();
if (this.m_iPort >= 0)
{
try
{
cancelCommand();
}
catch (Exception localException) {}
this.m_State = 5;
Naturally, the AT command resource isn't released, so when we start our midlet again:
java.lang.IllegalStateException: openATCommand: no channel available.
Hello,
According to the code you have cited the cancelCommand() call in the release() method is inside the try block and the Exception is being caught without displaying anything. So it is ignored.
ATCommandHelper.nativeCloseATCommand() indeed throws the IllegalStateException but I wouldn't expect that it would throw it with the same message "There is currently no AT command running". However I don't have access to the native code.
I've just done a simple test with creating the ATCommand instance, sending the command and releasing it on exit in destroyApp() method. I wasn't able to reproduce this problem. But I suppose that your MIDlet is much more complicated and many things are happening there. Isn't it possible that your code calls the cancelCommand() method?
Could you write some more about what's inside the MIDlet?
Regards,
Bartłomiej
Sure, it is much more complicated than that. I did another test to see if I could reproduce it again and could not.
The only possible resaon could be that we had put the atCommand.cancelCommand() and the atCommand.release() in a single try catch, thereby causing the release() not to execute. We corrected that yesterday during the day. Let's assume it was that, then the behavior as you tested indeed works.
I agree - that must have been the reason.
Regards,
Bartłomiej