fn udp_send(&mut self, sn: Sn, buf: &[u8]) -> Result<u16, Self::Error> {
        debug_assert_eq!(self.sn_sr(sn)?, Ok(SocketStatus::Udp));

        let data_len: u16 = u16::try_from(buf.len()).unwrap_or(u16::MAX);
        let free_size: u16 = self.sn_tx_fsr(sn)?;
        let tx_bytes: u16 = min(data_len, free_size);
        if tx_bytes != 0 {
            let ptr: u16 = self.sn_tx_wr(sn)?;
            self.set_sn_tx_buf(sn, ptr, &buf[..tx_bytes.into()])?;
            self.set_sn_tx_wr(sn, ptr.wrapping_add(tx_bytes))?;
            self.set_sn_cr(sn, SocketCommand::Send)?;
        }
        Ok(tx_bytes)
    }
/// Sends data to the currently configured destination.
/// On success, returns the number of bytes written.
///
/// The destination is set by the last call to [`Registers::set_sn_dest`],
/// [`Udp::udp_send_to`], or [`UdpWriter::udp_send_to`].
///
/// # Panics
///
/// * (debug) The socket must be opened as a UDP socket.
///
/// # Example
///
/// ```no_run
/// # use embedded_hal_mock as h;
/// # let mut w5500 = w5500_ll::blocking::vdm::W5500::new(h::spi::Mock::new(&[]), h::pin::Mock::new(&[]));
/// use w5500_hl::{
///     ll::{Registers, Sn::Sn0},
///     net::{Ipv4Addr, SocketAddrV4},
///     Udp,
/// };
///
/// const DEST: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(192, 0, 2, 1), 8081);
///
/// w5500.udp_bind(Sn0, 8080)?;
/// let buf: [u8; 10] = [0; 10];
/// let tx_bytes: u16 = w5500.udp_send_to(Sn0, &buf, &DEST)?;
/// assert_eq!(usize::from(tx_bytes), buf.len());
/// // send the same to the same destination
/// let tx_bytes: u16 = w5500.udp_send(Sn0, &buf)?;
/// assert_eq!(usize::from(tx_bytes), buf.len());
/// # Ok::<(), w5500_hl::ll::blocking::vdm::Error<_, _>>(())
/// ```
///
/// [`UdpWriter::udp_send_to`]: crate::UdpWriter::udp_send_to
Sends data to the currently configured destination.
On success, returns the number of bytes written.


Sends data to the currently configured destination . On success returns the number of bytes written .
fn udp_send(&mut self, sn: Sn, buf: &[u8]) -> Result<u16, Self::Error> {
        debug_assert_eq!(self.sn_sr(sn)?, Ok(SocketStatus::Udp));
        let data_len: u16 = u16::try_from(buf.len()).unwrap_or(u16::MAX);
        let free_size: u16 = self.sn_tx_fsr(sn)?;
        let tx_bytes: u16 = min(data_len, free_size);
        if tx_bytes != 0 {
            let ptr: u16 = self.sn_tx_wr(sn)?;
            self.set_sn_tx_buf(sn, ptr, &buf[..tx_bytes.into()])?;
            self.set_sn_tx_wr(sn, ptr.wrapping_add(tx_bytes))?;
            self.set_sn_cr(sn, SocketCommand::Send)?;
        }
        Ok(tx_bytes)
    }
fn udp_send ( & mut self , sn : Sn , buf : & [ u8 ] ) -> Result < u16 , Self :: Error > { debug_assert_eq ! ( self sn_sr ( sn ) Ok ( SocketStatus Udp ) ) ; let data_len : u16 = u16 :: try_from ( buf . len ( ) ) . unwrap_or ( u16 :: MAX ) ; let free_size : u16 = self . sn_tx_fsr ( sn ) ? ; let tx_bytes : u16 = min ( data_len , free_size ) ; if tx_bytes != 0 { let ptr : u16 = self . sn_tx_wr ( sn ) ? ; self . set_sn_tx_buf ( sn , ptr , & buf [ .. tx_bytes . into ( ) ] ) ? ; self . set_sn_tx_wr ( sn , ptr . wrapping_add ( tx_bytes ) ) ? ; self . set_sn_cr ( sn , SocketCommand :: Send ) ? ; } Ok ( tx_bytes ) }
Sends data to the currently configured destination.
Sends data to the currently configured destination .
&mut self
sn
Sn
buf
&[u8]
&mut self
sn
Sn
buf
&[u8]
panics
(debug) The socket must be opened as a UDP socket.
( debug ) The socket must be opened as a UDP socket .
example
None
use embedded_hal_mock as h;
None
let mut w5500 = w5500_ll::blocking::vdm::w5500::new(h::spi::mock::new(&[]), h::pin::mock::new(&[]));
None
ok::<(), w5500_hl::ll::blocking::vdm::error<_, _>>(())
None