Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Schmied committed Nov 17, 2022
0 parents commit 35f42a2
Show file tree
Hide file tree
Showing 7 changed files with 481 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Christoph Schmied

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# BladeRF SDR asynchronous wrapper

A python wrapper for the bladerf python bindings from Nuand. It provides synchronous as well as asynchronous functionality to send and receive data to and from the BladeRF SDR.

## Installation

- To install system-wide: `sudo python3 setup.py install`
- To install for your user: `python3 setup.py install`

## Usage

Below is an example of how to use the asynchronous wrapper with a python context manager and an asynchronous generator
to continuously receive samples from the SDR for 5 seconds.

```python
import asyncio
import bladerf
from bladerfsdraio import AioBladeRF


async def main():
with AioBladeRF() as sdr:
ch_rx = sdr.Channel(bladerf.CHANNEL_RX(0))
ch_rx.sample_rate = 1e6
ch_rx.frequency = 1e9

async def stream_samples(sdr: AioBladeRF):
async for samples in sdr.stream_samples_async(ch_rx, chunk_size=1024):
# .. handle samples
print(samples.max())

async def cancel_after(secs: float, sdr: AioBladeRF):
await asyncio.sleep(secs)
sdr.cancel_receive()

await asyncio.gather(
stream_samples(sdr),
cancel_after(5, sdr)
)


if __name__ == '__main__':
asyncio.run(main())
```
1 change: 1 addition & 0 deletions bladerfsdraio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .bladerfsdraio import AioBladeRF, print_channel_info
Binary file added bladerfsdraio/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 35f42a2

Please sign in to comment.