mod shm; use shared_mem_queue::byte_queue::ByteQueue; use shm::ShmHandle; use libc::O_RDWR; const SHM_CW_RR: &str = "shm_byte_queue"; const SHM_CW_RR_SIZE: usize = 128; fn main() -> Result<(), Box> { let mut shm_handle = ShmHandle::new(SHM_CW_RR, SHM_CW_RR_SIZE, O_RDWR, 0)?; let mut reader = unsafe { ByteQueue::attach(shm_handle.as_mut_ptr_u8(), SHM_CW_RR_SIZE) }; let mut rx = [0u8; 256]; loop { let len = reader.consume_at_most(&mut rx); if len != 0 { println!("shm data: {:?}", &rx[..len]); std::thread::sleep(std::time::Duration::from_secs(1)); } } }