Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedded-hal-1.0.0 examples update #129

Open
pdgilbert opened this issue Mar 21, 2024 · 1 comment
Open

embedded-hal-1.0.0 examples update #129

pdgilbert opened this issue Mar 21, 2024 · 1 comment

Comments

@pdgilbert
Copy link

Using @matheo-lucak 's fork of rust-radio-sx127x I finally have some examples compiling with embedded-hal-1.0.0 on stm32f4xx_hal and forks/branches of stm32g4xx_hal and stm32h7xx_hal. (Details are reported with other examples at https://github.com/pdgilbert/rust-integration-testing/actions . See jobs eg(lora_spi* in the workflow runs.)

The lora_spi_send and lora_spi_receive examples compile with all three hals. The lora_spi_gps example does not compile on stm32f4xx_hal because the embedded-io traits are not implemented. (See stm32-rs/stm32f4xx-hal#721.) It compiles but probably does not work yet withstm32g4xx_hal and stm32h7xx_hal. I need to rework some logic for the change to embedded-io traits. Nothing has yet been tested on hardware.

One problem that I found subtle is the need for common versions for traits to work properly. In particular I had trouble with Transmit and Receive traits. For example, in my Cargo.toml I need

radio = { version = "0.11.1", git = "https://github.com/rust-iot/radio-hal", rev = "7aade85b61c08161bf3422f7d148417bd38ecdc2" }
radio-sx127x  = {  git = "https://github.com/matheo-lucak/rust-radio-sx127x", default-features = false }

which specifies that the radio rev is the same as that used by radio-sx127x. If I do simple

radio         = { git = "https://github.com/rust-iot/radio-hal" } 
radio-sx127x  = { git = "https://github.com/matheo-lucak/rust-radio-sx127x", default-features = false }

the error messages can be very confusing:

Click to expand compiling error
...
error[E0599]: no method named `start_transmit` found for struct `Sx127x` in the current scope
  --> examples/radio-sx127x/lora_spi_send.rs:94:14
   |
94 |         lora.start_transmit(message).unwrap(); // should handle error
   |              ^^^^^^^^^^^^^^ method not found in `Sx127x<Base<Spi<SPI1>, ..., ..., ..., ..., ...>>`
   |
  ::: /home/paul/.cargo/git/checkouts/radio-hal-f38ece0492420e67/7aade85/src/lib.rs:39:8
   |
39 |     fn start_transmit(&mut self, data: &[u8]) -> Result<(), Self::Error>;
   |        -------------- the method is available for

... 

help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
45 + use radio::Transmit;
   |

...

warning: unused import: `radio::Transmit`
  --> examples/radio-sx127x/lora_spi_send.rs:57:5
   |
57 | use radio::Transmit;
   |     ^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

...

Is it possible radio-sx127x can re-export radio traits so I can manage this problem by using traites from radio-sx127x rather than from radio?

(BTW I have closed several old issues that are out-of-date. Thanks for all your help on those @ryankurte)

@pdgilbert
Copy link
Author

The rust-iot/rust-radio-sx127x master branch seems to be stuck at embedded-hal-rc. I can compile @matheo-lucak 's fork embedded-hal-1.0 but am not having any luck getting it to work on hardware (using stm32f4xx_hal with blackpill stm32f411 and stm32g4xx_hal with weact-stm32g474). I forked it to try and debug with my examples, but no luck with that either.

Does anyone actually have this working? On what hardware? Any other suggestions? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant