sftool_lib/common/
speed.rs1use crate::common::ram_command::{Command, RamCommand, RamOps};
2use crate::{Result, SifliToolTrait};
3use std::time::Duration;
4
5pub struct SpeedOps;
7
8impl SpeedOps {
9 pub fn set_speed<T>(tool: &mut T, speed: u32) -> Result<()>
11 where
12 T: SifliToolTrait + RamCommand,
13 {
14 tool.command(Command::SetBaud {
16 baud: speed,
17 delay: 10,
18 })?;
19
20 std::thread::sleep(Duration::from_millis(50));
22
23 tool.port().set_baud_rate(speed)?;
25
26 tool.port().clear(serialport::ClearBuffer::All)?;
27
28 RamOps::wait_for_shell_prompt(tool.port(), b"msh >", 200, 5)?;
29
30 Ok(())
31 }
32}