1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::{
CPUControlFlags, TxDatagram, MSG_RD_CPU_VERSION, MSG_RD_FPGA_FUNCTION, MSG_RD_FPGA_VERSION,
};
use anyhow::Result;
#[derive(Default)]
pub struct CPUVersion {}
impl CPUVersion {
pub fn pack(&mut self, tx: &mut TxDatagram) -> Result<()> {
tx.header_mut().msg_id = MSG_RD_CPU_VERSION;
tx.header_mut().cpu_flag = CPUControlFlags::from_bits(0x02).unwrap(); tx.num_bodies = 0;
Ok(())
}
}
#[derive(Default)]
pub struct FPGAVersion {}
impl FPGAVersion {
pub fn pack(&mut self, tx: &mut TxDatagram) -> Result<()> {
tx.header_mut().msg_id = MSG_RD_FPGA_VERSION;
tx.header_mut().cpu_flag = CPUControlFlags::from_bits(0x04).unwrap(); tx.num_bodies = 0;
Ok(())
}
}
#[derive(Default)]
pub struct FPGAFunctions {}
impl FPGAFunctions {
pub fn pack(&mut self, tx: &mut TxDatagram) -> Result<()> {
tx.header_mut().msg_id = MSG_RD_FPGA_FUNCTION;
tx.header_mut().cpu_flag = CPUControlFlags::from_bits(0x05).unwrap(); tx.num_bodies = 0;
Ok(())
}
}