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.
02-01-2023 01:43 PM
Customer is asking if they can save & write the log data and PLC project into the inserted micro sd card during operation. Is there any example or how-to ?
Solved! Go to Solution.
02-01-2023 02:19 PM
Hi Sophie,
you can read/write from the PLC or other apps like NodeRED to the memory card or usb-stick by using this path:
/media/mmcblk1p1/testfile.txt
The name of your device could be different and can be found in the ui under Settings-->Storage.
The PLC boot project is saved in the active configuration which is not on the memory card.
Find attached a plc example.
ROGRAM FileWriteAsync_PRG
VAR
fbFile: CXA_FileAsync.IL_FileAsync;
fbFileWrite: CXA_FileAsync.IL_FileWriteAsync;
filename: STRING := '/media/mmcblk1p1/testfile.txt'; // /var/snap/ctrlx-node-red/current/solutions/activeConfiguration/plc/run/linux-gcc-aarch64/data/myfilename.txt
itestcase: UINT := 0;
writebuf: STRING(500);
writebuflen: UDINT := 500;
writelen: UDINT := 0;
END_VAR
CASE itestcase OF
1: // open the file
fbFile(Enable:=TRUE, FileName:=ADR(filename), Mode:=IL_FILE_ACCESS_MODE.AM_WRITE);
IF fbFile.InOperation THEN
itestcase := itestcase + 1;
END_IF
2: // write the file
writebuf := 'BoschRexroth$R$NCtrlX Automation$R$NCXA_FileAsync$R$N';
writebuflen := IL_LEN(ADR(writebuf));
fbFileWrite(Execute:=TRUE, FileHandle:=fbFile.FileHandle, BufferAddr:=ADR(writebuf), BufferSize:=writebuflen, BytesWritten=>writelen);
IF fbFileWrite.Done THEN
fbFileWrite(Execute:=FALSE);
itestcase := itestcase + 1;
END_IF
3: // close file
fbFile(Enable:=FALSE);
If NOT fbFile.Shutdown AND NOT fbFile.InOperation THEN
itestcase := 0;
END_IF
END_CASE
IF fbFileWrite.Error OR fbFile.Error THEN
; // post some error
END_IF
02-01-2023 02:25 PM
thanks 'Captain 😉
05-05-2023 01:14 PM
Reading and Writing to a file in SD card is a good option to utilize memory. After writing some to a text file, we can easily read the file contents by using Node-RED app; however, can we read the file contents by using Textual IDE?
This option can improve the user readability. I have tried to access the file via SD card directory in IDE app, but the directory is empty even though it contains some files/folders.
For example, when we try to create a folder in the SD card directory via Textual IDE, it prompts that folder this name already exists. The Textual IDE don't show the available files/folders which are created by Node-RED.
05-05-2023 02:47 PM
Hi Akseer,
i'm a developer from the IDE App. Sounds like a usefull improvement for the IDE App. We will check, if it is technically possible and if yes, we should be abe to ship it in our upcoming releases. Next release with new features will be RM23.07 IDE Version 2.X.X in end of July.