Code Monkey home page Code Monkey logo

comms-rs's Introduction

comms-rs

Build Status

A library for building DSP communication pipelines. The goal of this experimental project is explore the use of Rust for the generation of signals in real time. The memory model and ease of concurrency in rust are potentially very useful for a data flow graph style of processing, with each node running in its own thread.

Currently macros are being worked on that allow a user to easily drop an arbitrary defined function into a graph node, and ease the development of potentially complicated processing pipelines.

There will be node functions defined for several common DSP and communications oriented tasks (such as mixing, filtering, FFTs, etc...) and provided directly in the project for immediate use. Additionally hardware interfaces will be provided to work with a few common SDR platforms.

Initial Goals:

  • Node based architecture
  • FFT/IFFT
  • FIR filter
  • Decimation
  • Upsampling
  • Pulse shaping
  • Mixer
  • BPSK modulation
  • Write/read to/from file
  • Hardware support for HackRF
  • Hardware support for rtl-sdr
  • Hardware support for BladeRF

Creating Your Own Nodes

The easiest way to create your own nodes is to derive the Node trait for your structure. The macro used to derive the Node trait is a bit magical, so there are certain assumptions it makes in order for the derivation to work properly.

To derive the trait, there are a few requirements that much be met.

  • Any inputs to the node must be of the type NodeReceiver.
  • Any outputs from the node must be of the type NodeSender.
  • The structure must implement a method named run(). The signature of run() is currently expected to take &mut self followed by every input type received in order defined in the structure. It is expected to return a Result<U, NodeError>.

Example:

#[derive(Node)]
pub struct ExampleNode {
    input1: NodeReceiver<u32>,
    input2: NodeReceiver<f64>,
    output: NodeSender<u8>,
}

impl ExampleNode {
    pub fn run(&mut self, input1: u32, input2: f64) -> Result<u8, NodeError> {
        ...
    }
}

comms-rs's People

Contributors

alex-addy avatar barkera avatar chris--b avatar garbagetrash avatar ostrosco avatar rfdoell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

chris--b

comms-rs's Issues

Create README for comms-rs

In order for the team/community to understand the purpose and aims of the project, a project README shoudl be created.

Make Mixer Node

This should be pretty straightforward. We need to be able mix things up and down in frequency with the software equivalent of an oscillator.

codecogseqn 1

Likely this is the type of operation we'll want to run as a batch in a real system, so make sure to include support for both sample by sample processing as well as batch processing.

Add logging support

For debugging and error reporting purposes, we would like to add logging support to the library.

Sparse Documentation: pulse module

Update documentation for the pulse module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Sparse Documentation

The documentation seems pretty sparse. Probably should make a concerted effort to comb through it and add where you can. Since 'improve documentation' is a pretty vague goal we should discuss some kind of boxed boundaries for the scope of this, or maybe just vote on whether it's good enough or something.

Anyways, I feel like we can do a bit better here.

Create type-conversion nodes

As different nodes have different type requirements, it's often needed to convert from one type to another. We'd like to create nodes to support the following:

  • Convert from Complex to Complex.
  • Convert from Vec<Complex> to Vec (alternating real/imag).
  • Convert from T to U assuming U: From.

Improve error handling

Currently there isn't a good way to handle errors that occur within a node and propagate them up to the network. We need a way to try to handle errors, tell when nodes are being starved, etc.

Sparse Documentation: prn module

Update documentation for the prn module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Add support for multi-sends from nodes

We'd like to be able to support multi-sends, i.e. one node sends multiple times on the same channels. This would be useful in cases where the node generates a vector but data should be sent out of the node one sample at a time.

Create skeleton for project

To decrease the barrier to entry for contribution, a basic skeleton of the project should be created so that developers can write code for the comms-rs project.

Acceptance:

  • Documentation for contribution or project skeleton created
  • Issues generated to support fleshing out the skeleton
  • Deployment keys/system determined

Add support for optional inputs

In order to allow control of nodes, we need to be able to support inputs into the nodes that are provided on demand versus on every iteration of the node.

Sparse Documentation: hardware module

Update documentation for the hardware module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Create network to manage nodes

To manage nodes better, we want to be able to manage all of the nodes in a network so we can do stuff like share state between the network, gracefully shutdown, etc.

Create upsampling node

This will be a simple upsampling node that merely injects zeros when upsampling for now.

Improve graph API

Currently the graph API is super clunky, requiring locking and such to build the graph. This should be made much easier.

Improve generated documentation

Currently the generated documentation from cargo doc is either incomplete or unreadable. We'd like to improve the documentation to make use of the library easier.

Add FM support

We'd like to support FM: both modulation and demodulation.

Sparse Documentation: fft module

Update documentation for the fft module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Create "Radio" HAL

As a user of the comms-rs system, I would like to have a radio hardware abstraction layer so that I can use one interface to setup whatever physical hardware I have on hand.

Prior to implementation, as per @Alex-Addy 's suggestion, we should investigate general rustic HAL implementations and see if there are any relevant traits.

For example, the main trait should have the following methods, or method-like abilities:

Radio:
    setup -> initializes any appropriate transfers
    teardown -> cleans up any resources and memory
    [set|get]_center_freq -> sets the center frequency of the radio appropriately for the hardware chain
    [set|get]_samp_rate -> Sets appropriate "bandwidth" to the given number or gets the value
    [set|get]_gain -> Sets/gets the hardware gain
    recv_samples(number, input_idx) -> Gets the number of samples for the given "antenna" or input
    send_samples(samples, output_idx) -> Sends the given samples to the selected "antenna" or output

