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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use crate::{
    CPUControlFlags, TxDatagram, MSG_RD_CPU_VERSION, MSG_RD_CPU_VERSION_MINOR,
    MSG_RD_FPGA_FUNCTION, MSG_RD_FPGA_VERSION, MSG_RD_FPGA_VERSION_MINOR,
};
use anyhow::Result;
#[derive(Default)]
pub struct CPUVersionMajor {}
impl CPUVersionMajor {
    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 CPUVersionMinor {}
impl CPUVersionMinor {
    pub fn pack(&mut self, tx: &mut TxDatagram) -> Result<()> {
        tx.header_mut().msg_id = MSG_RD_CPU_VERSION_MINOR;
        tx.num_bodies = 0;
        Ok(())
    }
}
#[derive(Default)]
pub struct FPGAVersionMajor {}
impl FPGAVersionMajor {
    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 FPGAVersionMinor {}
impl FPGAVersionMinor {
    pub fn pack(&mut self, tx: &mut TxDatagram) -> Result<()> {
        tx.header_mut().msg_id = MSG_RD_FPGA_VERSION_MINOR;
        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(())
    }
}