dds sample of data writer set to zero after participant_liveliness_lease_duration

6 posts / 0 new
Last post
Offline
Last seen: 4 weeks 14 hours ago
Joined: 05/17/2023
Posts: 5
dds sample of data writer set to zero after participant_liveliness_lease_duration

Hi everybody,

I am using rti connext dds 5.2.0.

I know after participant_liveliness_lease_duration, if no data is received from the data writer, data reader considers data writer as stale/dead and removes all data from database.

But in my case, all data related to data writer becomes zero after participant_liveliness_lease_duration in my GUI. Is there any way to make this last value instead of zero?

Thanks in advance.

Howard's picture
Offline
Last seen: 4 hours 10 min ago
Joined: 11/29/2012
Posts: 573

Not sure exactly what you're asking.

The participant_liveliness_lease_duration is used to timeout remote Participants when they die or are disconnected and depends on a DATA(p) discovery packet to be received.  It's not tied to data sent by user created DataWriters to user-created DataReaders.

What do you mean "all data related to the datawriter becomes zero"?

Do you mean information about the DataWriter using the DDS_PublicationBuiltinTopicData?

Or do you mean the data samples sent by the DataWriter in the DataReader's receive queue aka cache?  Data samples sent by the DataWriter and received by a DataReader should not be "zeroed" when the DataWriter is detected to be "dead"/"disconnected".  Data samples sent by a DataWriter is kept in a DataReader's receive cache until it's taken by user code OR overwritten by new data samples (when/how depends on QoS configuration).

Offline
Last seen: 4 weeks 14 hours ago
Joined: 05/17/2023
Posts: 5

Sorry for the vagueness in my question. I will explain more.

I understand participant_liveliness_lease_duration does nothing with the data between data writer and data reader, its just used to timeout dead/stale participants from the network. When I said data, I meant the dds sample defined in idl file, that is send from datawriter(DW) to datareader(DR).

Suppose I have 2 participants in the network - A and B. Participant A has a DW that send large data (video frames) along with other information from A to B and after receiving the data in B's DR,it displays the data in an HMI. Similarly B has a DW that sends some command/control messages to A's DR through HMI. Sometimes may be due to the large data sending from A to B, I received nothing in B and after participant_liveliness_lease_duration, all data displayed in HMI becomes zero and this zero value is trying to send back from B to A that is wrong.

So I want to know after participant_liveliness_lease_duration(3 sec) why zero value is displaying in HMI and instead I need the last dds sample value to be displayed in the HMI. I have 2 topics, one for the data from A to B and other for the data from B to A and I am using qos also.

I can solve the issue by increasing the participant_liveliness_lease_duration, but that is not the optimal solution.

Any kind help is highly appreciated.

Howard's picture
Offline
Last seen: 4 hours 10 min ago
Joined: 11/29/2012
Posts: 573

DDS does not set any data values to 0 in any automated fashion.   If user code is leaving data samples in the DataReader's cache using the read() API to access, and not the take() api to remove the data from DDS, the value of that data will remain whatever it was when it was received. 

Just because a participant's liveliness is lost, DDS does not change the data values sent by that participant to 0.

I suggest that there is some logic in user code that is doing that.  It's not being done by DDS.

If for some reason, a participant liveliness is lost, e.g., we have not received a participant liveliness message from the participant within the participant_liveliness_lease_duration, Connext DDS will remove that remote participant's information from its local database.  This means that if you send data for a Topic subscribed to by that participant, Connext DDS will not send the data to the participant since it no longer "exists". 

It is possible to rediscover a participant whose liveliness was lost...in which case data can again be sent to that participant.

But with respect to the local participant, there is no automated action that will cause any data samples to be zero'ed by DDS.  That must be something in user logic.

Offline
Last seen: 4 weeks 14 hours ago
Joined: 05/17/2023
Posts: 5

Thank you so much for your reply.

I am also wondering how it happens because I am sure user logic is doing nothing to make it zero.

To check the behaviour, I killed the application that has DW(A) and nothing received on DR(B) and values displayed are last received dds sample, but after participant_liveliness_lease_duration on_data_available callback is calling twice and then values becomes zero.

In on_data_available callback, info.valid_data is false when triggered after participant_liveliness_lease_duration and otherwise info.valid_data is true when DW is sending data.

 

Howard's picture
Offline
Last seen: 4 hours 10 min ago
Joined: 11/29/2012
Posts: 573

Well, that's exactly how DDS works. 

In the on_data_available() callback, user logic should check the value of the SampleInfo.valid_data fliag.  The data taken from the DataReader is only valid, and only should be processed if the "valid_data" flag is true.

If the "valid_data" flag is false, then the associated data sample does not contain any valid data and thus should not be processed.

The reason that on_data_available() is being called with a "false" valid_data flag is to inform you of the change in state of Topic...in this case, Connext DDS has detected that a DataWriter of the topic has been timedout due to the participant_liveliness_lease_duration.

90% of the code written using DDS API will test for valid_data flag and if false, do nothing.

Which is what your code should do.