[HL8548] +KFTPSND - check when tx buffer is empty

Hello,

In a current developpemnt, I would like to write data continuously to an FTP server, split into 2048 bytes per files.I’m able to connect to my server, and I wait for +KFTP_IND: 1,1,0 before trying to open the file.

My problem is I didn’t find a way to know when all datas has been sent, and it is possible to close the file. It seems datas are buffered to HL8548 before being written to the server, and when I write my EOF pattern (set by at+kpattern), the file is closed even if there is still some datas inside the buffer. When I open the next file, the remaining datas are sent to the new file, instead of the old one.
I also don’t receive +KFTP_IND URC after closing the file (which make sense, because transmit is not over).

Here is the command I do :

at+kftpsnd=1,"","file0000.txt",0,0
--Wait for DCD to go down--
....datas....
--Closing file using EOF pattern--
--Wait for DCD to go up--

I wanted to use +KFSFILE to write a file to the flash before sending it or *PSGCNT to track the number of byte sent trough GPRS connection, but both are only available to HL6528. What did I miss ?

Hi,

The KSFILE system is only on the HL6528, it was legacy functionality which is not being implemented on any of the newer HL6528RD, HL8xxx or HL7xxx units.

With regards your problem, a certain amount of data will be stored on the HL8 in its buffer for transmission and re tx if required as per the normal TCP sliding window, I would expect once you have completed sending the file along with the EOF indication that the unit will exit data mode and try to complete the operation independently at which point you need to wait for the indication that the file transfer has completed before embarking on another one. What is happening on the server side? Is the file getting through correctly but the HL8 is not outputting the unsolicited saying that the tx has finished?

Regards

Matt

Hi,

That is the behaviour I expected. However, It seems the file is closed immediatly when receiving the EOF, even if the GSM module buffer has not been fully transmitted to the FTP.
Once the file is opened, I start sending my 2048 bytes immediatly from my microcontroler, using the uart (115200 bauds).
As soon as the datas have been send to the HL8548, I send the EOF pattern, which close the file.

When I check the server, my file is there, but the size is less than 2048 (never the same size). The datas inside are the first part of the buffer.

If I open a new file, without providing new datas, the next part of the buffer is sent to the FTP (and if I wait long enough before closing it, the transmit is now complete). I receive the +KFTP_IND: 1,2,0 message (note that the number of byte transmitted is 0 according to this message, instead of 2048 or at least the size of the second file). The file is then available on the FTP, with the missing datas, and the total size of both files is 2048.

As for now, my only workaround is to wait for 1 second between sending the datas trough UART and closing the file, then check for KFTP_IND. If KFTP_IND is not present, I open a new file, and wait 1 more second before closing it, without providing more datas. This is far from ideal, because I need to be as fast as possible on some occasion, where the datas are coming continuously to my microcontroler, which could lead to buffer overflow.

Hope my english is not too bad, sorry if it is.
Regards.

Your English is fine.

I will see what I can do re testing

Regards

Matt

Can you send the full sequence, looking at the kftpsnd command t looks wrong in terms of the number and position of characters you are sending.

Regards

Matt

Hi,

Indeed, I forgot 1 empty parameter in my first message. The kftpsnd command is at+kftpsnd=1,"",“filename”,0,0, to write a file on root directory.

Here’s the command I send after HL reset.

at&k3 //Activate RTS/CTS
at&r1 //CTS drop as required by flow control
at&c1 //DCD is high when HL is in data mode, low otherwise
at+ksync=3,2 //GPIO2=1 when network is available

ate1
atq0
ats0=0
atv1
at&d0

Then, when I need to connect to FTP (with reply from HL8548) :

at+kcnxcfg=1,"GPRS","apn","login","password"
OK
at+kpattern=_EOF_
OK
at+kftpcfg=1,"address","login","password",21,0,0
+KFTPCFG: 1
OK
at+kcnx=1
OK
+KCNX_IND: 1,4,1
+KCNX_IND: 1,1,0
+KFTP_IND: 1,1

Once it’s connected, I write a small file :

at+kftpsnd=1,,"","small_file.txt",0,0
//wait for DCD high
CONNECT //Sometimes, it is received while the datas are being transmitted, it seems there is a small delay between entering data mode and this message.
//Send data (46 bytes)
_EOF_
OK
//Closing file
+KFTP_IND: 1,2,46

However, if I try to send a longer file (2048 bytes, in my case), it doesn’t work unless I add a delay :

at+kftpsnd=1,,"","2048B_file.txt",0,0
//wait for DCD high
CONNECT //Same as above
//Send data (2048 bytes)
_EOF_
OK
//Closing file
//No KFTP_IND is received, when I check the file on the FTP server, just the first n bytes are written. (n is different each times)

//Trying to open a new file
at+kftpsnd=1,,"","2048B_file_part2.txt",0,0
//wait for DCD high
CONNECT //Same as above
//Do not send new datas, but wait for a few seconds
_EOF_
OK
//Closing file 
+KFTP_IND: 1,2,0
//remaining datas (2048-n) are in 2048B_file_part2.txt. The size of this file is 2048-n, instead of the size reported by +KFTP_IND: 1,2,0

I’m using the last firmware rev available on the website (RHL85xx.5.5.23.0.201610311418.x6250_7).

Hi,

Is my AT command flow correct, or did I miss something? Did you manage to recreate the same behaviour?
My system is working since I always retry when I don’t receive the notification, but It add delays, which is not ideal.

Regards.