Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
inesmaria08 committed Sep 26, 2024
1 parent a208bcc commit 5ebe3e8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions apis/interface/servo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ impl<S: Syscalls> Servo<S> {
}
}
/// Returns the number of the servomotors available.
pub fn servo_number() -> Result<u32, ErrorCode> {
S::command(DRIVER_NUM, SERVO_NUMBER, 0, 0).to_result()
pub fn servo_count() -> Result<u32, ErrorCode> {
S::command(DRIVER_NUM, SERVO_COUNT, 0, 0).to_result()
}

/// Changes the angle of the servo.
Expand Down Expand Up @@ -59,6 +59,6 @@ const DRIVER_NUM: u32 = 0x90009;

// Command IDs
const EXISTS: u32 = 0;
const SERVO_NUMBER: u32 = 1;
const SERVO_COUNT: u32 = 1;
const SET_ANGLE: u32 = 2;
const GET_ANGLE: u32 = 3;
4 changes: 2 additions & 2 deletions apis/interface/servo/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ fn exists() {
assert_eq!(Servo::exists(), Ok(()));
}
#[test]
fn servo_number() {
fn servo_count() {
let kernel = fake::Kernel::new();
let driver = fake::Servo::<2>::new();
kernel.add_driver(&driver);
assert_eq!(Servo::servo_number(), Ok(2));
assert_eq!(Servo::servo_count(), Ok(2));
}
#[test]
fn set_angle() {
Expand Down
4 changes: 2 additions & 2 deletions examples/servo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ fn main() {
writeln!(Console::writer(), "The driver could not be found").unwrap();
return;
}
let servo_number = Servo::servo_number().unwrap();
let servo_count = Servo::servo_count().unwrap();

writeln!(
Console::writer(),
"The number of available servomotors is {:?}",
servo_number
servo_count
)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion unittest/src/fake/servo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ const DRIVER_NUM: u32 = 0x90009;

// Command numbers
const EXISTS: u32 = 0;
const SERVO_NUMBER: u32 = 1;
const SERVO_COUNT: u32 = 1;
const SET_ANGLE: u32 = 2;
const GET_ANGLE: u32 = 3;
4 changes: 2 additions & 2 deletions unittest/src/fake/servo/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn command() {
let value = servo.command(EXISTS, 0, 0);
assert_eq!(CommandReturn::is_success(&value), true);
assert_eq!(
CommandReturn::get_success_u32(&servo.command(SERVO_NUMBER, 0, 0)),
CommandReturn::get_success_u32(&servo.command(SERVO_COUNT, 0, 0)),
Some(1)
);
assert_eq!(
Expand All @@ -32,7 +32,7 @@ fn kernel_integration() {
let value = fake::Syscalls::command(DRIVER_NUM, EXISTS, 0, 0);
assert_eq!(CommandReturn::is_success(&value), true);
assert_eq!(
CommandReturn::get_success_u32(&fake::Syscalls::command(DRIVER_NUM, SERVO_NUMBER, 0, 0)),
CommandReturn::get_success_u32(&fake::Syscalls::command(DRIVER_NUM, SERVO_COUNT, 0, 0)),
Some(1)
);
assert_eq!(
Expand Down

0 comments on commit 5ebe3e8

Please sign in to comment.