[−][src]Enum w5500_ll::SocketCommand
Socket commands.
This is used to set the command for socket n.
After W5500 accepts the command, the crate::Registers::set_sn_cr
register is automatically cleared to 0x00.
Even though crate::Registers::set_sn_cr
is cleared to 0x00, the command
is still being processed.
To check whether the command is completed or not, check
crate::Registers::sn_ir
or crate::Registers::sn_sr
.
Variants
The command register clears to this state once a command has been accepted.
The socket is initialized and opened according to the protocol
selected in crate::Registers::sn_mr
.
crate::Registers::sn_mr | crate::Registers::sn_sr |
---|---|
Protocol::Closed | - |
Protocol::Tcp | SocketStatus::Init |
Protocol::Udp | SocketStatus::Udp |
Protocol::Macraw | SocketStatus::Macraw |
Operate the socket as a TCP server.
This will change the socket state from SocketStatus::Init
to
SocketStatus::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 SocketStatus::Listen
to
SocketStatus::Established
and the CON
socket interrupt is raised
(crate::SocketInterrupt::con_raised
).
When a TCP client connection request fails the TIMEOUT
socket
interrupt is set (crate::SocketInterrupt::timeout_raised
) and the
socket status changes to SocketStatus::Closed
.
Only valid in Protocol::Tcp
mode.
Connect to a TCP server.
A connect-request (SYN packet) is sent to the TCP server configured by
crate::Registers::sn_dipr
and crate::Registers::sn_dport
(destination IPv4 address and port).
If the connect-request is successful, the socket state changes to
SocketStatus::Established
and the CON
socket interrupt is raised
(crate::SocketInterrupt::con_raised
).
The connect-request fails in the following three cases:
- When a ARPTO occurs
(
crate::SocketInterrupt::con_raised
) because the destination hardware address is not acquired through the ARP-process. - When a SYN/ACK packet is not received within the TCP timeout duration
set by
crate::Registers::rcr
andcrate::Registers::rtr
(crate::SocketInterrupt::timeout_raised
). - When a RST packet is received instead of a SYN/ACK packet.
In these cases the socket state changes to SocketStatus::Closed
.
Only valid in Protocol::Tcp
mode when acting as a TCP client.
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 SocketStatus::Closed
.
Otherwise, TCP timeout occurs
(crate::SocketInterrupt::timeout_raised
) and then
the socket state changes to SocketStatus::Closed
.
If SocketCommand::Close
is used instead of
SocketCommand::Disconnect
, the socket state is changes to
SocketStatus::Closed
without the disconnect process.
If a RST packet is received from a peer during communication the socket
status is unconditionally changed to SocketStatus::Closed
.
Only valid in Protocol::Tcp
mode.
Close the socket.
The socket status is changed to SocketStatus::Closed
.
Transmits all the data in the socket TX buffer.
The basic operation is same as SocketCommand::Send
.
Normally SocketCommand::Send
transmits data after destination
hardware address is acquired by the automatic ARP-process
(Address Resolution Protocol).
SocketCommand::SendMac
transmits data without the automatic
ARP-process.
In this case, the destination hardware address is acquired from
crate::Registers::sn_dhar
configured by the host, instead of the ARP
process.
Only valid in Protocol::Udp
mode.
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 (crate::SocketInterrupt::timeout_raised
).
Only valid in Protocol::Tcp
mode.
RECV completes the processing of the received data in socket RX buffer.
See crate::Registers::sn_rx_buf
for an example.
Trait Implementations
impl Clone for SocketCommand
[src]
pub fn clone(&self) -> SocketCommand
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for SocketCommand
[src]
impl Debug for SocketCommand
[src]
impl Eq for SocketCommand
[src]
impl Hash for SocketCommand
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for SocketCommand
[src]
pub fn cmp(&self, other: &SocketCommand) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<SocketCommand> for SocketCommand
[src]
pub fn eq(&self, other: &SocketCommand) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<SocketCommand> for SocketCommand
[src]
pub fn partial_cmp(&self, other: &SocketCommand) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for SocketCommand
[src]
impl StructuralPartialEq for SocketCommand
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,