mock_cam_session/
mock_cam_session.rs1use std::time::Duration;
11
12use dvb_ci::tpdu::tags;
13use dvb_ci_runtime::{
14 Driver, DriverBounds, MockCaDevice, Notification, StackBounds, TransportBounds,
15};
16
17fn driver_bounds() -> DriverBounds {
18 DriverBounds {
19 stack: stack_bounds(),
20 max_pending_notifications: 1024,
21 slot_ready_grace: Duration::from_secs(12),
22 slot_retry: Duration::from_millis(250),
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() -> std::io::Result<()> {
40 let dev = MockCaDevice::new([vec![tags::C_T_C_REPLY, 0x01, 0x01]]);
42 let mut driver = Driver::new(dev, driver_bounds());
43
44 driver.init()?;
46 println!("init: sent {} device op(s)", driver.device().ops.len());
47
48 for step in 0..5 {
51 let read = driver.pump(Duration::from_millis(100))?;
52 println!("pump {step}: processed_frame={read}");
53 }
54
55 for note in driver.take_notifications() {
57 match note {
58 Notification::CamReady => println!("note: CAM ready — safe to send ca_pmt"),
59 Notification::ApplicationInfo { menu, .. } => {
60 println!("note: application_information menu={menu:?}")
61 }
62 Notification::CaInfo { ca_system_ids } => {
63 println!("note: ca_info system_ids={ca_system_ids:?}")
64 }
65 other => println!("note: {other:?}"),
66 }
67 }
68
69 println!("total recorded device ops: {}", driver.device().ops.len());
71 Ok(())
72}