Compare commits
1 Commits
58a913bcc1
...
602b8915e4
Author | SHA1 | Date | |
---|---|---|---|
602b8915e4 |
@@ -7,7 +7,20 @@
|
||||
//! Alternatively, you can also set a static IPv4 configuration via the `STATIC_IPV4_CONFIG`
|
||||
//! constant and by setting `USE_DHCP` to `false`.
|
||||
//!
|
||||
//! It also exposes simple UDP and TCP echo servers.
|
||||
//! It also exposes simple UDP and TCP echo servers. You can use the following sample commands
|
||||
//! to send UDP or TCP data to the Zedboard using the Unix `netcat` application:
|
||||
//!
|
||||
//! ## UDP
|
||||
//!
|
||||
//! ```sh
|
||||
//! echo "Hello Zedboard" | nc -uN <ip-address> 8000
|
||||
//! ```
|
||||
//!
|
||||
//! ## TCP
|
||||
//!
|
||||
//! ```sh
|
||||
//! echo "Hello Zedboard" | nc -N <ip-address> 8000
|
||||
//! ```
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
@@ -118,7 +131,7 @@ async fn udp_task(mut udp: UdpSocket<'static>) -> ! {
|
||||
loop {
|
||||
match udp.recv_from(&mut rx_buf).await {
|
||||
Ok((data, meta)) => {
|
||||
log::info!("UDP: rx {data} bytes from {meta:?}");
|
||||
log::info!("udp rx {data} bytes from {meta:?}");
|
||||
match udp.send_to(&rx_buf[0..data], meta).await {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
@@ -152,6 +165,7 @@ async fn tcp_task(mut tcp: TcpSocket<'static>) -> ! {
|
||||
tcp.close();
|
||||
}
|
||||
Ok(read_bytes) => {
|
||||
log::info!("tcp rx {read_bytes} bytes");
|
||||
if tcp.may_send() {
|
||||
match tcp.write_all(&rx_buf[0..read_bytes]).await {
|
||||
Ok(_) => continue,
|
||||
|
Reference in New Issue
Block a user