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.

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

save & write the log data and PLC project on the µSD

save & write the log data and PLC project on the µSD

Sophie
Community Moderator
Community Moderator

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 ?

4 REPLIES 4

TheCodeCaptain
Community Moderator
Community Moderator

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

thanks 'Captain 😉

 

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.

 

 

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.

 

 

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