sans_io_core/
sans_io_core.rs1use std::time::Duration;
11
12use dvb_ci_runtime::dvb_ci::tpdu::tags;
13use dvb_ci_runtime::{Action, CiStack, Event, HostRequest};
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 main() {
27 let mut stack = CiStack::new();
28
29 show("Init", &stack.handle(Event::Host(HostRequest::Init)));
31
32 let reply = [tags::C_T_C_REPLY, 0x01, 0x01];
34 show(
35 "Readable(C_T_C_Reply)",
36 &stack.handle(Event::Readable(&reply)),
37 );
38
39 show(
42 "Tick(100ms)",
43 &stack.handle(Event::Tick {
44 elapsed: Duration::from_millis(100),
45 }),
46 );
47}