Skip to content

Commit

Permalink
Add serial feature
Browse files Browse the repository at this point in the history
- No need to pull serialport-rs and embedded-hal-nb in projects that do
  not need serial functionality.

Signed-off-by: Ayush Singh <[email protected]>
  • Loading branch information
Ayush1325 committed Feb 4, 2025
1 parent 3ed5ad8 commit c9692e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ gpio_cdev = ["gpio-cdev"]
async-tokio = ["gpio-cdev/async-tokio", "dep:embedded-hal-async", "tokio/time"]
i2c = ["i2cdev"]
spi = ["spidev"]
serial = ["serialport", "embedded-hal-nb"]

default = [ "gpio_cdev", "gpio_sysfs", "i2c", "spi" ]
default = [ "gpio_cdev", "gpio_sysfs", "i2c", "spi", "serial" ]

[dependencies]
embedded-hal = "1"
embedded-hal-nb = "1"
embedded-hal-nb = { version = "1", optional = true }
embedded-hal-async = { version = "1", optional = true }
gpio-cdev = { version = "0.6.0", optional = true }
sysfs_gpio = { version = "0.6.1", optional = true }
i2cdev = { version = "0.6.0", optional = true }
nb = "1"
serialport = { version = "4.2.0", default-features = false }
serialport = { version = "4.2.0", default-features = false, optional = true }
spidev = { version = "0.6.0", optional = true }
nix = "0.27.1"
tokio = { version = "1", default-features = false, optional = true }
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[cfg(feature = "i2c")]
pub use i2cdev;
pub use nb;
#[cfg(feature = "serial")]
pub use serialport;
#[cfg(feature = "spi")]
pub use spidev;
Expand Down Expand Up @@ -43,6 +44,7 @@ pub use sysfs_pin::{SysfsPin, SysfsPinError};
mod delay;
#[cfg(feature = "i2c")]
mod i2c;
#[cfg(feature = "serial")]
mod serial;
#[cfg(feature = "spi")]
mod spi;
Expand All @@ -51,6 +53,7 @@ mod timer;
pub use crate::delay::Delay;
#[cfg(feature = "i2c")]
pub use crate::i2c::{I2CError, I2cdev};
#[cfg(feature = "serial")]
pub use crate::serial::{Serial, SerialError};
#[cfg(feature = "spi")]
pub use crate::spi::{SPIError, SpidevBus, SpidevDevice};
Expand Down

0 comments on commit c9692e1

Please sign in to comment.