Pages: [1]   Go Down
Author Topic: Updata a file on a FTP server via 3g  (Read 864 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right, So I've sent a .txt file to my FTP server via a 3G module, using the following section of code:
Code:
   Serial.println("AT+CFTPTYPE=A");    //Selects ASCII mode
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        data[x]=Serial.read();  
        x++;  
    }while(!(data[x-1]=='K'&&data[x-2]=='O'));

    Serial.println("AT+CFTPPUT=\"/test.txt\"");    //Creates a file and sends data (ASCII)
    Serial.flush();
    while(Serial.read()!='N');    //Waits 'N' from BEGIN

    Serial.println("01234567890123456789");    //Data for the file
    


    Serial.write(0x1A);                        //End of Data
    Serial.write(0x0D);                        //Carridge return
    Serial.write(0x0A);                        //Line Feed

    x=0;
    do
    {
        while(Serial.available()==0);
        data[x]=Serial.read();
        x++;  
    }
    while(!(data[x-1]=='K'&&data[x-2]=='O'));    //Looks for response OK
    delay(1000);

Question is, how do I continue to add to it?
If I repeat that code, say in a loop, will it overwrite the file test.txt or will it simply tag on the data at the end?
essentially the test.txt file is going to be used as a log, collecting all data. It will get quite big over time, (the data being sent "01234567890123456789" is not representative of the data actually being sent) so downloading, editing and uploading isn't really a viable solution....  After 2hrs the estimated file size will be 5mb, downloaded and uploaded every second.....
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a great question!  I'd also like to hear the best answer to this.  One choice is to create a new file each time.  This would be good if there were many minutes between sessions of sending data.  Another choice is to keep the file open and continue to send data every minute or less.  This is great if there is data available to send every minute.  There is a parameter to choose the timeout length.  The downside is power consumption.  I think we need more information to answer your question.

I will create another thread for my FTP question.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Pages: [1]   Go Up
Jump to: