Data duplicated when file moved from the ftp server to local storage for viewing

I setup a FTP server which the controller is communicating with to send and receive run data. When the data is loaded to be viewed (moved from FTP server to local storage for viewing) it gets duplicated, a table with 50 cells saved into the file becomes 100 cells (each cell got a copy).

Could this be a bug in the lines I have written or something observed behavior when using FTP ?

Do you clear Perf_data and Current_run_data before you run this code?

I do, this is the top part of this code

You said a 50 cell becomes 100, yet you are only clearing the first 50 values in the table. Are you sure you are doing this right?

Also, you can clear a string table with one command:


You are correct, the reason I am clearing only 50 because i setup the table length at 50


The 100 cells only show up on the local storage, I have attached an example showing how the cell get duplicated, its like the table was transmitted twice when running the get: command

example data (660 Bytes)


This is really helpful, thank you.

How are you creating the Postcopy file? The logic you have posted is only reading the data in and since you only have a 50 length table, there will never be more than 50 values, yet you have 100 in your Postcopy file.

This exactly the same thing that is I am stuck with.

The post copy file is created by just using the ftp to get a copy of that file and it to storage and for some unknown reason by running the code above it makes the postcopy file have a 100 cells.

I think I understand what you are saying now.

I see you’re not calling a CloseCommunication after the first file transfer, can you add that in and see if that fixes things.

I have tried that, with every file command now I have a close communication for it and it still duplicate the data.
It seems just some buggy somewhere. I will try to work around it. Thank you for the input.

I have figured out partly the cause for data duplication, since I am doing an end of message terminator as “,” the last value always have a , with an empty space afterward which causes the controller to believe it is an additional cell and need to look for the next , resulting in it recycling through the file. However, I am sure why it is doing it for only twice and no more than that.

Is there a better way to approach this?

Remove the white space at the end of the file?

Looks like a bug to me.

I’ve tested an FTP file transfer from a PR1 on my bench and I see the same issue. I simplified the code to the following:

SendCommunicationHandleCommand(chFTP, "get:philip/test.txt,/home/dev/unsecured/test.txt");

It doesn’t matter what I put in the test.txt file, it gets saved to the local file system with the contents repeated.

I tried testing it on SoftPAC as well, but for the life of me can’t figure out where it saves the file.

1 Like

Ah, thanks @philip for distilling that down… I had got distracted with the chatter about table length.

Yes, the duplicating is a bug. Here is a snippet from the ticket in our tracking system…

It will be fixed in the next release, 3.4.0. And before you ask its more than 4+ weeks away.

1 Like

On SoftPAC for some reason this does not work:

ftpStatus2 = SendCommunicationHandleCommand(chFTP, "get:philip/test.txt,C:\test.txt");

Just to verify all is okay with SoftPAC file saving, this does work:

SetCommunicationHandleValue("file:w,c:\test.txt", chFile);
fileStatus1 = OpenOutgoingCommunication(chFile);
fileStatus2 = TransmitString("Hello!", chFile);

The ftp file transfer does happen, I just don’t see the file getting saved. No error codes either.