Jump to content
OpenSplice DDS Forum
Sign in to follow this  
Max

Binding jython and c++

Recommended Posts

Hello,

 

I am developping an application with Opensplice and I would like to test it with jython.

Everything is ok for the installation and so on.

 

But I got a problem when sending data in jython and receiving it in c++. The data is received twice. If i send data in c++, data is received only once.

I find a solution by filtering the data received depending on its state, read or not_read but I would like to understand this behaviour.

 

I'm working on RedHat, Opensplice version 6+ and share memory architecture. Using listener for the datareader.

 

Does anyone have an idea about the behaviour ?

 

Regards,

Share this post


Link to post
Share on other sites

Hi ,

 

I don't know DDS jython, but maybe you can check your C++ code. 

 

There are 2 possible things .

 

P1 : You use read method without filter.

 

After you use read method to get sample , the sample is still saved in the cache and change state to DDS_READ_SAMPLE_STATE .

 

Something bad code like below :

while(true)
{
    int ret = reader.read (sample , no filter);
    if (ret > 0 )
        printf( "%s\n", sample.msg)
    sleep(1 sec)
}

You will print sample.msg every time.

 

So change to use filter will not happen .

Or change to use take method , this will remove sample from cache 

 

 

P2 : Did you check valid_data flag in sample info ?

 

After the writer  write out  a sample , the DDS middleware on reader side will tag the sample with

1. DDS_NOT_READ_SAMPLE_STATE , because you have not read / taken it

2. DDS_NEW_VIEW_STATE, because this instance is first time sent to you .

3. DDS_ALIVE_INSTANCE_STATE, because the writer , which produced this instance,  still alive or no one dispose instance . 

 

After you read it , the state is changed to DDS_READ_SAMPLE_STATE .

(If you read again with state filter DDS_NOT_READ_SAMPLE_STATE , you will return nothing )

 

And now , if your writer is killed or dispose the instance . 

The sample state on reader side will change to 

1. DDS_READ_SAMPLE_STATE , because you have read it once.

2. DDS_NOT_NEW_VIEW_STATE, because you have seen it .

3. DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE or DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE

 

And this is important , the DDS_DATA_AVAILABLE_STATUS is triggered , because the DDS_ALIVE_INSTANCE_STATE is changed .

Even there is nothing sent to reader side .

 

But the sample info will tag it "valid_data=false" to imply "this is not real data ."

 

So , if you read sample without any state filter , and you don't check valid_data flag 

 

You will seem to see "you received twice sample" , but actually the second is invalid sample , because this is triggered by state change .

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×