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

C++ DatalayerSystem instance throwing exception

C++ DatalayerSystem instance throwing exception

lg-lima
Established Member

Hi colleagues,

I'm using the SDK for developing a datalayer provider in my application. The code successfully compiles and runs on my PC, registering a bunch of nodes remotely in the ctrlX Core. The problem starts when trying to snap the app. When the ctrlX Core tries to start up the service for the snap, it throws the error below.

 

2022-05-09T05:06:44-03:00 focas-gateway.run[6227]: [2022-05-09 05:06:44.375] [info] Starting Datalayer Provider
2022-05-09T05:06:44-03:00 focas-gateway.run[6227]: terminate called after throwing an instance of 'std::system_error'
2022-05-09T05:06:44-03:00 focas-gateway.run[6227]:   what():  Invalid argument

 

Some investigation led me to conclude that the app throws the std::system_error when reaches the call to m_datalayer.start(false), which makes me wonder if there still some setup to be made before calling itor maybe some unmet dependency. Although I got this provider code from the sdk samples-cpp, is it correct? Am I missing something? 

 

Provider::Provider(Parser *parser) : m_parser(parser)
{
    // The app throws when calling the method below.
    m_datalayer.start(false);    // type: comm::datalayer::DatalayerSystem

    // Never reaches the code below
    std::string connectionString = getConnectionString();
    spdlog::info("Datalayer provider connection: {}", connectionString);
    m_provider = m_datalayer.factory()->createProvider(connectionString);
    if (m_provider->start() != DL_OK && !m_provider->isConnected())  {
        m_error = true;
        spdlog::error("Failed to instantiate datalayer provider connection");
        throw std::runtime_error("Failed to instantiate datalayer provider connection");
    }
}

 

Here is my snapcraft.yaml:

 

apps:
  run:
    command: bin/exec-runner
    plugs:
      - network
      - network-bind
      - datalayer
[...]
parts:
  executable:
    after: [dependencies]
    plugin: dump
    source: ./build/bin
    organize:
      "*": bin/

  datalayer-lib:
    after: [dependencies]
    plugin: dump
    source: https://github.com/boschrexroth/ctrlx-automation-sdk/releases/download/1.14.0/ctrlx-datalayer-1.7.13.deb

  dependencies:
    plugin: nil
    stage-packages:
        - libzmq5

 

1 REPLY 1

nickH
Community Moderator
Community Moderator

Hello,

did you test the provided examples in the SDK? There are two C++ samples for a simple provider in the Data Layer:

Did you try out these examples and did the samples work for you? 

Please have a look into the samples and check what you are doing different in your snap. I'm not aware of what you are doing in your snap but your snapcraft.yaml looks very different then any snapcraft.yaml we provide in our samples. What is the reason for that? Please especially have a look at the plug: datalayer we use in the samples. 

 

Best regards,

Nick

 

 

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