These should be universal for any kind of radio that we support. Individual implementations could have additional methods for modifying tuning parameters (various IF stages) or gains, but would require the user to have knowledge of the particular hardware platform.

Add ability to plot data

We would like the ability to plot spectrum and time domain sample data for analysis. We need to assess whether or not we can do this at run-time.

Make Upsampling/Pulse Shaping Node

We want a node or set of nodes that can receive the various complex valued symbols output from a modulator and upsample and pulse shape them. We'll keep it simple to start with and only target a couple basic shapes:

  • Rectangle pulse shaping
  • Root raised cosine (once we have an FIR filter implementation)

Taking a guess this would take the form of a node that receives a Complex value and spits out a vector of Complex. It would also have a couple parameters for things like samples per symbol, and total FIR filter tap length.

Sparse Documentation: mixer module

Update documentation for the mixer module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Create Node Prelude

Create a prelude that imports all the things that generated nodes need. Make sure to silence unused imports so that the users don't need to worry about it.

Batch Mode `Mixer` Implementation

Currently the Mixer module only has a sample by sample implementation. This is fine for demo purposes, but the batch mode implementation will be critical for any real world use cases.

Goals:

  • Batch mode Mixer implementation
  • Tests
  • Docs

Sparse Documentation: modulation module

Update documentation for the modulation module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Make FIR Filter Node

This one isn't 'hard' per se, but it's pretty important. FIR filters are gonna be everywhere in practice, as a minimal thing we'll need a naive implementation so we can do pulse shaping, alias filtering, and matched filtering.

Reference the wiki, but the basic equation is:

image

Where output signal is y[n], input signal is x[n], and filter taps (coefficients) are b_i.

Later on down the road if/when we end up doing all our batch processing we may want to extend this to do convolution via FFTs as an additional alternative node. FFT based filtering is faster once your number of taps is "large", which iirc in practice is something like 100+ taps. I'm not sure if even rust will be able to do filters that large real time, so I'm not sure if this will be something we want to bother with or not.

Either way, the scope of this issue is limited to the direct form 1 implementation, straightforward and easy. Filter implementation should just take vector of taps as input argument. Filter design is a later problem that can be solved, if it's even necessary. As a user I plan on doing the design outside of rust via Matlab or Scipy, then just grabbing those taps and dropping them into this node.

image

Make random number generator nodes

For now support for three specific node types would be nice:

  • Some node to do 0 and 1 generation, u8 output
  • Uniform random variable node, should support start and stop range parameters for node init()
  • Gaussian random variable node, should support mean and standard deviation parameters (mu and sigma)

These would be nice in and of themselves, but they can also serve as very basic node examples for the less rust inclined developers to model their nodes after. As such they should display 'best practice' and whatever that means for our team.

Create sys package for BladeRF

In order to enable the creation of a more rustic API for the BladeRF platform, comms-rs should provide a C interface to the blade RF API with appropriate tests.

Acceptance:

  • Minimal viable package created which can emulate libhackrf functionality in rust
  • Package has at least one test
  • Merge request accepted

Sparse Documenation: filter module

Update documentation for the filter module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Create FFT Node

We need a complex FFT and IFFT node. It needs to support interleaved IQ format in i16.

Create New Examples

I think we have the tools necessary to start doing some actually interesting things... we should make a couple examples demonstrating that fact. If it falls out from this that we're missing important things, then great! We'll add those as issues.

Sparse Documentation: prelude module

Update documentation for the prelude module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Create contribution guide

A contribution guide should be created and documented in the project so that new developers know how best to provide code to the comms-rs project.

Acceptance:

  • Guide created
  • Location of guide documented in the README
  • Example of workflow documented in the guide demonstrated on GitHub
  • Example referenced in guide somewhere

Create sys packages for HackRF

In order to enable the creation of a more rustic API for the HackRF platform, comms-rs should provide a C interface to the libhackrf API with appropriate tests.

Acceptance:

  • Minimal viable package created which can emulate libhackrf functionality in rust
  • Package has at least one test
  • Merge request accepted

Create "Radio" node

This node would be a wrapper for the Radio HAL, but would have intelligence around calling down to the HAL methods based on the streaming/synchronous behavior captured . The node could then be integrated into the graph for execution based on feedback created from other nodes.

Sparse Documentation: node module

Update documentation for the node module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Sparse Documentation: io module

Update documentation for the io module. In particular:

  • Add single line descriptions where missing, and extended descriptions where necessary
  • Add arguments sections where missing
  • Add examples sections where missing
  • Ensure all docs tests are passing

Use the util module documentation (or better) as a target for level of completeness.

Make PRNS Generator Node

This is a bit different than the random number generator node. The goal here is to use the standard linear-feedback shift register (LFSR) implementation of a PRNS generator. These are commonly used for communications systems for various things like frequency hopping and spread spectrum waveforms.

It's already basically implemented on the feature/prn branch, and supports LFSRs of size 8, 16, 32, 64, and 128 bits, as well as arbitrary polynomial specification for the generators. Reference for what I'm talking about regarding those polynomials. Crypto and coding theory nerds should recognize that Finite and Galois Field stuff. Note that in my implementation I've flipped around the direction that everything is flowing in that graphic, this is because in my mind bit 0 refers to the right most bit, and bit 15 would be the left most bit in that graphic.

image

Work remaining on this one is basically getting some decent documentation on the use written up, and some additional comments for the code. I won't bother explaining the operation of the LFSR, and will instead throw a reference into the docs somewhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.