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

registerType return DL_INVALID_VALUE

registerType return DL_INVALID_VALUE

Elleshar
Established Member

Hello community,

my registerType(address, bfbsPath); 
returns DL_INVALID_VALUE. 

its similar done like in:
https://developer.community.boschrexroth.com/t5/SDK/Register-multiple-flatbuffer-types-in-Data-Layer...

the main difference is that i compile the bfbs via a shellscript and not over cmakelist.

My call looks like:

auto bfbsXXX = "/snap/XXX/current/flatbuffers/XXX.bfbs";
auto result = Provider_->registerType(address, bfbsXXX);

also, 

flatbuffers::Offset<comm::datalayer::Reference> vecReferences[] = {comm::datalayer::CreateReferenceDirect(builder, "createType", address)};
is done and OnMetadata is done exactly like in the upper link too.
The path to the bfbs and the type get correct printed into console,

auto result = Provider_->registerType(address, bfbsXXX);
        if (comm::datalayer::STATUS_FAILED(result))
        {
            TRACE_MSG("registerType of '%s' failed: %s", address, result.toString());
            TRACE_MSG("path-address: '%s'", address);
            TRACE_MSG("path-bfbs: '%s'", bfbsXXX);
            return false;
        }



My compiling of flatbuffers is:
flatc -o ../YYY/Flatbuffers --cpp YYY.fbs
flatc -o ./bfbs --gen-object-api --binary --schema YYY.fbs

 

Any suggestions/ideas?

Sincerely Elleshar

9 REPLIES 9

nickH
Community Moderator
Community Moderator

Hello Elleshar,

maybe your bfbsPath is not correct. Try to use getenv("SNAP") to get the correct Path (like you can see in the example and in the post you mentioned):

bfbsPath = getenv("SNAP") != nullptr ? getenv("SNAP") : "bfbs";
bfbsPath += "/sampleSchema.bfbs";

 

I tried out the example sdk-cpp-registernode and it works fine for me. I additionally printed out the bfbsPath which looks like this: 

/snap/sdk-cpp-registernode/x1/sampleSchema.bfbs

 

Furthermore you should check if you can find your bfbs file at the Path you expect it to be:

2022-01-10_08h22_03.png

 

If not, check your snapcraft.yaml and see if you've got this parts:

parts:
  registernode:
    plugin: dump
    source: ./generated/build

  flatbuffers:
    plugin: dump
    source: ./bfbs
....

 

Let me know if this was helpful for you. 

Best regards,

Nick 

Elleshar
Established Member

Hi Nick,

thanks for the reply.

We are building for realtime-bundle at the moment, so getenv doesn't work.
The sample working also fine for us, we can build it and use.
All you mentioned, we already tried. The filesystems is fine and the paths also correct
we checked more than once.

Sincerely 
Elleshar

nickH
Community Moderator
Community Moderator

Ok. Let's check some further points. 

Did you try your flatbuffer schema and your compile mechanism via shellscript in a Non-Real-Time context first?

For example just modify the provider.all-data or the register.node example. 

 

If your flatbuffer schema and your compile mechanism works in the Non-Real-Time context, we can rule out some issues. And focus on the special requirements, which come with RT-Bundles. 

 

Best regards, 

Nick 

Elleshar
Established Member

Hi Nick,

good idea. We tried it.
We found out, that the problem lies in the usage of two snaps.
The problem seems to be that the *.bfbs files reside in a different snap,
than the snap which is using it (the bfbs data is part of our own snap, but the data is used by the rexroth-automationcore snap).
If we are in only one snap our build mechanism works fine,
else we get DL_INVALID_VALUE, how can we prevent this? Any suggestions?

Thanks for you help!

Sincerely 
Elleshar

nickH
Community Moderator
Community Moderator

Hello Elleshar,

I'm sorry, I don't understand the issue correctly. 

Why can't you have the .bfbs file inside of the snap where you want to execute the registerType methode?

And which data is used by the rexroth-automationcore snap

 

Best regards,

Nick

Elleshar
Established Member

Hi Nick,

here are more details on our setup (currently using SDK v1.10):
We are creating a realtime-bundle, which registers some Nodes (with custom Datatypes/Flatbuffers) in the Datalayer.
Since the bundle is called by the automation.core snap the getenv("SNAP") resolves to the location of the automation.core snap (/snap/rexroth-automationcore/360/).
But our .bfbs files are stored in our own snap, so we tried to set the bfbsPath manually to "/snap/MY_SNAP/current/".

When we tested our flatbuffer schema and compile mechanism with the register.node sample we found out, that it works as long as the bfbs Files are stored inside snap which they are used in:
The (adapted) registernode sample works fine if the bfbsPath is set to "/snap/registernode/current/myFlatbuffer.bfbs". But if we set the path to "/snap/MY_SNAP/current/myFlatbuffer.bfbs" (we double checked: the file exists at that location) the same error as in our realtime bundle occurs (DL_INVALID_VALUE on registerType).

As far as we understand/guess a rt-bundle runs in the context of the automation.core snap. And the problem seems to be that the different snaps cannot access the data of each other.

Sincerely
Elleshar

nickH
Community Moderator
Community Moderator

Hello Elleshar,

Thanks for explaining once again. Your problem has now become clear to me. And I found a solution.

You can store the .bfbs file in the Active Configuration of your ctrlX CORE.

 

To copy the .bfbs file into the Active Configuration I used a interface hook. See this tread for further information.

  1. Add the folder "snap/hooks" and the executable "connect-plug-active-solution" to the project.
    2022-01-14_11h39_38.png

     

  2. Make it executable

 

chmod +x connect-plug-active-solution​​

 

3  Changes in "snapcraft.yaml"

a) Add part "flatbuffer" to get the .bfbs file into the snap (use organize to make the folder "/bfbs" in the snap)

 

parts:
...
  flatbuffers:
    source: ./bfbs
    plugin: dump
    organize:
      '*': ./bfbs/​

 

 

b) Add plug to the snap to get general access to the active configuration

 

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

 

 

c) Add plug to the hook so active configuration can be manipulated in there

 

hooks:
  connect-plug-active-solution:
    plugs: [active-solution]

 

4  Add command line code in the executable "connect-plug-active-solution" to create a folder and copy .bfbs file to the active configuration

 

#!/bin/bash
mkdir -p /var/snap/rexroth-solutions/common/solutions/activeConfiguration/bfbs/
cp $SNAP/bfbs/sampleSchema.bfbs /var/snap/rexroth-solutions/common/solutions/activeConfiguration/bfbs/

 

5  You can change the bfbsPath in your C++ programm now to a path to the activeConfiguration:

 

auto bfbsPath = "/var/snap/rexroth-solutions/common/solutions/activeConfiguration/bfbs/sampleSchema.bfbs";
result = myProvider->registerType("types/sampleSchema/inertialValue", bfbsPath);​

 

 

After installation you should see your bfbs file in the folder "bfbs" in the active configuration and your Schema is registered in the Data Layer at "types". 

2022-01-14_11h32_54.png

 

 2022-01-14_11h57_39.png

 

 

Let me know if this solution can help you.

 

Best regards,

Nick

Elleshar
Established Member

Hi Nick,

thank you, great help!
Problem solved.

Sincerely
Elleshar

nickH
Community Moderator
Community Moderator

Hi everyone,

I just found out that hooks do not work with base: bare. Please use a proper base (base: core20 or base: core22).

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