OPEN SOCKET FROM PLC TO a FTP server.
1. FTP server can be enabled using Features in windows 10.
2. However, I want to use a portable FTP server.
3. BabyFTP seemed like a good candidate, but it stuck in binary mode and failed to create data socket
4. Xlight FTP, (rfc 959 IMPLEMENTATION) is my next candidate.
First, add a new virtual server.
Global Options include Install as service, deny/allow IP_address, Bandwidth limit, Firewall & broadband router, SSL certificate, ODBC DB config, Remote admin, logging even log to a DB. I am impressed! What a gem.
Create a user or anonymous user with home directory.
Hit Play to start the server.
From PLC, open socket to the target with port 21, then send commands
// Not needed if send directly from PLC, Testing with Hercules
OPEN 192.168.0.44
Response = 220 Xlight FTP Server 3.9 ready...
Your socket program need to check the response and act on it that is to give the USER as next command
USER ANONYMOUS$0D$0A
Response = 331 Anonymous login OK, send your e-mail as password
PASS FTP$0D$0A
Response = 230 Login OK
(not need TYPE ASCII)
EPSV$0D$0A
229 Entering Passive Mode (|||54732|)
PLC needs to parse out and retain the port 54732
RETR TestData.txt$0D$0A
150 Opening BINARY mode data connection for TestData.txt (30 bytes).
At this point, I need to connect to the data socket channel on port 54732 to view the content of the file:
Connected to 192.168.0.44
#CR#LF#CR#LFTHIS IS A TEST 99999 #CR#LF#CR#LF
Finally, parse the content to string tag