Let there be two files that we are bringing in for adding SOME/IP signals:
custom_someip.fidl
custom_someip.fdepl
Copy
custom_someip.fidl
toExampleSomeipInterface.fidl
custom_someip.fdepl
toExampleSomeipInterface.fdepl
Follow the steps to bring these signals for being used with the AWS IoT FleetWise
-
Add
onChange
handler inExampleSomeipInterfaceStubImpl.cpp
Go to the
src/ExampleSomeipInterfaceStubImpl.cpp
and add an initial value for the signal in the class constructor, and then:- Either implement the SOME/IP stub functions for methods using
getValueAsync
andsetValueAsync
- OR add an
onChange
handler for attributes
-
Using
getValueAsync
andsetValueAsync
Example: if you have SOME/IP methods
getTemperature
andsetTemperature
, and you want them to set and get a signal namedTemperature
with typeint32_t
, you would add the following inExampleSomeipInterfaceStubImpl.cpp
:// Add the initial value in the constructor: mSignals["Temperature"] = Signal( boost::any( static_cast<int32_t>( 0 ) ) ); // Add the stub implementation for `getTemperature` method: void ExampleSomeipInterfaceStubImpl::getTemperature( const std::shared_ptr<CommonAPI::ClientId> client, getSpeedReply_t reply ) { (void)client; getValueAsync( "Temperature", reply ); } // Add the stub implementation for `setTemperature` method: void ExampleSomeipInterfaceStubImpl::setTemperature( const std::shared_ptr<CommonAPI::ClientId> client, int32_t value, setTemperatureReply_t reply ) { (void)client; setValueAsync( "Temperature", value, reply ); }
-
Using
onChange
handler for attributesExample: if you have a SOME/IP attribute
temperature
, and you want to link it to a signal namedTemperature
with typeint32_t
, you would add the following inExampleSomeipInterfaceStubImpl.cpp
:// Add the initial value and onChanged handler in the constructor: mSignals["Temperature"] = Signal( boost::any(static_cast<int32_t>( 0 ) ), [this](){ fireTemperatureAttributeChanged( boost::any_cast<int32_t>( mSignals["Temperature"].value ) ); } );
- Either implement the SOME/IP stub functions for methods using
-
Make changes to the existing
SomeipDataSource.h
. Replace the current signals with the signals incustom_someip.fidl
in a similar way as already implemented in theSomeipDataSource.h
.For example lets consider we are adding a signal
Temperature
of typeINT32
:uint32_t mTemperatureSubscription{}; bool mLastTemperatureValAvailable{}; int32_t mLastTemperatureVal{}; void pushTemperatureValue( const int32_t &val );
-
Make changes to the
SomeipDataSource.cpp
This file ingests the data to FWE. Follow the current settings of the signals in
SomeipDataSource.cpp
to setup our own signals to be collected by AWS IoT FleetWise.In
SomeipDataSource::~SomeipDataSource()
which is a destructor add a condition to make your signal subscription unavailable under the conditionif ( mProxy )
.For example:
if ( mTemperatureSubscription != 0 ) { mProxy->getTemperatureAttribute().getChangedEvent().unsubscribe( mTemperatureSubscription ); }
Add a function
void SomeipDataSource::pushXXXXValue( const YYYY &val )
to ingest value to your signals.For example:
void SomeipDataSource::pushTemperatureValue( const int32_t &val ) { mNamedSignalDataSource->ingestSignalValue( 0, "Vehicle.ExampleSomeipInterface.Temperature", DecodedSignalValue{ val, SignalType::INT32 } ); }
Under
bool SomeipDataSource::init()
definemXXXXSubscription
.For example:
mTemperatureSubscription = mProxy->getTemperatureAttribute().getChangedEvent().subscribe( [this]( const int32_t &val ) { std::lock_guard<std::mutex> lock( mLastValMutex ); mLastTemperatureVal = val; mLastTemperatureValAvailable = true; pushTemperatureValue( val ); } );
Under the if condition
if ( mCyclicUpdatePeriodMs > 0 )
add checks for proxy availability similar to the already present implementation.For example:
while ( !mShouldStop ){ { std::lock_guard<std::mutex> lock( mLastValMutex ); if ( !mProxy->isAvailable() ) { mLastTemperatureValAvailable = false; } else{ if ( mLastTemperatureValAvailable ) { pushTemperatureValue( mLastTemperatureVal ); } } } std::this_thread::sleep_for( std::chrono::milliseconds( mCyclicUpdatePeriodMs ) ); }
-
Add signals with initial value to
signals.json
For example:
"Vehicle.ExampleSomeipInterface.Temperature": 1
-
Add signals to
custom-decoders-someip.json
with proper configurations as current implementation.For example:
{ "fullyQualifiedName": "Vehicle.ExampleSomeipInterface.Temperature", "interfaceId": "SOMEIP", "type": "CUSTOM_DECODING_SIGNAL", "customDecodingSignal": { "id": "Vehicle.ExampleSomeipInterface.Temperature" } }
-
Add signal to
custom-nodes-someip.json
Add your signals coming from sensor or an actuator.
For example:
{ "sensor": { "fullyQualifiedName": "Vehicle.ExampleSomeipInterface.Temperature", "description": "Vehicle.ExampleSomeipInterface.Temperature", "dataType": "INT32" } }