pub struct MctpI2cHandler { /* private fields */ }
Expand description
A handler for I2C MCTP
One instance should exist for each I2C bus with a MCTP transport.
Implementations§
Source§impl MctpI2cHandler
impl MctpI2cHandler
Sourcepub fn new(
own_addr: u8,
send_message: &'static mut Vec<u8, MAX_PAYLOAD>,
) -> Self
pub fn new( own_addr: u8, send_message: &'static mut Vec<u8, MAX_PAYLOAD>, ) -> Self
Constructs a new MctpI2cHandler
.
Note that the heapless::Vec
for fill_msg
is the version
specified by mctp-estack
crate. The re-export
mctp_estack::Vec
can be used for API compatibility.
Sourcepub fn receive<'f>(
&mut self,
packet: &[u8],
mctp: &'f mut Stack,
) -> Result<Option<(MctpMessage<'f>, u8, ReceiveHandle)>>
pub fn receive<'f>( &mut self, packet: &[u8], mctp: &'f mut Stack, ) -> Result<Option<(MctpMessage<'f>, u8, ReceiveHandle)>>
Handles receiving an I2C target write
Expects to be passed a packet
starting from the MCTP I2C header
(first byte is destination address).
buf
should have the PEC byte removed, already checked by callers.
TODO: provide separate software PEC check function?
Sourcepub fn is_send_ready(&self) -> bool
pub fn is_send_ready(&self) -> bool
Indicates whether data is pending to send
Sourcepub fn is_send_idle(&self) -> bool
pub fn is_send_idle(&self) -> bool
Indicates whether the send queue is idle, ready for an application to enqueue a new message
Sourcepub fn send_fill<'f>(&mut self, buf: &'f mut [u8]) -> SendOutput<'f>
pub fn send_fill<'f>(&mut self, buf: &'f mut [u8]) -> SendOutput<'f>
Fill a buffer with a packet to send over the i2c bus.
The send_complete
closure is called when an entire message completes sending.
It is called with Some(Tag)
on success (with the tag that was sent)
or None
on failure. The cookie is the one provided to send_enqueue
.
pub fn cancel_send(&mut self) -> Option<AppCookie>
Sourcepub fn send_enqueue<F>(
&mut self,
eid: Eid,
typ: MsgType,
tag: Option<Tag>,
ic: MsgIC,
i2c_dest: u8,
cookie: Option<AppCookie>,
mctp: &mut Stack,
fill_msg: F,
) -> Result<()>
pub fn send_enqueue<F>( &mut self, eid: Eid, typ: MsgType, tag: Option<Tag>, ic: MsgIC, i2c_dest: u8, cookie: Option<AppCookie>, mctp: &mut Stack, fill_msg: F, ) -> Result<()>
Provides a MCTP message to send.
The provided closure will fill out the message buffer, returning
Some(())
on success. If the closure fails it returns None
, and
send_enqueue()
will return mctp::Error::InvalidInput
.
send_enqueue()
must only be called when is_send_idle()
is true.
TODO fill_msg
will take something that isn’t a Vec.
Note that the heapless::Vec
for fill_msg
is the version
specified by mctp-estack
crate. The re-export
mctp_estack::Vec
can be used for API compatibility.