Home > Forum > IEC 61131 Programming (LogicLab) > Realize DataLogger with historicization on FTP server
tagged: ftp ftpClient warning
- This topic has 19 replies, 1 participant and was last updated 4 years, 2 months ago da Sergio Bertana.
-
AuthorPost
-
April 4, 2016 at 9: 17 am #35987Sergio BertanaAdministrator Forum
I have received requests from customers who wish to use our products SlimLine e Netsyst to create a DataLogger. In practice, the need is to acquire both analog and digital values or read data from instruments via Modbus and log them at regular intervals in a csv file on the local system.
To this requirement easily achievable using the FB StringToLogFile_v1 (Topic), I added the possibility to transfer the log file from the local disk of the system to a remote server in the cloud via FTP protocol using the FB FTPClient (Topic).
The problem to overcome in this application is saving the log records while the transfer operation of the local file to the FTP server is in progress. This problem is easily overcome with the FB FIFOFile, which allows data to be stored on file and then extracted when possible (Topic). As you can see, the example program historicizes the data in the FIFO every minute and at the same time if the local log file is free it reads from the FIFO and saves in the csv file.
The connection to the remote server is made every hour (in the example it is on the AlterVista site) and the local file is transferred to the remote server. The name of the file on the remote server is created by composing the Date / Time value to which the log refers (We will have files of the type 20160404-23.csv, 20160405-00.csv, etc ...).
The source program is provided so that everyone can modify it according to their needs (Print program, Download program).
February 9, 2017 at 12: 25 pm #39839SergioParticipantI've been using the Ptp139a000 program for some months after modifying it for my client's needs in the string generation part, but the state logic has remained the original one. I only encountered one small problem: occasionally - twice, the second two days ago - the call
iSysremove: = (Logger.Filename); (* Local file gate *)
it fails and therefore the file grows in size and has headers replicated every hour. SysLastError is simply 9961200 Error deleting the file. If I stop the program, the system restarts without problems and last time it went on for 10 days.
I thought it might be a problem due to the FTPClient block (eLLabNetworkLib_A200) which does not release the file and to work around I thought of modifying the program in order to separate the two operations (wait for ftp end, deletion) with a new case 13. But it could also depend on the StringToLogFile_v1 block and then I thought to add:
Logger (Enable: = TRUE, Write: = FALSE);before Sysremove.February 9, 2017 at 1: 51 pm #39840Sergio BertanaAdministrator ForumYou have seen well in the FTPClient FB there was a bug that could create the problem that you complain, I corrected the FB and I created the new version of the PTP139A100 program, you can download from the site.
In this version there is the new FTPClient FB, you can open the project and export the FB to your library, then import it into your project by overwriting the old FB.
February 24, 2017 at 9: 54 am #39854PierluigiParticipantI am writing because I have created a program for the hourly log on monthly files of a certain number of quantities acquired via modbus RTU from 3 PLC schneider micro series. SlimLine acts as a data concentrator and datalogger, so far so good, the files are correctly saved on the SD card installed on the vehicle and can be consulted and downloaded via Filezilla.
However, my client would need to download the files via batch script from his server automatically and was unable in any way to connect to the FTP server of the slimline and download, is there a solution?
February 25, 2017 at 8: 24 am #39855Sergio BertanaAdministrator ForumIf, as you say, the files are accessible through Filezilla but the batch script from the server fails to connect, the problem is in the script used.
Are you sure you are using an FTP connection and not SFTP? It may be that the FTP program used in the batch uses FTP commands not implemented in our FTP server, in which case I would need a connection report to understand what the problem is.
But why download files from a server when it can be SlimLine to send them to the FTP server in the cloud, by the way in this way the transfer is possible even if it is SlimLine it is on a NATtata network and not reachable from the Internet.
February 27, 2017 at 1: 58 pm #39865PierluigiParticipantI need to periodically transfer a file to FTP from a system SlimLine, I wrote a batch file with the commands:
@ ECHO OFF
echo FTP transfer started
ftp -s: cmd.ftp 192.168.0.xxx
echo End of transferHere is the contents of the "cmd.ftp" FTP command file:
admin
admin
cd / Storage
binary
get /nomefile.csv
quitBut I can't download the file. I cannot upload data to the cloud as I do not have internet access, the plant network is separate from the plant network where the internet is present.
March 6, 2017 at 7: 24 am #39866Sergio BertanaAdministrator Forumthe Windows ftp command does not handle the passive transfer which is the transfer managed by the FTP server SlimLine. So if you want to download the files automatically you have to use a Linux server (which supports passive transfer) or a client for Windows that supports passive transfer.
But since your system is on a local network, you can always have the data automatically downloaded to your FTP server directly from SlimLine there is no need to use the cloud just define the IP address of your FTP server.
July 27, 2018 at 6: 46 am #45166AuthorlessIdleWhere can I find the latest revision for the FTPClient FB? I ask because I am carrying out some comparative tests between the function blocks found among the various forum posts, FTPClient and FTPClient_v1 and for now only the FTPClient block works without going into error. The FTPClient_v1 block in my possession generates the following warning during compilation:
warning G0015: MOVE => Accumulator extension
and the following runtime error:
[Admin]> syslog
[W] SFW184 [26/07/2018 14:52:31] 6000, User program error:10063030July 27, 2018 at 6: 57 am #45171Sergio BertanaAdministrator ForumThe latest version of FTPClient_v1 can be found in the eLLabNetworkLib_B000 networking library, downloadable from the site. The new version v1 with respect to the previous one manages the dynamic allocation of memory buffers (Using the RMalloc function). In this way it is possible to size at will the TCP packets exchanged with the server (The maximum is 1500 bytes).
Error 10063030 indicates that the buffer size has not been defined (Parameter DBSize), you have probably used a project made with the previous version and you have not defined the parameter. Take a look at theextract of the manual and see the example shown.
August 29, 2019 at 6: 06 am #49451fedeleParticipantI am using the latest version of the library (eLLabNetworkLib_B100) and compiling the example program in SIMULATION mode I have the following error:
Generating function block FTPClient_v1
aborted.FTPClient_v1 (394) - error G0129: NULL => Comparison between reference and non-reference
FTPClient_v1 (519) - error G0129: NULL => Comparison between reference and non-reference0 warnings, 2 errors.
September 19, 2019 at 9: 22 am #49760RuboxParticipantResurrected this post because I am preparing a system that automatically sends daily log files to an FTP server.
Looking at the listing of the program I understand correctly that if the FTP server is not available, the program "stops" in the CaseNr 11 condition until the connection is established? Also for case 12, if the operation is not completed, does the program continue with CaseNr 12?
September 19, 2019 at 9: 44 am #49786Sergio BertanaAdministrator ForumThe program uses the FIFO FB to manage the logging, in this way the log record is saved in the FIFO file and then if the log file is free it is transferred to the log file (Case 0), this allows not to lose records when the log file is occupied by FTP transfer.
When the transfer of the log file to the server (Case 10) is commanded, the connection sequences begin which could go into error, in which case the output would be activated Fault which brings execution to the Case 20.
In the event of an error, the number of errors is increased and a time is waited before retrying sending.
So yes of course the program remains locked in the Case 11 until the connection to the server is made but if it fails to connect after the time defined in the parameter Timeout (You see FTPClient_v1) the output is activated Fault. The same goes for the Case 12 where the complete transfer of the file is expected.
September 19, 2019 at 4: 12 pm #49787RuboxParticipantI missed the 70 line of the program's PDF listing, mistakenly thinking that all FTP transfer management was in the CASE statement. OK, now I understand everything, and everything works too.
I back up the data on a file on the SD card (so there are some) and as soon as the day changes the program sends the previous file to the FTP server.
Thanks for the clarification of the help always on time.
September 20, 2019 at 6: 20 am #49790RuboxParticipantAllow me to go back to the listing of the program (assuming that I'm using another slightly different one), but assuming I am in case 20 I find myself Store = FALSE. We go to case 21 and after 10 minutes I go to case 10. Try the connection and go to case 11. Here if there is no server available (in my test I disconnected the network cable) after a time of Timeout goes into Fault.
However line 70 verifies that there is Store at TRUE andFault at TRUE to go to case 20 and handle the connection error. Store becomes true only after connecting to case 11. I have cleared the Store true check on line 70 and everything seems to work fine.
September 20, 2019 at 6: 32 am #49792Sergio BertanaAdministrator ForumThe FTPClient FB if it has Connect = TRUE tries to connect to the FTP server, if it fails (As in your case that you disconnected the cable) after the timeout time generates error 10063050 disables the connection and rehabilitates by retrying to connect.
If there is no connection it is useless to go to subsequent cases, so the program does not deliberately switch to case 20 but continues to wait to complete the connection. If you reattach the cable, everything should start again.
Certainly in this condition being stopped in case 11 I would continue to have the local log file blocked and the log records would saturate the FIFO. But if you can't connect to the FTP server there isn't much else to do.
In your case having removed the control on Store jumps to the 20 case timing then try again and after 3 attempts resume saving in the local log file trying again to send it to the next deadline. It can be a solution for connection problems that last a long time. But if the network cable comes off you will continue to save in the same log file saturating it. In the event provide a warning, perhaps with signal lamps or other.
-
AuthorPost
- You must be logged in to reply to this topic.