Enum blinkt::GpioError

source ·
pub enum GpioError {
    InvalidPin(u8),
    UnknownMode(u8),
    UnknownSoC,
    PermissionDenied,
    InstanceExists,
    NotInitialized,
    Io(Error),
    ThreadPanic,
}
Expand description

Errors that can occur when accessing the GPIO peripheral.

Variants

InvalidPin(u8)

Invalid GPIO pin number.

The GPIO pin number is not available on this Raspberry Pi model.

UnknownMode(u8)

Unknown GPIO pin mode.

The GPIO pin is set to an unknown mode.

UnknownSoC

Unknown SoC.

It wasn’t possible to automatically identify the Raspberry Pi’s SoC.

PermissionDenied

Permission denied when opening /dev/gpiomem and/or /dev/mem for read/write access.

Make sure the user has read and write access to /dev/gpiomem. Common causes are either incorrect file permissions on /dev/gpiomem, or the user isn’t a member of the gpio group. If /dev/gpiomem is missing, upgrade to a more recent version of Raspbian.

/dev/mem is a fallback when /dev/gpiomem can’t be accessed. Getting read and write access to /dev/mem is typically accomplished by executing the program as a privileged user through sudo. A better solution that doesn’t require sudo would be to upgrade to a version of Raspbian that implements /dev/gpiomem.

InstanceExists

An instance of Gpio already exists.

Multiple instances of Gpio can cause race conditions or pin configuration issues when several threads write to the same register simultaneously. While other applications can’t be prevented from writing to the GPIO registers at the same time, limiting Gpio to a single instance will at least make the Rust interface less error-prone.

You can share a Gpio instance with other threads using channels, or cloning an Arc<Mutex<Gpio>>. Although discouraged, you could also share it globally wrapped in a Mutex using the lazy_static crate.

NotInitialized

Gpio isn’t initialized.

You should normally only see this error when you call a method after running cleanup.

Io(Error)

IO error.

ThreadPanic

Interrupt polling thread panicked.

Trait Implementations

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
The lower-level source of this error, if any. Read more
👎Deprecated since 1.42.0: use the Display impl or to_string()
🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.