forked from M-Labs/kirdy
Add a separate tec_set_i cmd to reduce overhead
- miniconf is slow at validating complex struct with large enum lists
This commit is contained in:
parent
9f82fa58f4
commit
b1fa0e51c8
@ -153,9 +153,30 @@ pub fn send_status_report(buffer: &mut [u8], laser: &mut LdDrive, tec: &mut Ther
|
|||||||
net::eth_send(buffer, num_bytes);
|
net::eth_send(buffer, num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use a minimal struct for high speed cmd ctrl to reduce processing overhead
|
||||||
|
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Default, Tree)]
|
||||||
|
pub struct TecSetICmdJson {
|
||||||
|
tec_set_i: f64
|
||||||
|
}
|
||||||
|
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Default, Tree)]
|
||||||
|
pub struct TecSetICmd {
|
||||||
|
json: TecSetICmdJson
|
||||||
|
}
|
||||||
|
|
||||||
pub fn execute_cmd(buffer: &mut [u8], buffer_size: usize, mut laser: LdDrive, mut tec: Thermostat, mut device_settings: DeviceSettings)->(LdDrive, Thermostat, bool, DeviceSettings){
|
pub fn execute_cmd(buffer: &mut [u8], buffer_size: usize, mut laser: LdDrive, mut tec: Thermostat, mut device_settings: DeviceSettings)->(LdDrive, Thermostat, bool, DeviceSettings){
|
||||||
let mut should_reset = false;
|
let mut should_reset = false;
|
||||||
|
|
||||||
|
let mut cmd = TecSetICmd {
|
||||||
|
json: TecSetICmdJson::default()
|
||||||
|
};
|
||||||
|
match cmd.set_json("/json", &buffer[0..buffer_size]){
|
||||||
|
Ok(_) => {
|
||||||
|
tec.set_i(ElectricCurrent::new::<milliampere>(cmd.json.tec_set_i));
|
||||||
|
return (laser, tec, should_reset, device_settings);
|
||||||
|
}
|
||||||
|
Err(_) => { /* Do Nothing */}
|
||||||
|
}
|
||||||
|
|
||||||
let mut cmd = Cmd {
|
let mut cmd = Cmd {
|
||||||
json: CmdJsonObj::default()
|
json: CmdJsonObj::default()
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user