cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Transmit files from PLC to PC

Transmit files from PLC to PC

Open
New Contributor

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?

Open_0-1671521436880.png

Warmest regards,

5 REPLIES 5

CodeShepherd
Community Moderator
Community Moderator

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.

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? 

Open_0-1671761199310.png

We need to transfer data csv file from ctrlX to the PC. 

Warmest regards,

LiuPengfei
Established Member

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

 

 

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

Rathinavel_0-1694331837224.png

Rathinavel_2-1694332886378.png

 

 

 

 

Error codes can be found in our online documentation. See here. "RESSOURCE_ERROR, 16#0A0F0101, 16#0C230010, No object available with this name"

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist