ostrosco / comms-rs

A library for building DSP communication pipelines.
MIT License
13 stars 1 forks source link

Create "Radio" HAL #33

Closed rfdoell closed 5 years ago

rfdoell commented 5 years ago

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.

ostrosco commented 5 years ago

This looks good for a basis for the trait. There's one that I think warrants discussion though which is send_samples. For example, the RTL-SDR doesn't allow transmission so send_samples would do nothing. We could easily do something like have send_samples do nothing, but outside of comments there's not going to be a nice way to indicate via the traits that a node doesn't support particular functionality of the trait. The only way I could think of handling this is making multiple traits: one trait for configuration, one for support receives, and one for supporting transmits. Any thoughts?

garbagetrash commented 5 years ago

As a first pass I think that solution is probably fine. We'll go with it until it breaks, anyways. Go forth and code!

ostrosco commented 5 years ago

Initial work added as part of #36.