sub

class cyclonedds.sub.Subscriber(domain_participant, qos=None, listener=None)[source]

Bases: Entity

Parameters:
notify_readers()[source]
class cyclonedds.sub.DataReader(subscriber_or_participant, topic, qos=None, listener=None)[source]

Bases: Entity, Generic[_T]

Subscribe to a topic and read/take the data published to it.

All returned samples are annotated with the sample.sample_info attribute.

Parameters:
property topic: Topic[_T]
read(N=1, condition=None, instance_handle=None)[source]

Read a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.

Reading samples does not remove them from the DataReader's receive queue. So read methods may return the same sample in multiple calls.

Parameters:
Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type:

List[_T]

take(N=1, condition=None, instance_handle=None)[source]

Take a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.

Taking samples removes them from the DataReader's receive queue. So take methods will not return the same sample more than once.

Parameters:
Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type:

List[_T]

read_next()[source]

Shortcut method to read exactly one sample or return None.

Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type:

Optional[_T]

take_next()[source]

Shortcut method to take exactly one sample or return None.

Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type:

Optional[_T]

read_iter(condition=None, timeout=None)[source]

Shortcut method to iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters:

timeout (int) –

Return type:

Generator[_T, None, None]

read_one(condition=None, timeout=None)[source]

Shortcut method to block and take exactly one sample or raise a timeout

Parameters:

timeout (int) –

Return type:

_T

take_iter(condition=None, timeout=None)[source]

Shortcut method to iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters:

timeout (int) –

Return type:

Generator[_T, None, None]

take_one(condition=None, timeout=None)[source]

Shortcut method to block and take exactly one sample or raise a timeout

Parameters:

timeout (int) –

Return type:

_T

async read_aiter(condition=None, timeout=None)[source]

Shortcut method to async iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters:

timeout (int) –

Return type:

AsyncGenerator[_T, None]

async take_aiter(condition=None, timeout=None)[source]

Shortcut method to async iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises:

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters:

timeout (int) –

Return type:

AsyncGenerator[_T, None]

wait_for_historical_data(timeout)[source]
Parameters:

timeout (int) –

Return type:

bool

lookup_instance(sample)[source]
Parameters:

sample (_T) –

Return type:

Optional[int]

get_matched_publications()[source]

Get instance handles of the data writers matching a reader.

Raises:

DDSException – When the number of matching writers < 0.:

Returns:

A list of instance handles of the matching data writers.

Return type:

List[int]

property matched_pub: List[int]

Get instance handles of the data writers matching a reader.

Raises:

DDSException – When the number of matching writers < 0.:

Returns:

A list of instance handles of the matching data writers.

Return type:

List[int]

get_matched_publication_data(handle)[source]

Get a description of a writer matched with the provided reader.

Parameters:

handle (Int) – The instance handle of a writer.

Returns:

The sample of the DcpsEndpoint built-in topic.

Return type:

DcpsEndpoint

get_liveliness_changed_status()[source]

Get LIVELINESS_CHANGED status

Raises:

DDSException

Returns:

The class ‘liveness_changed_status’ value.

Return type:

liveness_changed_status

get_requested_deadline_missed_status()[source]

Get REQUESTED DEALINE MISSED status

Raises:

DDSException

Returns:

The class ‘requested_deadline_missed_status’ value.

Return type:

requested_deadline_missed_status

get_requested_incompatible_qos_status()[source]

Get REQUESTED INCOMPATIBLE QOS status

Raises:

DDSException

Returns:

The class ‘requested_incompatible_qos_status’ value.

Return type:

requested_incompatible_qos_status

get_sample_lost_status()[source]

Get SAMPLE LOST status

Raises:

DDSException

Returns:

The class ‘sample_lost_status’ value.

Return type:

sample_lost_status

get_sample_rejected_status()[source]

Get SAMPLE REJECTED status

Raises:

DDSException

Returns:

The class ‘sample_rejected_status’ value.

Return type:

sample_rejected_status

get_subscription_matched_status()[source]

Get SUBSCRIPTION MATCHED status

Raises:

DDSException

Returns:

The class ‘subscription_matched_status’ value.

Return type:

subscription_matched_status