golemparts / rppal

A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
MIT License
1.21k stars 96 forks source link

PinNotAvailable(): how to drop and reinit pin? #111

Closed mateusz-szczyrzyca closed 2 years ago

mateusz-szczyrzyca commented 2 years ago

Hello,

First of all, thanks for working on that crate.

I need to reinitialize pins from time to time (live config reload). So normally I read from pins, but after reload, I want to "clean" everything and initialize again (same pins)

Current code throws the following error in such scenario: PinNotAvailable(NUM) - I fully understand, I checked the source code, but I didn't find the clear way how to "reset" pin.

I tried drop() for gpio and IoPin but that didn't help with this. Still same issue.

So my question is: what's the simplest way to "drop/reset/release" pin and init again?

Thanks in advance,

mateusz-szczyrzyca commented 2 years ago

Ok, I realized one thread was keeping gpio reading in the background, so that's why it wasn't dropped. Closing.