SCSI support: ROG Arion external drive LED control

This commit is contained in:
Luke D. Jones
2024-12-21 20:35:51 +13:00
parent 19ffcf3376
commit 0f2d89858e
24 changed files with 1393 additions and 172 deletions

48
rog-scsi/src/lib.rs Normal file
View File

@@ -0,0 +1,48 @@
mod builtin_modes;
mod error;
mod scsi;
pub use builtin_modes::*;
pub use error::*;
use serde::{Deserialize, Serialize};
pub use sg::{Device, Task};
pub const PROD_SCSI_ARION: &str = "1932";
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub enum ScsiType {
Arion,
#[default]
Unsupported,
}
impl ScsiType {
pub const fn prod_id_str(&self) -> &str {
match self {
ScsiType::Arion => PROD_SCSI_ARION,
ScsiType::Unsupported => "",
}
}
}
impl From<&str> for ScsiType {
fn from(s: &str) -> Self {
match s.to_lowercase().as_str() {
PROD_SCSI_ARION | "0x1932" => Self::Arion,
_ => Self::Unsupported,
}
}
}
impl From<ScsiType> for &str {
fn from(s: ScsiType) -> Self {
match s {
ScsiType::Arion => PROD_SCSI_ARION,
ScsiType::Unsupported => "Unsupported",
}
}
}
pub fn open_device(path: &str) -> Result<Device, std::io::Error> {
Device::open(path)
}