CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Mon May 29, 2017 12:25 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: FileTransfer to Device
PostPosted: Fri Aug 26, 2016 8:59 am 
Offline

Joined: Wed Aug 03, 2016 3:00 pm
Posts: 8
Hello,

i want to write a script that can transfer a file (in my case a symbolconfiguration xml) to the storage of the connected device.
FTP is not a possibility because my device is only accessible via the Gateway.

I can't find no possibility in the Script Engine API.
But i see two interesting entries in system.commands:
guid="ede62c94-9e06-4d0e-b713-01c9c66351eb" name="Datei von Steuerung laden"
guid="b099ed07-d6d3-4e2b-aed2-bf15b59c2f35" name="Datei auf Steuerung schreiben"
(sorry for german names)

I tried to execute them and found out that they both take two str attributes. My guesses unfortunately didnt work (eg. src, dest filenames).
Maybe someone know what exactly attributes are required.
Or is there another way to do a file transfer?

Best Regards
Thomas


Top
   
PostPosted: Tue Aug 30, 2016 1:18 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 192
Hi Thomas233.

Thomas233 wrote:
Hello,

i want to write a script that can transfer a file (in my case a symbolconfiguration xml) to the storage of the connected device.
FTP is not a possibility because my device is only accessible via the Gateway.

I can't find no possibility in the Script Engine API.

With CODESYS V3.5 SP9 we added the API to the online device object of the ScriptEngine. See IScriptOnlineDevice4 in the ScriptEngine API documentation.

The following example code was used with our WinV3 PLC so the file paths uses the MS Windows syntax. If the PLC uses any other operating system you have to use the corresponding syntax.

Code:
onlineDev = online.create_online_device()

myDir = "TF_Test"
myFile = "/temp.txt"
myDir2 = "TF_Test2"
myFile2 = "/temp2.txt"

print("dir *")
infos = onlineDev.get_file_list_of_directory("")
for info in infos:
   if info.is_directory:
      print("D " + info.name)
   elif info.is_file:
      print("F {} ctime:{} atime:{} mtime:{}, size:{}".format(info.name, info.creation_time, info.last_access_time, info.last_modification_time, info.size))

print("create dir")
onlineDev.create_directory(myDir)

print("download file")
onlineDev.download_file(r"e:\test\temp.txt", myDir + myFile, True)

print("rename file")
onlineDev.rename_file(myDir + myFile, myDir + myFile2)

print("rename directory")
onlineDev.rename_directory(myDir, myDir2)

print("upload file")
onlineDev.upload_file(myDir2 + myFile2, r"e:\test\temp2.txt", True)

print("delete file")
onlineDev.delete_file(myDir2 + myFile2)

print("delete dir")
onlineDev.delete_directory(myDir2)

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Fri Sep 02, 2016 2:14 pm 
Offline

Joined: Wed Aug 03, 2016 3:00 pm
Posts: 8
Thank You Martin, know i also found it in the API of SP9. That is what i was looking for.
Unfortunately i can't use this, because the branded codesys from Lenze have not updated yet to SP9.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited