gondola_core/packets/
bfsw_ack_packet.rs1use crate::prelude::*;
5
6#[cfg_attr(feature="pybindings", pyclass)]
9pub struct AckBfsw {
10 pub header : TelemetryPacketHeader,
11 pub ack_type : u8,
12 pub ret_code1 : u8,
13 pub ret_code2 : u8,
14 pub body : Vec<u8>
15}
16
17impl AckBfsw {
18 pub fn new() -> Self {
19 Self {
22 header : TelemetryPacketHeader::new(),
23 ack_type : 1,
24 ret_code1 : 0,
25 ret_code2 : 0,
26 body : Vec::<u8>::new()
27 }
28 }
29
30 }
39
40impl Serialization for AckBfsw {
41
42 const HEAD : u16 = 0x90eb;
43 const TAIL : u16 = 0x0000; const SIZE : usize = 13;
45
46 fn from_bytestream(stream : &Vec<u8>,
47 pos : &mut usize)
48 -> Result<Self, SerializationError> {
49 if stream.len() < *pos + 3 {
50 return Err(SerializationError::StreamTooShort);
51 }
52 let mut ack = AckBfsw::new();
53 ack.ack_type = parse_u8(stream, pos);
54 ack.ret_code1 = parse_u8(stream, pos);
55 ack.ret_code2 = parse_u8(stream, pos);
56 Ok(ack)
57 }
58
59 fn to_bytestream(&self) -> Vec<u8> {
60 let mut stream = Vec::<u8>::new();
61 stream.push(self.ack_type);
62 stream.push(self.ret_code1);
63 stream.push(self.ret_code2);
64 stream
65 }
66}
67
68impl TofPackable for AckBfsw {
69 const TOF_PACKET_TYPE : TofPacketType = TofPacketType::BfswAckPacket;
70}
71
72impl fmt::Display for AckBfsw {
73 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
74 let mut repr = String::from("<AckBfsw:");
75 repr += &(format!("\n Ack Type : {}" ,self.ack_type));
79 repr += &(format!("\n Ret Code1 : {}" ,self.ret_code1));
80 repr += &(format!("\n Ret Code2 : {}>",self.ret_code2));
81 write!(f, "{}", repr)
82 }
83}
84
85#[cfg(feature="pybindings")]
88#[pymethods]
89impl AckBfsw {
90 #[getter]
91 fn get_header(&self) -> TelemetryPacketHeader {
92 self.header.clone()
93 }
94
95 #[getter]
96 fn get_ack_type(&self) -> u8 {
97 self.ack_type
98 }
99
100 #[getter]
101 fn get_ret_code1(&self) -> u8 {
102 self.ret_code1
103 }
104
105 #[getter]
106 fn get_ret_code2(&self) -> u8 {
107 self.ret_code2
108 }
109
110 #[getter]
111 fn get_body(&self) -> Vec<u8> {
112 self.body.clone()
113 }
114}
115
116#[cfg(feature="pybindings")]
117pythonize!(AckBfsw);
118