Dear Community User! We are updating our platform to a new system.
Read more: Important information on the platform change.

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

Cannot store data in configuration

Cannot store data in configuration

asti
Member

I tried to store a simple txt file into configuration using hello-plc C++ example from SDK 1.8, but it doesn´t work.

1. I added the plug as described:

asti_0-1625494593067.png

2. I tried to store the txt file to the following paths I found in some community posts, but none of them worked for me:

- /var/snap/rexroth-solutions/common/solutions/activeConfiguration/helloplc

- /var/snap/rexroth-solutions/common/solutions/DefaultSolutions/configurations/Default/helloplc

- filepath: $SNAP_COMMON + /solutions/activeConfiguration/helloplc

Via configurations (web interface) I see also no configuration for my helloplc snap. 😞

asti_1-1625495130902.png

Could you send me a small code example which explains how to add a  file (txt or json) from hello plc C++ snap to configuration?

Thank you very much!!

 

2 REPLIES 2

CodeShepherd
Community Moderator
Community Moderator

To simply store a file in the active configuration add the plug to your .yaml file:

plugs:
  active-solution:
    interface: content
    content: solutions
    target: $SNAP_COMMON/solutions

And then use following code:

#include <fstream>
/////  test  /////  
    path = "/var/snap/rexroth-solutions/common/solutions/activeConfiguration/test.txt";
    std::cout << "write " << path << std::endl;
    std::ofstream outfile (path);
    if (outfile.is_open()){
      std::cout << "opened: "<< path << std::endl; 
      outfile << "Test txt with some words\nand two lines\n" << path;
      outfile.close();
    }
    else{
      std::cout << "error: " << path << std::endl;
    }

 

If you like to be part of the automatic save and load process of the configuration some more steps have to be done. To get more information please get in contact with your ctrlX World contact person.

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