Use AT#FTPRECV correctly

  • Hi!

    I am currently trying to use my TER-GX300S to download a big file via FTP. (>16kB, therefore not possible to just store it into one variable with FTPGET). My approach (with a public server) is:

    loop until I find "ERROR":
    char = AT#FTPRECV=3000
    WriteToFile(char, append)

    WriteToFile is a selfmade function using file I/O, which is working just fine, the rest is sent to the MDM Interface/read from the MDM Interface. When I do all these commands with e.g. HTerm, it works just fine and the module receives the file 2000-byte wise. (Though I am not quite sure, why not 3000-byte wise)

    When I run the code, however, sometimes I get #FTPRECV=486, sometimes even #FTPRECV=0 within the MDM.receive stream. Also, the last lines of the file are cutoff. Please feel free to test it out with this ftp server yourself.

    Is there any known issue that could cause such behaviour; Is there any timeout I need? (between the commands, I always use MOD.sleep(10) (atleast)

    AT+GMM: GC864-QUAD
    AT+GMR: 10.00.065



  • Good morning!

    Sorry, I didn't clarify this, yes I am indeed using Python for programming. To get ahead of further questions, the code is:

    The , behind serv and usr are needed in the syntax of FTPOPEN, I integrated them in the string directly. WriteToDisk is working just fine.

    Regards, ChristophB

  • Hi!

    I am checking the answer, see, I am writing it to a file and afterwards (when the script is finished), I download the file from the module to read from it. Sometimes, I did not write it down but sent it over the SER port to immediatly check the answer. It was always the same, sometimes #FTPRECV=900something, sometimes 400something and sometimes 0.

    The part that I do not understand is, that in the command-line from RSTerm or HTerm, it is working just fine and I always get #FTPRECV=2000. Can it have something to do with FlowControl? In HTerm, CTS FlowControl is of course checked, but when I use to get what the module would be sending to the serial port otherwise, I have no control abour that.

    Any ideas?

    Thanks in advance!



  • we have reconstruct it in. In our test unit it works fine. We've set AT&K0.

    Here the important part of script. I hope this will help:

  • Hi!

    I still have trouble with the routine. To clear things up a bit:

    When I am using AT#FTPRECV=3000 (e.g.) in the console, I receive the output in the console, i.e. the SerialPort. To get this very same output inside the program, I need to use the MDM functions, right? Does the flow control change the behaviour of the MDM/MDM2-port? Or is it only for the SER-port?

    The routine you posted is, as I see it, only for reading out one answer to AT#FTPRECV=3000, am I right about that? The problem is, when trying your solution, I ended up not even getting in the routine, because my MDM2.getDCD() was always zero.

    Why exactly did you use MDM2? Do I need to send the command to the MDM2-port then aswell or does it not matter?

    I am sorry for all these questions, but I just can't seem to get it working.

    Regards and thank you very much for your patience with me!


  • You can use MDM as well of course.
    For any further help we need a more detailed overview from your application. Please be so kind and send you complete code with commends
    to forum and a flowchart as well.
    Thank you.