MCPcopy Create free account
hub / github.com/FutureSDR/FutureSDR / work

Method work

examples/wlan/src/decoder.rs:133–225  ·  view source on GitHub ↗
(
        &mut self,
        io: &mut WorkIo,
        mo: &mut MessageOutputs,
        _b: &mut BlockMeta,
    )

Source from the content-addressed store, hash-verified

131 I: CpuBufferReader<Item = u8>,
132{
133 async fn work(
134 &mut self,
135 io: &mut WorkIo,
136 mo: &mut MessageOutputs,
137 _b: &BlockMeta,
138 ) -> Result<()> {
139 let (mut input, in_tags) = self.input.slice_with_tags();
140 let mut next_tag_index = None;
141
142 if let Some((index, any)) = in_tags.iter().find_map(|x| match x {
143 ItemTag {
144 index,
145 tag: Tag::NamedAny(n, any),
146 } => {
147 if n == "wifi_start" {
148 Some((index, any))
149 } else {
150 None
151 }
152 }
153 _ => None,
154 }) {
155 if *index == 0 {
156 // if !self.frame_complete {
157 // warn!("decoder: previous frame not complete, canceling.");
158 // }
159 let frame_param = any.downcast_ref::<FrameParam>().unwrap();
160 if frame_param.n_symbols() <= MAX_SYM && frame_param.psdu_size() <= MAX_PSDU_SIZE {
161 self.frame_param = frame_param.clone();
162 self.copied = 0;
163 self.frame_complete = false;
164 } else {
165 // warn!("decoder: frame too large, dropping. ({:?})", frame_param);
166 }
167 } else {
168 input = &input[0..*index];
169 next_tag_index = Some(*index);
170 }
171 }
172
173 // println!("decoder: input len {}, complete {}, copied {}, frame {:?}, tags {:?}", input.len(), self.frame_complete, self.copied, self.frame_param, tags);
174
175 let max_i = input.len() / 48;
176 let mut i = 0;
177 let mut broke_early = false;
178
179 // println!("decoder input: {:?}", &input[0..max_i * 48]);
180
181 while i < max_i {
182 if self.copied < self.frame_param.n_symbols() {
183 // println!("copying {} of {}", self.copied, self.frame_param.n_symbols());
184 self.rx_symbols[(self.copied * 48)..((self.copied + 1) * 48)]
185 .copy_from_slice(&input[(i * 48)..((i + 1) * 48)]);
186 }
187
188 i += 1;
189 self.copied += 1;
190

Callers

nothing calls this directly

Calls 9

n_symbolsMethod · 0.80
psdu_sizeMethod · 0.80
lenMethod · 0.80
slice_with_tagsMethod · 0.45
cloneMethod · 0.45
decodeMethod · 0.45
postMethod · 0.45
consumeMethod · 0.45
finishedMethod · 0.45

Tested by

no test coverage detected