Skip to content

Commit add6a4c

Browse files
committed
dio_mode
1 parent 0c81dd8 commit add6a4c

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55
license-file = "LICENSE"
66
name = "lebai_sdk"
77
repository = "https://github.com/lebai-robotics/lebai-sdk.rs"
8-
version = "0.2.20"
8+
version = "0.2.21"
99

1010
[workspace]
1111
members = [

proto/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["protobuf"]
66
license = "MIT"
77
name = "lebai-proto"
88
repository = "https://github.com/lebai-robotics/lebai-sdk.rs"
9-
version = "3.2.2"
9+
version = "3.2.3"
1010

1111
[dependencies]
1212
jsonrpsee = {version = "0.24", features = ["client-core", "macros"]}

src/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ mod rpc;
55
mod runtime;
66

77
#[cmod::cmod]
8-
pub mod lebai_sdk {
8+
mod lebai_sdk {
99
use super::*;
1010
use cmod::Result;
1111
use proto::lebai::claw::Claw;
1212
use proto::lebai::dynamic::Payload;
13+
use proto::lebai::io::DigitalMode;
1314
use proto::lebai::posture::Position;
1415
use proto::lebai::system::{EstopReason, PhyData, RobotState};
1516
use proto::serde::kinematic::KinData;
@@ -208,6 +209,16 @@ pub mod lebai_sdk {
208209

209210
//IO
210211
#[classmethod]
212+
#[cmod::tags(args(device, mode))]
213+
pub async fn set_dio_mode(&self, device: String, pin: u32, mode: DigitalMode) -> Result<()> {
214+
self.0.set_dio_mode(device, pin, mode).await
215+
}
216+
#[classmethod]
217+
#[cmod::tags(args(device), ret)]
218+
pub async fn get_dio_mode(&self, device: String, pin: u32) -> Result<DigitalMode> {
219+
self.0.get_dio_mode(device, pin).await
220+
}
221+
#[classmethod]
211222
#[cmod::tags(args(device))]
212223
pub async fn set_do(&self, device: String, pin: u32, value: u32) -> Result<()> {
213224
self.0.set_do(device, pin, value).await

src/rpc/io.rs

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ use cmod::Result;
33
use proto::lebai::io::*;
44

55
impl Robot {
6+
pub(crate) async fn set_dio_mode(&self, device: String, pin: u32, mode: DigitalMode) -> Result<()> {
7+
let req = SetDioModeRequest {
8+
device: IoDevice::from(&*device).into(),
9+
pin,
10+
mode: mode.into(),
11+
};
12+
let _ = self.c.set_dio_mode(Some(req)).await.map_err(|e| e.to_string())?;
13+
Ok(())
14+
}
15+
pub(crate) async fn get_dio_mode(&self, device: String, pin: u32) -> Result<DigitalMode> {
16+
let req = GetDioModeRequest {
17+
device: IoDevice::from(&*device).into(),
18+
pin,
19+
};
20+
let resp = self.c.get_dio_mode(Some(req)).await.map_err(|e| e.to_string())?;
21+
Ok(resp.mode())
22+
}
623
pub(crate) async fn set_do(&self, device: String, pin: u32, value: u32) -> Result<()> {
724
let req = SetDoPinRequest {
825
device: IoDevice::from(&*device).into(),

0 commit comments

Comments
 (0)