TC65i-x file delete failed

53 views
Skip to first unread message

Ruchs

unread,
May 6, 2016, 7:02:20 AM5/6/16
to Cinterion Java enabled chips support
Hey all,

So we have a alarm.txt file that we created on the a:/// of the TC65i-x, this file grew out of control as we commented out our control mechanism during testing, and has become about 3.45MB.  This is causing that no other functions to be able to write anything to any files on the a:/// as all the space was taken up by this file plus the other files we have stored there.

Luckily we created a function that can download a file from the server and in this function it runs a file delete, however it doesn't work when the file is this large.  

We tested the delete function and can confirm with a normal sized file 100kb, it deletes perfectly.  

When we are trying to delete the 3.45MB file from the drive, we get a IOException:

java.io.IOException -
com
.cinterion.io.j2me.file.Protocol..unknown.() bci=0 -
com
.cinterion.io.j2me.file.Protocol..delete.().bci=116 -
.....

This is not really telling me much, the next steps we performed:
  1. Deleted the file via the MES
  2. Made the file smaller - about 2.83MB 
  3. Uploaded the file back via MES
  4. Tried the same function as below and it worked perfectly
My current assumption is then:
  • The delete function requires some buffer space to be able to run correctly - therefore since the entire flash is full it is failing to run?
  • The delete function is somehow limited to a file size that it can delete?
Is there any AT command that I can issue to delete the file not using the API.

Here is the function that is deleting the file:

try
{
   
HttpConnection c = null;
   
InputStream is = null;
   
int rc;

    c
= (HttpConnection)Connector.open("http://" + Interchange.ServerIP + "/files/" + fileName);
 
   
// Getting the response code will open the connection,
   
// send the request, and read the HTTP response headers.
   
// The headers are stored until requested.
    rc
= c.getResponseCode();
   
if (rc != HttpConnection.HTTP_OK) {
       
return false;
   
}
 
   
is = c.openInputStream();
 
   
// Get the length and process the data
   
int len = (int)c.getLength();
   
if (len > 0)
   
{
       
FileConnection fconn = (FileConnection)Connector.open("file:///a:/" + fileName);

       
SystemIO.encryptOutput("Stream open going to download: " + fileName);
       
// If no exception is thrown, then the URI is valid, but the file
       
// may or may not exist.
       
if (!fconn.exists())
       
{
          fconn
.create();
       
}
       
else
       
{
          fconn
.delete();
          fconn
.create();
       
}
       
DataOutputStream dos = fconn.openDataOutputStream();
           
       
int actual = 0;
       
int bytesread = 0 ;
       
while ((bytesread != len) && (actual != -1))
       
{
         
byte[] data = new byte[1024];
          actual
= is.read(data, 0, 1024);
          bytesread
+= actual;

         
SystemIO.encryptOutput("Read: " + bytesread);
          dos
.write(data, 0, actual);
       
}
   
}
   
else
     
return false;
 
   
is.close();
   c
.close();

   
return true;
 
}
 
catch (Exception ex)
 
{
   
SystemIO.printError("downloadFile", ex);
   
return false;
 
}


Ahmed Adnane

unread,
May 6, 2016, 9:48:54 AM5/6/16
to java...@googlegroups.com
Hello,
Sure there should be some available space on the flash to allow access to it. You are lucky you succeeded to remove it via MES, if the flush is totally full, then even the access via MES wouldn't be possible. The best way is to control the size of your file so as to guarantee a minimum free space on the flash. You  can use the availableSize() method called on (FileConnection)Connector.open("file:///a:/") to know the available size left on the flash.
Regards,

--
javacint group - http://www.javacint.com/
---
You received this message because you are subscribed to the Google Groups "Cinterion Java enabled chips support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacint+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
ADNANE Ahmed

Ruchs

unread,
May 6, 2016, 10:09:42 AM5/6/16
to Cinterion Java enabled chips support
Hey thanks for quick response.  I wanted to figure out if there was a way to get a unit in this situation out of it without using MES, as this requires a lot of time and energy and as you mentioned might not even work all the time.

Is there a AT command I can issue that will delete a file?  I looked through the ATC pdf and cannot find any file interaction commands...

Thanks

Ahmed Adnane

unread,
May 6, 2016, 10:33:22 AM5/6/16
to java...@googlegroups.com
Have you tried the DELETE command of the SMS OTAP, you can use the SMS OTAP prog written by Florent

ejw

unread,
May 6, 2016, 11:14:02 AM5/6/16
to Cinterion Java enabled chips support
Hi,

Have you thought about using the HTTP GET commands under AT^SISR?.

I don't think it deletes, but it could overwrite the file with a smaller one in an emergency. Not tested outside of the very strict parameters I was set, but I have used FTP at^siss=1,srvType,ftp with a new csv file that overwrites the same filename on the tc65. It updates a settings file.

It might also be worth putting in a check on the .txt file size when it is opened and warning/truncating if getting too big.

EJW
Reply all
Reply to author
Forward
0 new messages