rtlsdr.helpers

rtlsdr.helpers.limit_calls(max_calls)[source]

Decorator to cancel async reads after the given number of calls.

Parameters

max_calls (int) – Number of calls to wait for before cancelling

Examples

Stop reading after 10 calls:
>>> @limit_calls(10)
>>> def read_callback(data, context):
>>>     print('signal mean:', sum(data)/len(data))
>>> sdr = RtlSdr()
>>> sdr.read_samples_async(read_callback)

Notes

See notes in limit_time()

rtlsdr.helpers.limit_time(max_seconds)[source]

Decorator to cancel async reads after a specified time period.

Parameters

max_seconds – Number of seconds to wait before cancelling

Examples

Stop reading after 10 seconds:
>>> @limit_time(10)
>>> def read_callback(data, context):
>>>     print('signal mean:', sum(data)/len(data))
>>> sdr = RtlSdr()
>>> sdr.read_samples_async(read_callback)

Notes

The context in either read_bytes_async() or read_samples_async() is relied upon and must use the default value (the RtlSdr instance)