sans_io_core/
sans_io_core.rs1use std::time::Duration;
11
12use dvb_ci::tpdu::tags;
13use dvb_ci_runtime::{Action, CiStack, Event, HostRequest, StackBounds, TransportBounds};
14
15fn show(label: &str, actions: &[Action]) {
16 println!("{label} -> {} action(s)", actions.len());
17 for a in actions {
18 match a {
19 Action::Write(w) => println!(" Write {:02X?}", &w[..w.len().min(8)]),
20 Action::SetTimer { after } => println!(" SetTimer after={after:?}"),
21 other => println!(" {other:?}"),
22 }
23 }
24}
25
26fn stack_bounds() -> StackBounds {
27 StackBounds {
28 transport: TransportBounds {
29 poll_interval: Duration::from_millis(100),
30 reply_timeout: Duration::from_secs(1),
31 max_setup_attempts: 5,
32 max_reassembly_len: 2 * 1024 * 1024,
33 max_outbound_queue: 64,
34 },
35 max_sessions: 32,
36 }
37}
38
39fn main() {
40 let mut stack = CiStack::new(stack_bounds());
41
42 show("Init", &stack.handle(Event::Host(HostRequest::Init)));
44
45 let reply = [tags::C_T_C_REPLY, 0x01, 0x01];
47 show(
48 "Readable(C_T_C_Reply)",
49 &stack.handle(Event::Readable(&reply)),
50 );
51
52 show(
55 "Tick(100ms)",
56 &stack.handle(Event::Tick {
57 elapsed: Duration::from_millis(100),
58 }),
59 );
60}