Callback issue in the FTP get function of 9160

How to determine if the download is complete when downloading files from the FTP server using the ftp_get function?

Although Ctrl_cb will return code, in my actual testing, when downloading a large file, the download was not completed yet, and Ctrl_cb already returned 226 code indicating that the transfer was completed. However, there was no callback message when the download was actually completed.

I haven't tested the ftp put function yet, may there be similar issues as well?

Parents Reply Children
  • Hi,

    Is your application based on serial_lte_modem? Can you provide more information about your application?

    Which NCS version do you use?

    What do you refer to as data_cb and ctrl_cb?

    Best regards,
    Dejan

  • Hello Dejans

    Yes, I use SLM,the NCS version is 2.6.1

    Sorry, I forgot that these two function names were given by myself,data_cb and ctrl_cb are callback functions in the ftp_client library used to receive ftp information.

    typedef void (*ftp_client_callback_t)(const uint8_t *msg, uint16_t len);
    
    ftp_client_callback_t ctrl_cb(const uint8_t *msg, uint16_t len);
    ftp_client_callback_t data_cb(const uint8_t *msg, uint16_t len);
    ftp_init(ctrl_cb, data_cb);

    After starting the FTP connection, ctrl_cb will receive a message similar to " 230 Login successful." indicating the current status,data_cb will receive data obtained from the FTP server, such as data from downloaded files.

    If you need any other information, please let me know, thanks

  • Hi,

    Could you provide more information about your setup?

    Do you have any log which you could share?

    Best regards,
    Dejan

  • Hi dejans,

    I tested FTP using SLM, which includes FTP_client h, and there are no other special settings for FTP. Then, as in the previous reply, I wrote two callback functions. In the ctrl callback, I only printed out the received information. In the data callback, I added some logical code to display the downloaded data volume and save the received data to LFS.

    Then below is the log I obtained, and I have removed some duplicate parts for easy viewing

    [10:37:57.976]收←◆ctrl_cb: 220 (vsFTPd 3.0.3)
    
    
    [10:37:58.250]收←◆ctrl_cb: 200 Always in UTF8 mode.
    
    
    [10:37:58.619]收←◆ctrl_cb: 331 Please specify the password.
    
    
    [10:37:59.136]收←◆ctrl_cb: 230 Login successful.
    
    lfs_dir_fetchmatch count: 4
    return 0 
    
    [10:37:59.416]收←◆ctrl_cb: 227 Entering Passive Mode (8,222,179,2,154,94)
    
    
    [10:38:02.131]收←◆data len = 708
    lfs_dir_fetchmatch count: 5
    return 0 
    
    [10:38:02.243]收←◆count: 1
    data len = 708
    
    [10:38:02.361]收←◆count: 2
    data len = 708
    
    [10:38:02.493]收←◆count: 3
    data len = 708
    
    [10:38:02.638]收←◆count: 4
    data len = 708
    
    [10:38:02.798]收←◆count: 5
    
    [10:38:04.418]收←◆data len = 708
    
    [10:38:04.685]收←◆count: 6
    data len = 708
    
    [10:38:04.793]收←◆count: 7
    data len = 708
    
    [10:38:04.918]收←◆count: 8
    data len = 708
    
    [10:38:05.017]收←◆ctrl_cb: 150 Opening BINARY mode data connection for /newdir/test2.bin (312643 bytes).
    
    
    [10:38:05.068]收←◆count: 9
    
    [10:38:06.165]收←◆data len = 708
    
    [10:38:06.313]收←◆count: 10
    
    [10:38:06.497]收←◆data len = 708
    
    [10:38:06.659]收←◆count: 11
    
    [10:38:06.784]收←◆data len = 632
    
    [10:38:07.059]收←◆count: 12
    data len = 708
    
    [10:38:07.180]收←◆count: 13
    
    [10:38:07.521]收←◆data len = 708
    
    [10:38:07.648]收←◆count: 14
    data len = 76
    
    [10:38:07.775]收←◆count: 15
    
    [10:38:08.642]收←◆data len = 708
    
                    Omit the same part in the middle here
    
    [10:39:04.092]收←◆count: 135
    
    [10:39:04.485]收←◆data len = 708
    
    [10:39:04.605]收←◆count: 136
    
    [10:39:05.040]收←◆ftp_get return = -116
    **********************************************mx_startTftp finish
    
    Upgrade OK
    OK
    
    [10:39:05.108]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 137
    
    [10:39:05.634]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 138
    
    [10:39:05.955]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 139
    
    [10:39:06.274]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 140
    
    [10:39:06.564]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 141
    
    [10:39:06.998]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 142
    
                   Omit the same part in the middle here
    
    [10:41:25.213]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 441
    
    [10:41:25.500]收←◆data len = 708
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 442
    
    [10:41:25.869]收←◆data len = 415
    FAIL: seek /lfs/test.bin: -9FAIL: write /lfs/test.bin: -9count: 443
    

    In the FTP data callback, I saved the downloaded data to LFS, but as you can see, when I downloaded about one-third of the time, it gave me a notification that the download was completed (usually returning a 226 code, this time it didn't return, but this is not important, except for not displaying the 226 code, everything else is exactly the same), and then the LFS file closed, causing me to be unable to write data. And when the download is actually completed in the end, there is no return code or any information

  • Hi,

    Documentation for SLM sample specifies that client behavior may vary depending on the server that is used for testing. Which FTP server did you use?

    You could try to test FTP connection using FTP AT commands.

    llly said:
    when I downloaded about one-third of the time, it gave me a notification that the download was completed

    Where is this shown in the log?

    Best regards,
    Dejan

Related