Home > Forum > IEC 61131 Programming (LogicLab) > Function block for connection to FTP server
- This topic has 10 replies, 4 participants and was last updated 4 years, 7 months ago da Sergio Bertana.
-
AuthorPost
-
February 17, 2016 at 10: 21 am #35948Sergio BertanaAdministrator Forum
We have released the new function block FTPClient (Manual extract), using this function block you can connect to an FTP server, perform authentication and transfer files to and from the server.
The command Store allows you to transfer a local file from the system file system to the FTP server.
The command Retrieve allows you to transfer a file from the FTP server to the local file system of the system.I published the FTPTest project which allows testing the operation of the new FB (Project download).
March 1, 2016 at 5: 01 pm #39423GiulioParticipantIs there the possibility of using the client within a LAN, disabling DNS in some way?
March 2, 2016 at 7: 33 am #39424Sergio BertanaAdministrator ForumThere is no need to disable anything just define the IP instead of the URL, example:
http://FTP.FTPServer:=ADR('192.168.0.10'); (* FTP Server *)
The function block recognizes that the server is indicated as an IP address (Dotted) and connects directly to the address indicated.
March 11, 2016 at 10: 38 am #39446Luca MaraniParticipantGiven the addition of the FTP Client, I wanted to make the PLC send a file at the same time every day. Everything works, except if you overlap sending the file with writing the file itself.
I thought I would solve the problem by creating a copy of the file to be sent every time the original is changed. The copy would be performed only if I am not sending the file (in your example, only if CaseNr = 0), and the sending would be put on hold until the end of the write. Is the problem copying the file, is there a function block that does this, or do I have to read all of the original file and save the contents in the copy?
March 11, 2016 at 10: 42 am #39447Sergio BertanaAdministrator ForumOf course, the operation of sending a file to the FTP server takes a certain time (as long as the file is longer), and during this time the file must be blocked for writing, there must be no other program access to the file in writing.
Surely it is a good idea to create a copy of the original file which will then be used for the FTP transfer, unfortunately there is no file copy FB, so if you want to make a copy you have to manage the reading of the source file and the writing of the target file.
But I would advise you to pass write operations in the local file from a FB FIFOFile (Topic), in this way every time the program has to write to the file it actually writes to the FIFO support file and then if the file transferred in FTP is free you can extract the data from the FIFO and write them in the file.
So during the FTP upload of the file, the FIFO continues to accumulate the data (keeping them even at shutdown) and then when the FTP operations are finished you can read from the FIFO and populate your support FTP file.
March 11, 2016 at 5: 22 pm #39449Luca MaraniParticipantPerfect, thanks, but I have a problem and a report.
The problem is: does the file where the FIFO saves keep growing? Do I have to worry about deleting it if it gets too big? What is the Del command used for?
The message concerns the version of the function block. The one in your example works, but is different from the one contained in the new library eLLabLogLib_B100.plclib. Do they do the same thing only with different parameter names?
March 11, 2016 at 5: 25 pm #39450Sergio BertanaAdministrator ForumIn the management of the FIFO it is defined in FIFOSize the maximum size of the support file, the FB automatically keeps the file at that size. In practice, the FB starts writing to the file, then once the limit size is reached it resumes writing from the beginning. This means that the larger the file, the more the FIFO can contain data without overwriting the older ones.
It is always advisable to use the most recent version of the library which surely contains the most updated FBs. The command From it was present in the first version of the FB because it was expected to read a record with the command Oct and then decide to delete it from the FIFO with the command Del.
In the latest version of FB the command is gone, running the FB with the command Oct active, the record inserted first is returned to the output and automatically deleted from the FIFO. The next time the FB is executed with the Out command active, the next record is returned and so on until the FIFO is emptied.
September 26, 2019 at 12: 04 pm #50054RuboxParticipantGood evening, there is one thing I am not very clear about the FTPClient_v1 block. In all examples there is either an IP address, or there is a generic name "myserver". But if I take it as an example
FTPServer: = ADR ('my.serverftp.com')
does it work or not? All day I open ports on the router to which the PLC is connected and the one on which the FTP server is, creating rules… but nothing. It always gives me an address resolution error.
However, if I connect from the LAN where the PLC is to the FTP server with FileZilla I can access the FTP server.
September 26, 2019 at 12: 09 pm #50077Sergio BertanaAdministrator ForumIf you use a system based on Cortex M7 you can put the URL, the system automatically handles the request to the DNS server (Of course you must have correctly set the IP address of the DNS server in the network configuration).
But I don't understand what has to do with creating rules on the router to which the PLC is connected, the FTPClient is just a client so it automatically exits on the network. Maybe your problem is not having set the gateway correctly in the network settings.
Try connecting on telnet from local to SlimLine to execute a ping command to an Internet URL (Example Ping google.com) so check if it SlimLine can access the Internet. If it doesn't work, you have problems setting up the gateway.
September 26, 2019 at 2: 05 pm #50078RuboxParticipantAfternoon, the problem was that on the PLC's web configuration page it showed me the correct gateway and DNS values, while reading the values with the PLC and the SysOSIDValue function I found others. I wrote the values from PLC and now it seems to work correctly.
I apologize for the trivial questions, even in the other post, but honestly I didn't know what to do anymore and so I still opened the ports on the PLC side router and checked and recreated the rules on the FTP server side router.
September 26, 2019 at 2: 49 pm #50091Sergio BertanaAdministrator ForumThe behavior of the web page system configuration is shown in this topic.
-
AuthorPost
- You must be logged in to reply to this topic.