plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SD/MM card ready for writing on an HMI device?

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems
View previous topic :: View next topic  
Author Message
csiki
Member junior
Member junior


Joined: 21 Aug 2015
Posts: 62
Location: Hungary

PostPosted: 19/10/2015 18:55    Post subject: SD/MM card ready for writing on an HMI device? Reply with quote

How do you use a script to determine whether a storage drive with removable media (USB stick, SD/MM card) is ready for writing on an HMI device?

1 Create a script for a function with the following code:
For Windows-based devices:

Code:
Function MediaCheckWin(ByRef path)
Dim fso, drive, result
Set fso= CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set drive=fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(path)))
If Err.Number=0 Then
result= 0
Else
result= Err.Number
End If
MediaCheckWin= result
End Function

For WindowsCE-based devices:
Code:

Function MediaCheckCE(ByRef path)
Dim fso, result
Set fso= CreateObject("Filectl.filesystem")
If fso.dir(path)="" Then
result= 1
Else
result= 0
End If
Set fso= Nothing
MediaCheckCE= result
End Function


Note
The "result" return value can be changed to suit your requirements.
2 Call the MediaCheckWin() or MediaCheckCE() script each time before you run a write procedure to the medium concerned. As parameter you assign the script the path on which the file to be written is to be located, for example: "e:\" (Windows) or "\Storage Card USB\" (Windows CE).

Note
If you transfer the path as parameter via an input field, make sure that your input is accepted (press Enter key).
If you do not transfer the path as parameter, but define it in the script, then you set the path specification in quotation marks.
3 Depending on the return value you decide whether to continue the write procedure or abort it.
The return value "0" means that the medium was ready for writing when tested; any other return value means that the medium was not ready for writing.

TIA Portal sample project KP400 Comfort / PC Runtime with integrated scripts
https://support.industry.siemens.com/cs/attachments/89855157/storage_media_status.zip
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro