This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF9160 goes into cpu idle after sending data

Hello nordic.

I'm using your FTP client. The client can only send 4 kB of data at once so I send data numerous times and append to a file.

The first send I do is 160kB which requires 40 packets to be sent. If I then send another file it halts after sending around 70 packets, I get an error -116 and the device goes into idle and I have to reboot.
If I wait a 2-3 minutes from the first file before sending the second file, there is no problem.

Thus there must be a problem with a timer or a buffer overflowing or some such thing. The FTP client has a heartbeat timer but changing the value of this made no difference. I have deduced that it does not matter if I wait 10 seconds or 50 seconds, the second file always breaks at the same packet. This makes me think that the problem should be with a buffer that clears after a set amount of time.

Edit: I should add that I do ftp_uninit() when done with transfer and ftp_open() and ftp_login() before starting transfer.

Edit2: I accidentally verified the answer of the old thread and could not revert it, so please discard the other thread.

The error says connection timed out but if I try reconnecting it says the ftp connection is still up. Also, the timing doesn't matter, if its within the range of say, one minute, the transfer stops at the same place, indicating a set amount of data causes it to halt. I have gotten connection timed out before when it actually times out, then the program continues and does NOT halt. So there must be some sort of cpu panic going on here.


Looking forward to your reply

Kind regards

  • Are you slicing the file into 4kB parts yourself before sending?

    Because it looks like the ftp code will do this for you, have you tried just sending the whole file?

    And when you send the "PASV" command I believe you are telling the server to enter passive mode to prepare to receive data. "Pass" is related to sending password credentials.

    You can read more about how FTP works here.

    -Einar

  • If I try to send a buffer larger than 4kB I get "E: send data failed: -122" and 122 error code is "Message too long".

    Edit: And yes, I slice it myself. I read 4kB from my file into a buffer, send via ftp, read next 4kB, send via ftp etc.

    Edit2: I should mention that a previous thread about FTP on this forum said that 4kB was a restriction without a workaround, something with the modem firmware.

  • Hi

    Yes it's correct that the modem can't send more than 4kB at a time, I thought the "send" function might be able to figure that out but I guess not.

    It does seem like the FTP put function automatically closes the data connection when the transfer is completed though, so it might be the case that you're not supposed to uninit and open between each consecutive transfer.

    It could be that you're clogging the available connections with control message connections since you're opening many connections quickly?

    Remember that when you issue a put command, the transfer is placed in a queue, and isn't executed immediately.

    I would try just queueing your transfers without disconnecting between each one if you haven't already.

    -Einar

  • Hi again!

    Yes, I've tried that but unless it follows the flow described in ftp_put it doesn't work. You either get an error saying bad sequence of commands or nothing at all happens.

    as described, the flow is:

    /** Typical sequence:
         * FTP        51    Request: PASV
         * FTP        96    Response: 227 Entering Passive Mode (90,130,70,73,105,177).
         * FTP        63    Request: STOR upload2.txt
         * FTP-DATA    53    FTP Data: 8 bytes (PASV) (STOR upload2.txt)
         * FTP        67    Response: 150 Ok to send data.
         * FTP        69    Response: 226 Transfer complete.
         */

    but if I do:

            for (int i = 0; i < 10; i++) {
                k_work_submit_to_queue(&ftp_work_q, &data_task_param.work);
                ret = poll_data_task_done();
            }

    or even

            for (int i = 0; i < 10; i++) {
                k_work_submit_to_queue(&ftp_work_q, &data_task_param.work);
            }

    it doesn't work.

    In another ftp thread a user said he managed to avoid socked disconnecting on each put and that he transferred a 10mb file so this should be possible, I just can't get it to work.

  • I don't think you should run the k_work functions manually, if you use ftp_put then the FTP client will make sure the sequencing is done properly.

    What I mean is you should try running ftp_put for each 4kB segment without running uninit etc in between.

    -Einar

Related