C# File handling
Hello!
I've tried to open a open a file for reading with a C# function block but the PLC goes to stop.
Have someone tried this functionality with a better outcome. I think I use the correct path because when I am using the built in file functions in plcnext engineer it works.
I've tried
if(File.Exists("/opt/plcnext/filename"))
{
//Some simple code
}
/Stefan
Comments
Hello Stefan,
could you provide me the Output Messages, please (see in /opt/plcnext/logs).
Please send me also your complete C# FB-Code with In- and Output variables.
Thanks!
-Eduard-
Hi,
Thanks for reply.
The output.log and code is in attached file
/Stefan
Hi Stefan,
please define your OutputString as follows and try to execute the ReadXml() only in initialisation part :
[Output, DataType("STRING")]
public IecStringEx FilePath;
Please see the Readme.txt in your Project, and compare the following datatype documentation:
| IEC 61131-3 | C#
| STRING | System.Iec61131Lib.IecStringEx |
Please give me a short Feedback, if the Problem is resolved.
Thanks!
-Eduard-
Hi again,
When i change to IecStringEx datatype i get CILG0001 internal error in plcnext
/Stefan
Hello Stefan,
please find the examples for C# FB under following link (see 05_IECString and 08_FileHandling):
https://github.com/PLCnext/CSharpExamples/tree/master/PLCnext_CSharpExamples
Please try only to use the example "08_FileHandling" in your application and give me a short feedback if you can successfully start it or not.
Thanks.
-Eduard-
Hi,
Now I got it to work,
I think the main problem was the cycle time.
The cycle time was 2000 ms but the watchdog is not correlated to that time. When I changed the watchdog it works.
Before I added this post I searched for plc stop information in the controller cockpit but I could not find anything. Is there going to be more information there in the future?
Thanks for all help,
/Stefan
Hello Stefan,
in the future you will find the Status Information in cockpit under "Notifications", please see screenshot below. Additionally you can also find the Informations in /opt/plcnext/logs/Output.log.
Bets Regards
-Eduard-