rust-iot / rust-radio-sx127x

Rust driver for the Semtech SX127x series of Sub-GHz LoRa/ISM radio transceivers
Mozilla Public License 2.0
32 stars 16 forks source link

Upgrade dependencies #8

Closed BlinkyStitt closed 3 years ago

BlinkyStitt commented 4 years ago

Upgrade embedded-spi, structopt, radio, simplelog, humantime, color-backtrace.

I also dropped the patch versions from the cargo.toml. I've had a few headaches before dealing with mismatched match versions when a pin to the minor version is almost always fine. I can include the patch version if you prefer that though.

I was able to figure out some of the changes by looking at https://github.com/ryankurte/rust-embedded-spi/pull/2.

This doesn't compile yet though. I'm sure I'm missing something small.

$ cargo check --no-default-features
error[E0599]: no function or associated item named `new` found for struct `Sx127x<embedded_spi::wrapper::Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>, SpiError, PinError>` in the current scope
   --> src/lib.rs:142:15
    |
64  | pub struct Sx127x<Base, CommsError, PinError> {
    | --------------------------------------------- function or associated item `new` not found for this
...
142 |         Self::new(hal, config)
    |               ^^^ function or associated item not found in `Sx127x<embedded_spi::wrapper::Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>, SpiError, PinError>`
    | 
   ::: /Users/bwstitt/.cargo/registry/src/github.com-1ecc6299db9ec823/embedded-spi-0.6.2/src/wrapper.rs:13:1
    |
13  | pub struct Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> {
    | -------------------------------------------------------------------------------------- doesn't satisfy `_: base::Base<SpiError, PinError>`
    |
    = note: the method `new` exists but the following trait bounds were not satisfied:
            `embedded_spi::wrapper::Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>: base::Base<SpiError, PinError>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `radio-sx127x`.

To learn more, run the command again with --verbose.
BlinkyStitt commented 4 years ago

It looks like new expects a Base and not a Wrapper. I'm not sure how best to use these traits. Let me know, or feel free to commandeer this PR.

ryankurte commented 4 years ago

hey thanks, the trait bounds one these are a bit tricky because it's meant to be abstract over both SPI and UART, but Base is implemented for Wrapper, there's just a missing trait bound (see comment).

I also dropped the patch versions from the cargo.toml. I've had a few headaches before dealing with mismatched match versions when a pin to the minor version is almost always fine. I can include the patch version if you prefer that though.

it doesn't really matter imo. 0.2.1 will pull anything newer than that in the 0.2 series which is basically the same as not having the patch, though it means no regression is possible, and it's up to us (maintainers) to do our best not to break things across patches anyway.

(there's also rust-radio-sx128x to look at but, it's patched up for the embedded-hal alpha release and my spi-transactions patch, both of which will be huge simplifications when they're landed).

BlinkyStitt commented 4 years ago

I think it is working. I don't have hardware setup to test it yet, but it compiles

BlinkyStitt commented 4 years ago

I'm trying to test this, but I'm a bit stuck. Do you have any examples of this code being used? I'm not sure what to pass for delay

EDIT: I think this is right

let delay = hal::delay::Delay::new(device.SYST, &mut clocks);

OR

let delay = AsmDelay::new(asm_delay::bitrate::U32BitrateExt::mhz(48));
ryankurte commented 4 years ago

yeah that's right, just needs something that implements DelayMs and DelayUs from embedded-hal. There's a utility in the repo that demonstrates use, though linux-embedded-hal provides a Delay object.

henrikssn commented 3 years ago

Tested with embedded-spi 0.6.2 and it resolves the compilation errors also there.

Are there any plans to merge this soon?

ryankurte commented 3 years ago

thanks for the reminder, looks good to me