#[repr(u8)]
pub enum SocketCommand { Accepted = 0, Open = 1, Listen = 2, Connect = 4, Disconnect = 8, Close = 16, Send = 32, SendMac = 33, SendKeep = 34, Recv = 64, }
Expand description

Socket commands.

This is used to set the command for socket n.

After W5500 accepts the command, the sn_cr register is automatically cleared to 0x00. Even though sn_cr is cleared to 0x00, the command is still being processed. To check whether the command is completed or not, check sn_ir or sn_sr.

Variants§

§

Accepted = 0

The command register clears to this state once a command has been accepted.

§

Open = 1

§

Listen = 2

Operate the socket as a TCP server.

This will change the socket state from Init to Listen, and the socket will listen for a connection-request (SYN packet) from any TCP client.

When a TCP client connection request is successfully established, the socket state changes from Listen to Established and the CON socket interrupt is raised.

When a TCP client connection request fails the TIMEOUT socket interrupt is set and the socket status changes to Closed.

Only valid in Tcp mode.

§

Connect = 4

Connect to a TCP server.

A connect-request (SYN packet) is sent to the TCP server configured by the IPv4 address and port set with set_sn_dest.

If the connect-request is successful, the socket state changes to Established and the CON socket interrupt is raised.

The connect-request fails in the following three cases:

  1. When a ARPTO occurs (timeout_raised) because the destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received within the TCP timeout duration set by rcr and rtr (timeout_raised).
  3. When a RST packet is received instead of a SYN/ACK packet.

In these cases the socket state changes to Closed.

Only valid in Tcp mode when acting as a TCP client.

§

Disconnect = 8

Start the disconnect process.

  • Active close it transmits disconnect-request(FIN packet) to the connected peer.
  • Passive close when FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), the socket state changes to Closed. Otherwise, TCP timeout occurs (timeout_raised) and then the socket state changes to Closed.

If the Close command is used instead of Disconnect, the socket state is changes to Closed without the disconnect process.

If a RST packet is received from a peer during communication the socket status is unconditionally changed to Closed.

Only valid in Tcp mode.

§

Close = 16

Close the socket.

The socket status is changed to Closed.

§

Send = 32

Transmits all the data in the socket TX buffer.

§

SendMac = 33

The basic operation is same as Send.

Normally Send transmits data after destination hardware address is acquired by the automatic ARP-process (Address Resolution Protocol). SendMac transmits data without the automatic ARP-process. In this case, the destination hardware address is acquired from sn_dhar configured by the host, instead of the ARP process.

Only valid in Udp mode.

§

SendKeep = 34

Sends a 1 byte keep-alive packet.

If the peer cannot respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur (timeout_raised).

Only valid in Tcp mode.

§

Recv = 64

Completes the processing of the received data in socket RX buffer.

See sn_rx_buf for an example.

Trait Implementations§

source§

impl Clone for SocketCommand

source§

fn clone(&self) -> SocketCommand

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SocketCommand

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Format for SocketCommand

source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
source§

impl From<SocketCommand> for u8

source§

fn from(val: SocketCommand) -> u8

Converts to this type from the input type.
source§

impl Hash for SocketCommand

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for SocketCommand

source§

fn cmp(&self, other: &SocketCommand) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for SocketCommand

source§

fn eq(&self, other: &SocketCommand) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for SocketCommand

source§

fn partial_cmp(&self, other: &SocketCommand) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<u8> for SocketCommand

§

type Error = u8

The type returned in the event of a conversion error.
source§

fn try_from(val: u8) -> Result<Self, u8>

Performs the conversion.
source§

impl Copy for SocketCommand

source§

impl Eq for SocketCommand

source§

impl StructuralEq for SocketCommand

source§

impl StructuralPartialEq for SocketCommand

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.