Struct rpi_mailbox::Mailbox
source · pub struct Mailbox(_);
Implementations§
source§impl Mailbox
impl Mailbox
sourcepub fn new<P>(device: &P) -> Result<Self, Error>where
P: ?Sized + NixPath,
pub fn new<P>(device: &P) -> Result<Self, Error>where P: ?Sized + NixPath,
open device
device: path to mailbox device. e.g. /dev/vcio
Examples found in repository?
examples/memflag.rs (line 32)
29 30 31 32 33 34 35 36 37 38 39 40 41 42
fn main() {
use memflag::Flags;
let mb = Mailbox::new("/dev/vcio").expect("mailbox");
print!("NORMAL: ");
print_addr(&mb, Flags::MEM_FLAG_NORMAL).expect("MEM_FLAG_NORMAL");
print!("DIRECT: ");
print_addr(&mb, Flags::MEM_FLAG_DIRECT).expect("MEM_FLAG_DIRECT");
print!("COHERENT: ");
print_addr(&mb, Flags::MEM_FLAG_COHERENT).expect("MEM_FLAG_COHERENT");
print!("L1_NONALLOCATING: ");
print_addr(&mb, Flags::MEM_FLAG_L1_NONALLOCATING).expect("MEM_FLAG_L1_NONALLOCATING");
}
More examples
examples/info.rs (line 9)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
let mb = Mailbox::new("/dev/vcio").expect("mailbox");
let rev = firmware_revision(&mb).expect("firmware_revision");
let date = DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp_opt(rev as i64, 0).unwrap(),
Utc,
);
println!("Firmware revision: {}", date.format("%b %e %Y %T"));
let model = get_board_model(&mb).expect("board_model");
println!("Board model: 0x{:08x}", model);
let rev = get_board_revision(&mb).expect("board_revision");
println!("Board revision: 0x{:08x}", rev);
let mac = get_board_mac_address(&mb).expect("board_mac_address");
println!("Board MAC address: {:012x}", mac);
let serial = get_board_serial(&mb).expect("board_serial");
println!("Board serial: 0x{:x}", serial);
let (base, size) = get_arm_memory(&mb).expect("arm_memory");
println!("ARM memory: 0x{:08x} bytes at 0x{:08x}", size, base);
let (base, size) = get_vc_memory(&mb).expect("vc_memory");
println!("VC memory: 0x{:08x} bytes at 0x{:08x}", size, base);
let throttled = get_throttled(&mb).expect("throttled");
println!("Throttled: 0x{:x}", throttled);
}
Trait Implementations§
source§impl FromRawFd for Mailbox
impl FromRawFd for Mailbox
source§unsafe fn from_raw_fd(fd: RawFd) -> Self
unsafe fn from_raw_fd(fd: RawFd) -> Self
Constructs a new instance of
Self
from the given raw file
descriptor. Read moresource§impl IntoRawFd for Mailbox
impl IntoRawFd for Mailbox
source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
Consumes this object, returning the raw underlying file descriptor. Read more
source§impl Ord for Mailbox
impl Ord for Mailbox
source§impl PartialEq<Mailbox> for Mailbox
impl PartialEq<Mailbox> for Mailbox
source§impl PartialOrd<Mailbox> for Mailbox
impl PartialOrd<Mailbox> for Mailbox
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Mailbox
impl StructuralEq for Mailbox
impl StructuralPartialEq for Mailbox
Auto Trait Implementations§
impl RefUnwindSafe for Mailbox
impl Send for Mailbox
impl Sync for Mailbox
impl Unpin for Mailbox
impl UnwindSafe for Mailbox
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more