Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
XdoctorwhoZ committed Jul 21, 2024
1 parent 2748efb commit 30b5192
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions src/app_dio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,42 @@ impl AppDio {
self.in_buf_size += data_len;
}

/// Try to decode an API request
///
fn try_to_decode_api_request(&mut self, frame: &[u8]) -> Option<PicohaDioRequest> {
match PicohaDioRequest::decode(frame) {
Ok(ppp) => {
let mut new_request = PicohaDioRequest::default();
new_request.r#type = ppp.r#type;
new_request.pin_num = ppp.pin_num;
new_request.value = ppp.value;
Some(new_request)
}
Err(e) => None,
}
}

/// Try to decode a request from the incoming data buffer
///
fn try_to_decode_request(&mut self) -> Option<PicohaDioRequest> {
fn try_to_decode_buffer(&mut self) -> Option<PicohaDioRequest> {
let mut slip_decoder = serial_line_ip::Decoder::new();

slip_decoder
.decode(&self.in_buf[..self.in_buf_size], &mut self.decode_buffer)
.map(|(input_bytes_processed, output_slice, is_end_of_packet)| {
match PicohaDioRequest::decode(output_slice) {
Ok(ppp) => {
print_debug_message!("deco {:?}", ppp.pin_num);
Some(ppp)
}
Err(e) => {
print_debug_message!("error deco {:?}", e);
None
}
}
});

// Ok((input_bytes_processed, output_slice, is_end_of_packet)) => {

None
// match {
// Ok(ppp) => {
// print_debug_message!("deco {:?}", ppp.pin_num);
// Some(ppp)
// }
// Err(e) => {
// print_debug_message!("error deco {:?}", e);
// None
// }
// }
})
.ok()
}

/// Process incoming data
Expand Down

0 comments on commit 30b5192

Please sign in to comment.