registerType return DL_INVALID_VALUE

Hello community,

my registerType(address, bfbsPath); 
returns DL_INVALID_VALUE. 

its similar done like in:
/sdk-el5su9ce/post/register-multiple-flatbuffer-types-in-data-layer-LBH7UIciMXNtkqU

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

Best reply by nickH

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.

     

  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". 

 

 

 

 

Let me know if this solution can help you.

 

Best regards,

Nick

View original
9 replies