FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
12-20-2022 08:33 AM - last edited on 12-22-2022 09:03 AM by CodeShepherd
Hello,
I am new to CXA_FileAsync with FB IL_FileWriteAsync for datalogging, are there any function block or possible to automatically transfer the data logged csv files from ctrlX to my PC every hour?
Warmest regards,
Solved! Go to Solution.
12-21-2022 12:55 PM - edited 12-22-2022 09:05 AM
Moves to own topic from this one.
There are several ways to do so. First I like to mention that the CXA_SocketComm library also includes FTP and TFTP protocol to send files to a server e.g. your PC.
12-23-2022 03:12 AM
Hello CodeShepherd,
Thank you for your reply!
I am new to CXA_SocketComm and FTP are there any examples to use the FTP IL_FTPGetAsync function block?
We need to transfer data csv file from ctrlX to the PC.
Warmest regards,
12-27-2022 04:47 AM - edited 12-27-2022 04:54 AM
Hi,
Here is asimple demo code, maybe helpfull for you.
Declaration:
PROGRAM IL_FTPPut_Test
VAR
fbFTPPut : IL_FTPPutAsync;
fbFTPPutFile : IL_FTPPutFileAsync;
filebuf: STRING(5000) := 'asdasd$R$N12312312$R$Npoipoi$R$N';
sendlen: UDINT;
itestcase: INT;
END_VAR
Implementation:
fbFTPPut();
fbFTPPutFile();
CASE itestcase OF
1: // put string
fbFTPPut.Address := '192.168.1.101';
fbFTPPut.Login := 'MyPcUserName';
fbFTPPut.Password := '';
fbFTPPut.RemoteFile := 'ftpsavefile'; // existing file
fbFTPPut.ValueAdr := ADR(filebuf);
fbFTPPut.NoOfBytes := IL_LEN(adr(filebuf));
sendlen := fbFTPPut.NoOfSendBytes;
fbFTPPut.Execute := TRUE;
IF fbFTPPut.Done THEN
fbFTPPut.Execute := FALSE;
itestcase := 0;
END_IF
2: // put fie
fbFTPPutFile.Address := '192.168.1.101';
fbFTPPutFile.Login := 'MyPcUserName';
fbFTPPutFile.Password := '';
fbFTPPutFile.RemoteFile := 'ftpcoty.scope'; //300kB
fbFTPPutFile.LocalFile := ADR('_cnc/xy_2.scope');
sendlen := fbFTPPutFile.NoOfSendBytes;
fbFTPPutFile.Execute := TRUE;
IF fbFTPPutFile.Done THEN
fbFTPPutFile.Execute := FALSE;
itestcase := 0;
END_IF
END_CASE
09-10-2023 09:48 AM - edited 09-10-2023 10:03 AM
Hi,
I tried executing the above sample in my machine, the case1 just produced a file on my ftpserver with the given name & buffer data were successfully written to the file.
But the case2: did not retrive the file from my PLC to PC and it resulted the error codes as below
Error ID: RESOURCE_ERROR
Additional1: 16#0A0F0102
Additional2: 16#0C231010
same server successfully accessed by case1, but did not by case2 & could not find the description for the error codes shown here
the localfile was present in the ctrlX, pic as below
09-11-2023 08:09 AM
Error codes can be found in our online documentation. See here. "RESSOURCE_ERROR, 16#0A0F0101, 16#0C230010, No object available with this name"