Skip to content

Instantly share code, notes, and snippets.

@andresv
Created November 10, 2021 08:35
Show Gist options
  • Save andresv/9392fd5def2d3402c3c63e40a0433575 to your computer and use it in GitHub Desktop.
Save andresv/9392fd5def2d3402c3c63e40a0433575 to your computer and use it in GitHub Desktop.
atat ingress_manager
fn cpin_partial_response() {
static mut RES_Q: BBBuffer<TEST_RES_CAPACITY> = BBBuffer::new();
let (res_p, mut res_c) = unsafe { RES_Q.try_split_framed().unwrap() };
static mut URC_Q: BBBuffer<TEST_URC_CAPACITY> = BBBuffer::new();
let (urc_p, _urc_c) = unsafe { URC_Q.try_split_framed().unwrap() };
static mut COM_Q: queues::ComQueue = Queue::new();
let (_com_p, com_c) = unsafe { COM_Q.split() };
let mut ingress = IngressManager::<
_,
_,
TEST_RX_BUF_LEN,
TEST_RES_CAPACITY,
TEST_URC_CAPACITY,
>::with_customs(
res_p,
urc_p,
com_c,
DefaultUrcMatcher::default(),
DefaultDigester::default(),
);
// send digest response in 2 chunks
ingress.write(b"A");
ingress.digest();
ingress.write(b"T+CPIN?\r\n");
ingress.digest();
ingress.write(b"\r\n+CPIN: READY\r\n\r\nOK\r\n");
ingress.digest();
let mut grant = res_c.read().unwrap();
grant.auto_release(true);
match ResponseHeader::from_bytes(grant.as_ref()) {
Ok(data) => assert_eq!(data, b"+CPIN: READY"),
Err(_) => assert!(false)
}
assert_eq!(0, ingress.len());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment