diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index 4dcfe91a1..0f31cc4a3 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -121,13 +121,13 @@ jobs: - uses: actions/upload-artifact@v2 if: ${{ failure() && env.CRASHED_TUN == '1' }} with: - name: core-expect-posix + name: core-expect-linux path: | ./ot-core-dump/* - uses: actions/upload-artifact@v2 if: ${{ failure() }} with: - name: syslog-expect-posix + name: syslog-expect-linux path: /var/log/syslog - name: Generate Coverage run: | @@ -137,7 +137,7 @@ jobs: name: cov-expects-linux-2 path: tmp/coverage.info - posix-cli: + thread-cert: runs-on: ubuntu-20.04 env: COVERAGE: 1 @@ -167,59 +167,17 @@ jobs: - uses: actions/upload-artifact@v2 if: ${{ failure() }} with: - name: posix-cli-thread-cert + name: thread-cert path: build/posix/tests/scripts/thread-cert - name: Generate Coverage run: | ./script/test generate_coverage gcc - uses: actions/upload-artifact@v2 with: - name: cov-posix-cli + name: cov-thread-cert path: tmp/coverage.info - posix-ncp: - runs-on: ubuntu-20.04 - env: - COVERAGE: 1 - NODE_TYPE: ncp-sim - PYTHONUNBUFFERED: 1 - READLINE: readline - REFERENCE_DEVICE: 1 - THREAD_VERSION: 1.1 - VIRTUAL_TIME: 1 - VIRTUAL_TIME_UART: 1 - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Bootstrap - run: | - sudo rm /etc/apt/sources.list.d/* && sudo apt-get update - sudo apt-get --no-install-recommends install -y libreadline6-dev python3-setuptools python3-wheel lcov - python3 -m pip install -r tests/scripts/thread-cert/requirements.txt - sudo python3 -m pip install git+https://github.com/openthread/pyspinel - - name: Build - run: | - ./bootstrap - make -f examples/Makefile-simulation - make -f src/posix/Makefile-posix - - name: Run - run: | - VERBOSE=1 OT_NCP_PATH="$PWD/output/posix/bin/ot-ncp" RADIO_DEVICE="$PWD/output/simulation/bin/ot-rcp" make -f src/posix/Makefile-posix check - - uses: actions/upload-artifact@v2 - if: ${{ failure() }} - with: - name: posix-ncp-thread-cert - path: build/posix/tests/scripts/thread-cert - - name: Generate Coverage - run: | - ./script/test generate_coverage gcc - - uses: actions/upload-artifact@v2 - with: - name: cov-posix-ncp - path: tmp/coverage.info - - posix-ncp-rcp-migrate: + ncp-rcp-migrate: runs-on: ubuntu-20.04 env: COVERAGE: 1 @@ -243,7 +201,7 @@ jobs: ./script/test generate_coverage gcc - uses: actions/upload-artifact@v2 with: - name: cov-posix-ncp-rcp-migrate + name: cov-ncp-rcp-migrate path: tmp/coverage.info pty-linux: @@ -309,10 +267,9 @@ jobs: upload-coverage: needs: - expects-linux - - posix-cli - - posix-ncp - - posix-ncp-rcp-migrate + - ncp-rcp-migrate - pty-linux + - thread-cert runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/toranj.yml b/.github/workflows/toranj.yml index 4536cd0e8..f5124ee35 100644 --- a/.github/workflows/toranj.yml +++ b/.github/workflows/toranj.yml @@ -40,11 +40,15 @@ jobs: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" if: "github.ref != 'refs/heads/main'" - toranj-ncp: + toranj: + name: toranj-${{ matrix.TORANJ_RADIO }} runs-on: ubuntu-18.04 + strategy: + matrix: + TORANJ_RADIO: ['15.4', 'trel', 'multi'] env: COVERAGE: 1 - TORANJ_RADIO : 15.4 + TORANJ_RADIO : ${{ matrix.TORANJ_RADIO }} steps: - uses: actions/checkout@v2 with: @@ -72,158 +76,18 @@ jobs: run: | top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh - name: Generate Coverage + if: "matrix.TORANJ_RADIO != 'multi'" run: | ./script/test generate_coverage gcc - uses: actions/upload-artifact@v2 + if: "matrix.TORANJ_RADIO != 'multi'" with: - name: cov-toranj-ncp + name: cov-toranj-${{ matrix.TORANJ_RADIO }} path: tmp/coverage.info - toranj-rcp: - runs-on: ubuntu-18.04 - env: - COVERAGE: 1 - TORANJ_POSIX_RCP_MODEL: 1 - TORANJ_RADIO : 15.4 - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Bootstrap - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - run: | - sudo rm /etc/apt/sources.list.d/* && sudo apt-get update - sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev - sudo apt-get --no-install-recommends install -y autoconf-archive - sudo apt-get --no-install-recommends install -y bsdtar - sudo apt-get --no-install-recommends install -y libtool - sudo apt-get --no-install-recommends install -y libglib2.0-dev - sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev - sudo apt-get --no-install-recommends install -y lcov - - script/git-tool clone --depth=1 --branch=master https://github.com/openthread/wpantund.git - cd wpantund - ./bootstrap.sh - ./configure - sudo make -j2 - sudo make install - - name: Build & Run - run: | - top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh - - name: Generate Coverage - run: | - ./script/test generate_coverage gcc - - uses: actions/upload-artifact@v2 - with: - name: cov-toranj-rcp - path: tmp/coverage.info - - toranj-ncp-trel: - runs-on: ubuntu-18.04 - env: - COVERAGE: 1 - TORANJ_RADIO : trel - steps: - - uses: actions/checkout@v2 - - name: Bootstrap - run: | - sudo rm /etc/apt/sources.list.d/* && sudo apt-get update - sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev - sudo apt-get --no-install-recommends install -y autoconf-archive - sudo apt-get --no-install-recommends install -y bsdtar - sudo apt-get --no-install-recommends install -y libtool - sudo apt-get --no-install-recommends install -y libglib2.0-dev - sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev - sudo apt-get --no-install-recommends install -y lcov - - git clone --depth=1 --branch=master https://github.com/openthread/wpantund.git - cd wpantund - ./bootstrap.sh - ./configure - sudo make -j2 - sudo make install - - name: Build & Run - run: | - top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh - - name: Generate Coverage - run: | - ./script/test generate_coverage gcc - - uses: actions/upload-artifact@v2 - with: - name: cov-toranj-ncp-trel - path: tmp/coverage.info - - toranj-rcp-trel: - runs-on: ubuntu-18.04 - env: - COVERAGE: 1 - TORANJ_POSIX_RCP_MODEL: 1 - TORANJ_RADIO : trel - steps: - - uses: actions/checkout@v2 - - name: Bootstrap - run: | - sudo rm /etc/apt/sources.list.d/* && sudo apt-get update - sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev - sudo apt-get --no-install-recommends install -y autoconf-archive - sudo apt-get --no-install-recommends install -y bsdtar - sudo apt-get --no-install-recommends install -y libtool - sudo apt-get --no-install-recommends install -y libglib2.0-dev - sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev - sudo apt-get --no-install-recommends install -y lcov - - git clone --depth=1 --branch=master https://github.com/openthread/wpantund.git - cd wpantund - ./bootstrap.sh - ./configure - sudo make -j2 - sudo make install - - name: Build & Run - run: | - top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh - - name: Generate Coverage - run: | - ./script/test generate_coverage gcc - - uses: actions/upload-artifact@v2 - with: - name: cov-toranj-rcp-trel - path: tmp/coverage.info - - toranj-ncp-multi: - runs-on: ubuntu-18.04 - env: - COVERAGE: 1 - TORANJ_RADIO : multi - steps: - - uses: actions/checkout@v2 - - name: Bootstrap - run: | - sudo rm /etc/apt/sources.list.d/* && sudo apt-get update - sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev - sudo apt-get --no-install-recommends install -y autoconf-archive - sudo apt-get --no-install-recommends install -y bsdtar - sudo apt-get --no-install-recommends install -y libtool - sudo apt-get --no-install-recommends install -y libglib2.0-dev - sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev - sudo apt-get --no-install-recommends install -y lcov - - git clone --depth=1 --branch=master https://github.com/openthread/wpantund.git - cd wpantund - ./bootstrap.sh - ./configure - sudo make -j2 - sudo make install - - name: Build & Run - run: | - top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh - upload-coverage: needs: - - toranj-ncp - - toranj-rcp - - toranj-ncp-trel - - toranj-rcp-trel + - toranj runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 diff --git a/Android.mk b/Android.mk index 533db375a..f2b340b0b 100644 --- a/Android.mk +++ b/Android.mk @@ -475,7 +475,6 @@ LOCAL_C_INCLUDES := \ LOCAL_CFLAGS := \ $(OPENTHREAD_PUBLIC_CFLAGS) \ $(OPENTHREAD_PRIVATE_CFLAGS) \ - -DOPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_CLI \ $(OPENTHREAD_PROJECT_CFLAGS) \ $(NULL) diff --git a/configure.ac b/configure.ac index e0c5f02c6..b25ef424d 100644 --- a/configure.ac +++ b/configure.ac @@ -931,6 +931,8 @@ AM_CONDITIONAL(OPENTHREAD_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"]) AM_CONDITIONAL(OPENTHREAD_POSIX, [test "${with_platform}" = "posix" -o "${with_examples}" = "simulation"]) +AM_CONDITIONAL([OPENTHREAD_ENABLE_SPINEL_RCP], [test OPENTHREAD_PLATFORM_POSIX || test OPENTHREAD_ENABLE_RADIO_ONLY]) + # # Checks for libraries and packages. # diff --git a/script/check-ncp-rcp-migrate b/script/check-ncp-rcp-migrate index 878d71346..50db7b9d9 100755 --- a/script/check-ncp-rcp-migrate +++ b/script/check-ncp-rcp-migrate @@ -93,7 +93,7 @@ EOF echo "Step 2. Start retrieving dataset from Radio..." RADIO_NCP_PATH="$PWD/output/simulation/bin/ot-ncp-ftd" - "$PWD/output/posix/bin/ot-ncp" -n --radio-version "spinel+hdlc+forkpty://${RADIO_NCP_PATH}?forkpty-arg=1&ncp-dataset=1" + "$PWD/output/posix/bin/ot-cli" -n --radio-version "spinel+hdlc+forkpty://${RADIO_NCP_PATH}?forkpty-arg=1&ncp-dataset=1" echo "Step 3. Start posix app and check whether PAN dataset is the same..." RADIO_RCP_PATH="$PWD/output/simulation/bin/ot-rcp" diff --git a/script/check-simulation-build-cmake b/script/check-simulation-build-cmake index 487893009..cba7d8509 100755 --- a/script/check-simulation-build-cmake +++ b/script/check-simulation-build-cmake @@ -71,9 +71,6 @@ build_toranj() { reset_source top_builddir="$OT_BUILDDIR" ./tests/toranj/build.sh cmake - - reset_source - top_builddir="$OT_BUILDDIR" ./tests/toranj/build.sh cmake-posix } main() diff --git a/script/test b/script/test index c7ade8fc1..c2cf53cb1 100755 --- a/script/test +++ b/script/test @@ -546,14 +546,11 @@ envsetup() if [[ ${OT_NODE_TYPE} == rcp* ]]; then export RADIO_DEVICE="${OT_BUILDDIR}/openthread-simulation-${THREAD_VERSION}/examples/apps/ncp/ot-rcp" export OT_CLI_PATH="${OT_BUILDDIR}/openthread-posix-${THREAD_VERSION}/src/posix/ot-cli" - export OT_NCP_PATH="${OT_BUILDDIR}/openthread-posix-${THREAD_VERSION}/src/posix/ot-ncp" if [[ ${THREAD_VERSION} == "1.2" ]]; then export RADIO_DEVICE_1_1="${OT_BUILDDIR}/openthread-simulation-1.1/examples/apps/ncp/ot-rcp" export OT_CLI_PATH_1_1="${OT_BUILDDIR}/openthread-posix-1.1/src/posix/ot-cli" - export OT_NCP_PATH_1_1="${OT_BUILDDIR}/openthread-posix-1.1/src/posix/ot-ncp" export OT_CLI_PATH_1_2_BBR="${OT_BUILDDIR}/openthread-posix-1.2-bbr/src/posix/ot-cli" - export OT_NCP_PATH_1_2_BBR="${OT_BUILDDIR}/openthread-posix-1.2-bbr/src/posix/ot-ncp" fi fi diff --git a/src/lib/spinel/Makefile.am b/src/lib/spinel/Makefile.am index af1fa20e6..04061f603 100644 --- a/src/lib/spinel/Makefile.am +++ b/src/lib/spinel/Makefile.am @@ -38,7 +38,7 @@ if OPENTHREAD_ENABLE_MTD noinst_LIBRARIES += libopenthread-spinel-ncp.a endif -if OPENTHREAD_ENABLE_RADIO_ONLY +if OPENTHREAD_ENABLE_SPINEL_RCP noinst_LIBRARIES += libopenthread-spinel-rcp.a endif diff --git a/src/posix/CMakeLists.txt b/src/posix/CMakeLists.txt index 575271a8f..1353ce030 100644 --- a/src/posix/CMakeLists.txt +++ b/src/posix/CMakeLists.txt @@ -75,14 +75,8 @@ if(OT_DAEMON) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(CPACK_PACKAGE_NAME "openthread-daemon") endif() -else() - if(OT_APP_CLI) - include(cli.cmake) - endif() - - if(OT_APP_NCP) - include(ncp.cmake) - endif() +elseif(OT_APP_CLI) + include(cli.cmake) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(CPACK_PACKAGE_NAME "openthread-standalone") diff --git a/src/posix/Makefile-posix b/src/posix/Makefile-posix index 2f0621250..2b8430be6 100644 --- a/src/posix/Makefile-posix +++ b/src/posix/Makefile-posix @@ -84,7 +84,6 @@ COMMONCFLAGS := \ configure_OPTIONS = \ --enable-cli \ --enable-ftd \ - --enable-ncp \ --with-platform=posix \ $(NULL) diff --git a/src/posix/Makefile.am b/src/posix/Makefile.am index e20aa6c30..309983c5e 100644 --- a/src/posix/Makefile.am +++ b/src/posix/Makefile.am @@ -75,33 +75,6 @@ bin_PROGRAMS = \ $(NULL) if OPENTHREAD_ENABLE_EXECUTABLE -ot_ncp_CPPFLAGS = \ - $(CPPFLAGS_COMMON) \ - -DOPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_NCP \ - $(NULL) - -ot_ncp_SOURCES = \ - main.c \ - ncp.cpp \ - $(NULL) - -ot_ncp_LDADD = \ - $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \ - $(top_builddir)/src/core/libopenthread-ftd.a \ - $(LDADD_COMMON) \ - $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \ - $(top_builddir)/src/core/libopenthread-ftd.a \ - $(LDADD_COMMON) \ - $(NULL) - -ot_ncp_LDFLAGS = \ - $(LDFLAGS_COMMON) \ - $(NULL) - -ot_ncp_LIBTOOLFLAGS = \ - $(LIBTOOLFLAGS_COMMON) \ - $(NULL) - if OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE bin_PROGRAMS += \ ot-ctl \ @@ -113,11 +86,6 @@ bin_PROGRAMS += \ ot-cli \ $(NULL) endif -if OPENTHREAD_ENABLE_NCP -bin_PROGRAMS += \ - ot-ncp \ - $(NULL) -endif endif # OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE ot_ctl_SOURCES = \ @@ -130,7 +98,6 @@ ot_ctl_CPPFLAGS = \ ot_daemon_CPPFLAGS = \ $(CPPFLAGS_COMMON) \ - -DOPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_CLI \ $(NULL) ot_daemon_SOURCES = \ @@ -139,12 +106,12 @@ ot_daemon_SOURCES = \ ot_daemon_LDADD = \ $(top_builddir)/src/cli/libopenthread-cli-ftd.a \ - $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \ $(top_builddir)/src/core/libopenthread-ftd.a \ $(LDADD_COMMON) \ $(top_builddir)/src/cli/libopenthread-cli-ftd.a \ - $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \ $(top_builddir)/src/core/libopenthread-ftd.a \ + $(top_builddir)/src/lib/spinel/libopenthread-spinel-rcp.a \ + $(top_builddir)/src/lib/hdlc/libopenthread-hdlc.a \ $(LDADD_COMMON) \ $(NULL) @@ -158,7 +125,6 @@ ot_daemon_LIBTOOLFLAGS = \ ot_cli_CPPFLAGS = \ $(CPPFLAGS_COMMON) \ - -DOPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_CLI \ $(NULL) ot_cli_SOURCES = \ @@ -168,12 +134,12 @@ ot_cli_SOURCES = \ ot_cli_LDADD = \ $(top_builddir)/src/cli/libopenthread-cli-ftd.a \ - $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \ $(top_builddir)/src/core/libopenthread-ftd.a \ $(LDADD_COMMON) \ $(top_builddir)/src/cli/libopenthread-cli-ftd.a \ - $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \ $(top_builddir)/src/core/libopenthread-ftd.a \ + $(top_builddir)/src/lib/spinel/libopenthread-spinel-rcp.a \ + $(top_builddir)/src/lib/hdlc/libopenthread-hdlc.a \ $(LDADD_COMMON) \ $(NULL) @@ -186,7 +152,6 @@ ot_cli_LIBTOOLFLAGS = \ $(NULL) if OPENTHREAD_ENABLE_LINKER_MAP -ot_ncp_LDFLAGS += -Wl,-Map=ot-cli-ftd.map ot_cli_LDFLAGS += -Wl,-Map=ot-cli-mtd.map endif diff --git a/src/posix/README.md b/src/posix/README.md index 59de6e377..f2c210beb 100644 --- a/src/posix/README.md +++ b/src/posix/README.md @@ -82,26 +82,7 @@ python cc2538-bsl/cc2538-bsl.py -b 460800 -e -w -v -p /dev/ttyUSB0 ot-rcp.bin ./output/posix/bin/ot-cli 'spinel+hdlc+uart:///dev/ttyUSB0?uart-baudrate=115200' ``` -## Wpantund Support - -**NOTE** Assuming the build system is 64bit Linux and _wpantund_ is already installed and **stopped**. - -### With Simulation - -```sh -sudo wpantund -s 'system:./output/posix/bin/ot-ncp spinel+hdlc+forkpty://output/simulation/bin/ot-rcp?forkpty-arg=1' -``` - -### With Real Device - -```sh -# nRF52840 -sudo wpantund -s 'system:./output/posix/bin/ot-ncp spinel+hdlc+uart:///dev/ttyACM0?uart-baudrate=115200' -# CC2538 -sudo wpantund -s 'system:./output/posix/bin/ot-ncp spinel+hdlc+uart:///dev/ttyUSB0?uart-baudrate=115200' -``` - -## Daemon Mode Support +## Daemon Mode OpenThread Posix Daemon mode uses a unix socket as input and output, so that OpenThread core can run as a service. And a client can communicate with it by connecting to the socket. The protocol is OpenThread CLI. diff --git a/src/posix/cli.cmake b/src/posix/cli.cmake index cfb5dc380..3bf007733 100644 --- a/src/posix/cli.cmake +++ b/src/posix/cli.cmake @@ -42,7 +42,6 @@ target_include_directories(ot-cli PRIVATE ${COMMON_INCLUDES}) target_compile_definitions(ot-cli PRIVATE $<$:HAVE_LIB$=1> - OPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_CLI ${OT_PLATFORM_DEFINES} ) diff --git a/src/posix/daemon.cmake b/src/posix/daemon.cmake index 6eceddd53..f7e7326ec 100644 --- a/src/posix/daemon.cmake +++ b/src/posix/daemon.cmake @@ -40,7 +40,6 @@ set_target_properties( target_include_directories(ot-daemon PRIVATE ${COMMON_INCLUDES}) target_compile_definitions(ot-daemon PRIVATE - OPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_CLI ${OT_PLATFORM_DEFINES} ) @@ -53,7 +52,8 @@ target_link_libraries(ot-daemon PRIVATE ${OT_PLATFORM_LIB} openthread-ftd ${OT_PLATFORM_LIB} - openthread-ncp-ftd + openthread-hdlc + openthread-spinel-rcp ${OT_MBEDTLS} ) diff --git a/src/posix/main.c b/src/posix/main.c index da5006ae0..752265867 100644 --- a/src/posix/main.c +++ b/src/posix/main.c @@ -53,23 +53,15 @@ #define HAVE_LIBREADLINE 0 #endif -#define OT_POSIX_APP_TYPE_NCP 1 -#define OT_POSIX_APP_TYPE_CLI 2 - #include #include #include #include #include #include -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP -#include -#elif OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI +#if !OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE #include - #include "cli/cli_config.h" -#else -#error "Unknown posix app type!" #endif #include #include @@ -295,7 +287,6 @@ static void ParseArg(int aArgCount, char *aArgVector[], PosixConfig *aConfig) aConfig->mPlatformConfig.mRadioUrl = aArgVector[optind]; } -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI static void PrintRadioUrl(void *aContext, uint8_t aArgsLength, char *aArgs[]) { (void)aArgsLength; @@ -304,7 +295,6 @@ static void PrintRadioUrl(void *aContext, uint8_t aArgsLength, char *aArgs[]) otPlatformConfig *config = (otPlatformConfig *)aContext; otCliOutputFormat("%s\r\nDone\r\n", config->mRadioUrl); } -#endif // OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI static otInstance *InitInstance(PosixConfig *aConfig) { @@ -353,12 +343,10 @@ void otPlatReset(otInstance *aInstance) int main(int argc, char *argv[]) { - otInstance *instance; - int rval = 0; - PosixConfig config; -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI + otInstance * instance; + int rval = 0; + PosixConfig config; otCliCommand radioUrlCommand = {"radiourl", PrintRadioUrl}; -#endif #ifdef __linux__ // Ensure we terminate this process if the @@ -380,14 +368,10 @@ int main(int argc, char *argv[]) setlogmask(setlogmask(0) & LOG_UPTO(LOG_DEBUG)); instance = InitInstance(&config); -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP - otAppNcpInit(instance); -#elif OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI #if !OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE otAppCliInit(instance); #endif otCliSetUserCommands(&radioUrlCommand, 1, &config.mPlatformConfig); -#endif while (true) { @@ -403,12 +387,8 @@ int main(int argc, char *argv[]) mainloop.mTimeout.tv_sec = 10; mainloop.mTimeout.tv_usec = 0; -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP - otAppNcpUpdate(&mainloop); -#elif OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI #if !OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE otAppCliUpdate(&mainloop); -#endif #endif otSysMainloopUpdate(instance, &mainloop); @@ -416,12 +396,8 @@ int main(int argc, char *argv[]) if (otSysMainloopPoll(&mainloop) >= 0) { otSysMainloopProcess(instance, &mainloop); -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP - otAppNcpProcess(&mainloop); -#elif OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI #if !OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE otAppCliProcess(&mainloop); -#endif #endif } else if (errno != EINTR) @@ -431,13 +407,9 @@ int main(int argc, char *argv[]) } } -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP - // disable ncp -#elif OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI #if !OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE otAppCliDeinit(); #endif -#endif exit: otInstanceFinalize(instance); diff --git a/src/posix/ncp.cmake b/src/posix/ncp.cmake deleted file mode 100644 index e313059bf..000000000 --- a/src/posix/ncp.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# -# Copyright (c) 2020, The OpenThread Authors. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the copyright holder nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -add_executable(ot-ncp - main.c - ncp.cpp -) - -set_target_properties( - ot-ncp - PROPERTIES - C_STANDARD 99 - CXX_STANDARD 11 -) - -target_include_directories(ot-ncp PRIVATE ${COMMON_INCLUDES}) - -target_compile_definitions(ot-ncp PRIVATE - OPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_NCP - ${OT_PLATFORM_DEFINES} -) - -target_compile_options(ot-ncp PRIVATE - ${OT_CFLAGS} -) - -target_link_libraries(ot-ncp - openthread-ncp-ftd - ${OT_PLATFORM_LIB} - openthread-ftd - ${OT_PLATFORM_LIB} - ${OT_MBEDTLS} - openthread-ncp-ftd -) - -install(TARGETS ot-ncp DESTINATION bin) diff --git a/src/posix/ncp.cpp b/src/posix/ncp.cpp deleted file mode 100644 index 868b71c6e..000000000 --- a/src/posix/ncp.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2021, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "openthread-posix-config.h" -#include "platform-posix.h" - -#include -#include -#include -#include - -#include -#include - -#include "common/code_utils.hpp" - -#if OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP -static const uint8_t *sWriteBuffer = nullptr; -static uint16_t sWriteLength = 0; - -static int ncpHdlcSend(const uint8_t *aBuf, uint16_t aBufLength) -{ - sWriteBuffer = aBuf; - sWriteLength = aBufLength; - - return aBufLength; -} - -extern "C" void otAppNcpInit(otInstance *aInstance) -{ - otNcpHdlcInit(aInstance, ncpHdlcSend); -} - -extern "C" void otAppNcpUpdate(otSysMainloopContext *aContext) -{ - FD_SET(STDIN_FILENO, &aContext->mReadFdSet); - FD_SET(STDIN_FILENO, &aContext->mErrorFdSet); - - if (aContext->mMaxFd < STDIN_FILENO) - { - aContext->mMaxFd = STDIN_FILENO; - } - - if (sWriteLength > 0) - { - FD_SET(STDOUT_FILENO, &aContext->mWriteFdSet); - FD_SET(STDOUT_FILENO, &aContext->mErrorFdSet); - - if (aContext->mMaxFd < STDOUT_FILENO) - { - aContext->mMaxFd = STDOUT_FILENO; - } - } -} - -extern "C" void otAppNcpProcess(const otSysMainloopContext *aContext) -{ - ssize_t rval; - - if (FD_ISSET(STDIN_FILENO, &aContext->mErrorFdSet)) - { - DieNowWithMessage("stdin", OT_EXIT_FAILURE); - } - - if (FD_ISSET(STDOUT_FILENO, &aContext->mErrorFdSet)) - { - DieNowWithMessage("stdout", OT_EXIT_FAILURE); - } - - if (FD_ISSET(STDIN_FILENO, &aContext->mReadFdSet)) - { - uint8_t buffer[256]; - - rval = read(STDIN_FILENO, buffer, sizeof(buffer)); - - if (rval > 0) - { - otNcpHdlcReceive(buffer, static_cast(rval)); - } - else if (rval <= 0) - { - DieNowWithMessage("UART read", (rval < 0) ? OT_EXIT_ERROR_ERRNO : OT_EXIT_FAILURE); - } - } - - if ((FD_ISSET(STDOUT_FILENO, &aContext->mWriteFdSet))) - { - if (sWriteLength > 0) - { - rval = write(STDOUT_FILENO, sWriteBuffer, sWriteLength); - - if (rval < 0) - { - DieNow(OT_EXIT_ERROR_ERRNO); - } - - sWriteBuffer += rval; - sWriteLength -= static_cast(rval); - } - - if (sWriteLength == 0) - { - otNcpHdlcSendDone(); - } - } -} -#endif // OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_NCP diff --git a/tests/toranj/start.sh b/tests/toranj/start.sh index dda94ac8f..be232bc25 100755 --- a/tests/toranj/start.sh +++ b/tests/toranj/start.sh @@ -102,34 +102,16 @@ else coverage_option="" fi -case $TORANJ_POSIX_RCP_MODEL in - 1 | yes) - use_posix_with_rcp=yes - ;; - *) - use_posix_with_rcp=no - ;; -esac - -if [ "$use_posix_with_rcp" = "no" ]; then - if [ "$TORANJ_RADIO" = "multi" ]; then - # Build all combinations - ./build.sh "${coverage_option}" ncp-15.4 || die "ncp-15.4 build failed" - (cd ${top_builddir} && make clean) || die "cd and clean failed" - ./build.sh "${coverage_option}" ncp-trel || die "ncp-trel build failed" - (cd ${top_builddir} && make clean) || die "cd and clean failed" - ./build.sh "${coverage_option}" ncp-15.4+trel || die "ncp-15.4+trel build failed" - (cd ${top_builddir} && make clean) || die "cd and clean failed" - else - ./build.sh "${coverage_option}" ncp-"${TORANJ_RADIO}" || die "ncp build failed" - fi +if [ "$TORANJ_RADIO" = "multi" ]; then + # Build all combinations + ./build.sh "${coverage_option}" ncp-15.4 || die "ncp-15.4 build failed" + (cd ${top_builddir} && make clean) || die "cd and clean failed" + ./build.sh "${coverage_option}" ncp-trel || die "ncp-trel build failed" + (cd ${top_builddir} && make clean) || die "cd and clean failed" + ./build.sh "${coverage_option}" ncp-15.4+trel || die "ncp-15.4+trel build failed" + (cd ${top_builddir} && make clean) || die "cd and clean failed" else - ./build.sh "${coverage_option}" rcp || die "rcp build failed" - ./build.sh "${coverage_option}" posix-"${TORANJ_RADIO}" || die "posix build failed" - - if [ "$TORANJ_RADIO" = "trel" ]; then - prepare_trel_link - fi + ./build.sh "${coverage_option}" ncp-"${TORANJ_RADIO}" || die "ncp build failed" fi cleanup diff --git a/tests/toranj/test-001-get-set.py b/tests/toranj/test-001-get-set.py index 5a26499ba..2daed0131 100644 --- a/tests/toranj/test-001-get-set.py +++ b/tests/toranj/test-001-get-set.py @@ -174,8 +174,6 @@ all_gettable_props = [ wpan.WPAN_THREAD_STABLE_LEADER_NETWORK_DATA, ] -all_posix_gettable_props = [wpan.WPAN_RCP_VERSION] - # note: Partition Id only takes effect after forming one Thread network. node.set(wpan.WPAN_PARTITION_ID, '12345678') @@ -187,10 +185,6 @@ verify(int(node.get(wpan.WPAN_PARTITION_ID), 0) == 12345678) for prop in all_gettable_props: node.get(prop) -if node.using_posix_with_rcp: - for prop in all_posix_gettable_props: - node.get(prop) - # ----------------------------------------------------------------------------------------------------------------------- # Test finished diff --git a/tests/toranj/wpan.py b/tests/toranj/wpan.py index 1153405a5..a25347d47 100644 --- a/tests/toranj/wpan.py +++ b/tests/toranj/wpan.py @@ -302,18 +302,11 @@ class Node(object): _VERBOSE = os.getenv('TORANJ_VERBOSE', 'no').lower() in ['true', '1', 't', 'y', 'yes', 'on'] _SPEED_UP_FACTOR = 1 # defines the default time speed up factor - # path to `wpantund`, `wpanctl`, `ot-ncp-ftd`,`ot-ncp` and `ot-rcp` + # path to `wpantund`, `wpanctl` and `ot-ncp-ftd` _WPANTUND = '%s/sbin/wpantund' % _WPANTUND_PREFIX _WPANCTL = '%s/bin/wpanctl' % _WPANTUND_PREFIX _OT_NCP_FTD = '%s/examples/apps/ncp/ot-ncp-ftd' % _OT_BUILDDIR - _OT_NCP_FTD_POSIX = '%s/src/posix/ot-ncp' % _OT_BUILDDIR - _OT_RCP = '%s/examples/apps/ncp/ot-rcp' % _OT_BUILDDIR - - # Environment variable used to determine how to run OpenThread - # If set to 1, then posix NCP (`ot-ncp`) is used along with a posix RCP `ot-rcp`. - # Otherwise, the posix NCP `ot-ncp-ftd` is used - _POSIX_ENV_VAR = 'TORANJ_POSIX_RCP_MODEL' # determines if the wpantund logs are saved in file or sent to stdout _TUND_LOG_TO_FILE = True @@ -338,19 +331,8 @@ class Node(object): self._interface_name = self._INTFC_NAME_PREFIX + str(index) self._verbose = verbose - # Check if env variable `TORANJ_POSIX_RCP_MODEL` is defined - # and use it to determine if to use operate in "posix-ncp-app". - if self._POSIX_ENV_VAR in os.environ: - self._use_posix_with_rcp = (os.environ[self._POSIX_ENV_VAR] in ['1', 'yes']) - else: - self._use_posix_with_rcp = False - - if self._use_posix_with_rcp: - ncp_socket_path = 'system:{}{} -s {} spinel+hdlc+uart://{}?forkpty-arg={}'.format( - self._OT_NCP_FTD_POSIX, '' if radios is None else radios, self._SPEED_UP_FACTOR, self._OT_RCP, index) - else: - ncp_socket_path = 'system:{}{} {} {}'.format(self._OT_NCP_FTD, '' if radios is None else radios, index, - self._SPEED_UP_FACTOR) + ncp_socket_path = 'system:{}{} {} {}'.format(self._OT_NCP_FTD, '' if radios is None else radios, index, + self._SPEED_UP_FACTOR) cmd = self._WPANTUND + \ ' -o Config:NCP:SocketPath \"{}\"'.format(ncp_socket_path) + \ @@ -395,10 +377,6 @@ class Node(object): def tund_log_file(self): return self._tund_log_file - @property - def using_posix_with_rcp(self): - return self._use_posix_with_rcp - # ------------------------------------------------------------------------------------------------------------------ # Executing a `wpanctl` command