From ec9abc7b0293de643ba8ec13d26655be3645dd47 Mon Sep 17 00:00:00 2001 From: Suren Gabrielyan Date: Thu, 17 Nov 2022 20:13:09 +0400 Subject: [PATCH] Examples: update README of socket examples --- examples/protocols/sockets/README.md | 28 +++++++++++-------- .../protocols/sockets/tcp_client/README.md | 16 +---------- .../protocols/sockets/tcp_server/README.md | 12 +------- .../protocols/sockets/udp_client/README.md | 12 +------- .../protocols/sockets/udp_server/README.md | 12 +------- 5 files changed, 21 insertions(+), 59 deletions(-) diff --git a/examples/protocols/sockets/README.md b/examples/protocols/sockets/README.md index 3dc8c7802a..871f909a30 100644 --- a/examples/protocols/sockets/README.md +++ b/examples/protocols/sockets/README.md @@ -30,7 +30,23 @@ There are many host-side tools which can be used to interact with the UDP/TCP se One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets. Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands. -In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples. +In addition to those tools, Python scripts named `pytest_xxx.py` can be found under each example directory. + + +### Python scripts + +Script named `pytest_xxxx` in the application directory can be used for automated tests. +They can also be run locally. Ref: [ESP-IDF Tests with Pytest Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/contribute/esp-idf-tests-with-pytest.html). + +Example: +```bash +$ cd $IDF_PATH +$ bash install.sh --enable-pytest +$ . ./export.sh +$ cd examples/protocols/sockets/tcp_client +$ python $IDF_PATH/tools/ci/ci_build_apps.py . --target esp32 -vv --pytest-apps +$ pytest --target esp32 +``` ### Send UDP packet via netcat ``` @@ -62,16 +78,6 @@ nc 192.168.0.167 3333 nc -l 192.168.0.167 -p 3333 ``` -### Python scripts -Each script in the application directory could be used to exercise the socket communication. -Command line arguments such as IP version (IPv4 or IPv6) and IP address and payload data (only clients) shall be supplied. -In addition to that, port number and interface id are hardcoded in the scripts and might need to be altered to match the values used by the application. Example: - -``` -PORT = 3333 -INTERFACE = 'en0' -``` - ### Note about IPv6 addresses Examples are configured to obtain multiple IPv6 addresses. The actual behavior may differ depending on the local network, typically the ESP gets assigned these two addresses diff --git a/examples/protocols/sockets/tcp_client/README.md b/examples/protocols/sockets/tcp_client/README.md index 0d90afe16c..3e4b571f40 100644 --- a/examples/protocols/sockets/tcp_client/README.md +++ b/examples/protocols/sockets/tcp_client/README.md @@ -41,27 +41,13 @@ In order to create TCP server that communicates with TCP Client example, choose There are many host-side tools which can be used to interact with the UDP/TCP server/client. One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets. -In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples. +Ref to the [upper level README](../README.md#host-tools) for more information. ### TCP server using netcat ``` nc -l 192.168.0.167 3333 ``` -### Python scripts -Script example_test.py could be used as a counter part to the tcp-client project, ip protocol name (IPv4 or IPv6) shall be stated as argument. - -Note that this script is used in automated tests, as well, so the IDF test framework packages need to be imported. -Please run the following commands to configure the terminal to execute the script. -``` -export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci/python_packages" -python -m pip install -r $IDF_PATH/tools/ci/python_packages/ttfw_idf/requirements.txt -``` - -Example: -``` -python example_test.py IPv4 -``` ## Hardware Required This example can be run on any commonly available ESP32 development board. diff --git a/examples/protocols/sockets/tcp_server/README.md b/examples/protocols/sockets/tcp_server/README.md index afeefaf140..8b0312320b 100644 --- a/examples/protocols/sockets/tcp_server/README.md +++ b/examples/protocols/sockets/tcp_server/README.md @@ -16,23 +16,13 @@ There are many host-side tools which can be used to interact with the UDP/TCP se One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets. Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following command. -In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples. +Ref to the [upper level README](../README.md#host-tools) for more information. ### TCP client using netcat ``` nc 192.168.0.167 3333 ``` -### Python scripts -Script example_test.py could be used as a counter part to the tcp-server application, -IP address and the message to be send to the server shall be stated as arguments. Example: - -``` -python example_test.py 192.168.0.167 Message -``` -Note that this script is used in automated tests, as well, so the IDF test framework packages need to be imported; -please add `$IDF_PATH/tools/ci/python_packages` to `PYTHONPATH`. - ## Hardware Required This example can be run on any commonly available ESP32 development board. diff --git a/examples/protocols/sockets/udp_client/README.md b/examples/protocols/sockets/udp_client/README.md index 90f0a110d6..87a6eb1a7e 100644 --- a/examples/protocols/sockets/udp_client/README.md +++ b/examples/protocols/sockets/udp_client/README.md @@ -16,7 +16,7 @@ There are many host-side tools which can be used to interact with the UDP/TCP se One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets. Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands. -In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples. +Ref to the [upper level README](../README.md#host-tools) for more information. ### Send UDP packet via netcat ``` @@ -33,16 +33,6 @@ echo "Hello from PC" | nc -w1 -u 192.168.0.167 3333 nc -u -l 192.168.0.167 3333 ``` -### Python scripts -Script example_test.py could be used as a counter part to the udp-client application, ip protocol name (IPv4 or IPv6) shall be stated as argument. Example: - -``` -python example_test.py IPv4 -``` -Note that this script is used in automated tests, as well, so the IDF test framework packages need to be imported; -please add `$IDF_PATH/tools/ci/python_packages` to `PYTHONPATH`. - - ## Hardware Required This example can be run on any commonly available ESP32 development board. diff --git a/examples/protocols/sockets/udp_server/README.md b/examples/protocols/sockets/udp_server/README.md index 03c96b884b..5a868c6f32 100644 --- a/examples/protocols/sockets/udp_server/README.md +++ b/examples/protocols/sockets/udp_server/README.md @@ -17,7 +17,7 @@ One command line tool is [netcat](http://netcat.sourceforge.net) which can send Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands. If want to use this RECVINFO function, please enable LWIP_NETBUF_RECVINFO in menuconfig,this function can only resolve the destination address of IPV4. -In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples. +Ref to the [upper level README](../README.md#host-tools) for more information. ### Send UDP packet via netcat ``` @@ -34,16 +34,6 @@ echo "Hello from PC" | nc -w1 -u 192.168.0.167 3333 nc -u 192.168.0.167 3333 ``` -### Python scripts -Script example_test.py could be used as a counter part to the udp-server application, -IP address and the message to be send to the server shall be stated as arguments. Example: - -``` -python example_test.py 192.168.0.167 Message -``` -Note that this script is used in automated tests, as well, so the IDF test framework packages need to be imported; -please add `$IDF_PATH/tools/ci/python_packages` to `PYTHONPATH`. - ## Hardware Required This example can be run on any commonly available ESP32 development board.