Struct apigpio::ConnectionCore
source · pub struct ConnectionCore { /* private fields */ }
Expand description
Most of the Connection
methods, mirroring pigpiod_if2
,
are actually provided here.
Where methods are named after a facility in pigpiod_if2
http://abyz.me.uk/rpi/pigpio/pdif2.html they perform the same
function here. Documentation here in agpipio
is present only
if there is something unusual.
Implementations
sourceimpl ConnectionCore
impl ConnectionCore
pub async fn set_mode(&self, pin: PPin, mode: GpioMode) -> Result<()>
pub async fn get_mode(&self, pin: PPin) -> Result<GpioMode>
pub async fn set_pull_up_down(&self, pin: PPin, pud: PullUpDown) -> Result<()>
pub async fn gpio_read(&self, pin: PPin) -> Result<Level>
pub async fn gpio_write(&self, pin: PPin, level: Level) -> Result<()>
pub async fn wave_clear(&self) -> Result<()>
pub async fn wave_add_new(&self) -> Result<WaveId>
sourcepub async fn wave_create(&self) -> Result<WaveId>
pub async fn wave_create(&self) -> Result<WaveId>
Create a waveform (globally, in pigpiod)
Caller is responsible for not calling wave_*
functions for
multiple purposes concurrently - ie, for enforcing the
concurrency control implied by pigpiod’s interface.
Getting this wrong is not a memory safety concern (hence the lack of unsafe) but would cause wrong behaviours.
Note that this applies even across multiple different pigpiod clients.
sourcepub async unsafe fn wave_delete(&self, wave: WaveId) -> Result<()>
pub async unsafe fn wave_delete(&self, wave: WaveId) -> Result<()>
Delete a waveform (globally, in pigpiod)
Safety
This is safe if no-one in the whole system ever calls
wave_send_using_mode
with mode *SYNC*
. See the pigpio
documentation on wave_send_using_mode
for full details.
It is usually easier
to call the safe function
wave_clear
before startup, and during shutdown,
than to worry about these questions.
pub async fn wave_send_once(&self, wave: WaveId) -> Result<Word>
pub async fn wave_send_repeat(&self, wave: WaveId) -> Result<Word>
pub async fn wave_tx_stop(&self) -> Result<()>
pub async fn wave_tx_at(&self) -> Result<Option<WaveId>>
pub async fn wave_tx_busy(&self) -> Result<bool>
pub async fn wave_add_generic(&self, pulses: &[Pulse]) -> Result<Word>
pub async fn wave_get_micros(&self) -> Result<Word>
pub async fn wave_get_high_micros(&self) -> Result<Word>
pub async fn wave_get_max_micros(&self) -> Result<Word>
sourcepub async unsafe fn wave_send_using_mode(
&self,
wave: WaveId,
txmode: Word
) -> Result<Word>
pub async unsafe fn wave_send_using_mode(
&self,
wave: WaveId,
txmode: Word
) -> Result<Word>
Start sending a waveform using a specified mode
value
Safety
Caller must ensure that if txmode
is *SYNC*
the “bad things”
described in the pigpio docs do not happen.
If any calls to this facility
(whether via apigpio or any other way of talking to pigpiod)
use *SYNC*
, then wave_delete
(and the equivalent function in other pigpiod bindings)
is potentially unsafe and all calls to it must be checked.
Note that because everything is shared amongst all clients of
pigpiod, this might involve auditing your process handling etc.
Caller must also ensure that txmode
is a known valid value,
which represents a safe and sane mode.
Unknown values are unsound because they might
invoke some hazardous new feature of pigpiod.