diff --git a/README.md b/README.md index f0f759b5..fc218749 100644 --- a/README.md +++ b/README.md @@ -216,15 +216,26 @@ You then need to run `scp` with the `-P 1535` flag with `localhost` as the targe ## Port forwarding for TMTC commanding -This requires using the TCP on sender side (Python client) and receiver side (OBSW TMTC TCP server). +If you are using the UDP communication interface, you can use: ```sh ssh -L 1536:192.168.133.10:7301 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 -t /bin/bash ``` +This forwards UDP TMTC packets on port `1536` of localhost to the TMTC reception port of the Q7S. + +For TCP, you can use + +```sh +ssh -L 1537:192.168.133.10:7303 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 -t /bin/bash +``` + +This forwards TCP TMTC packets on port `1537` of localhost to the TMTC reception port of the Q7S. + ## Set up all port forwarding at once -You can specify the `-L` option multiple times to set up all port forwarding at once +You can specify the `-L` option multiple times to set up all port forwarding at once. +Example for using the UDP communication interface: ```sh ssh -L 1534:192.168.133.10:1534 \ diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index 2743aa36..8ef40d06 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -72,13 +72,13 @@ void initmission::initTasks() { /* UDP bridge */ PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::UDP_BRIDGE); + result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "Add component UDP Unix Bridge failed" << std::endl; } PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK); + result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "Add component UDP Polling failed" << std::endl; } diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index acc0be37..0933df5b 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -28,7 +28,7 @@ void Factory::setStaticFrameworkObjectIds(){ CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::UDP_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; // No storage object for now. TmFunnel::storageDestination = objects::NO_OBJECT; @@ -40,7 +40,7 @@ void ObjectFactory::produce(void* args){ Factory::setStaticFrameworkObjectIds(); ObjectFactory::produceGenericObjects(); - new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE); + new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); } diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 9e7abd94..68423216 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -66,13 +66,13 @@ void initmission::initTasks() { /* UDP bridge */ PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::UDP_BRIDGE); + result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "Add component UDP Unix Bridge failed" << std::endl; } PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK); + result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "Add component UDP Polling failed" << std::endl; } diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 4f7dd59a..0d3e8ce5 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -45,7 +45,7 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::UDP_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; // No storage object for now. TmFunnel::storageDestination = objects::NO_OBJECT; @@ -59,8 +59,8 @@ void ObjectFactory::produce(void* args){ Factory::setStaticFrameworkObjectIds(); ObjectFactory::produceGenericObjects(); - new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE); + new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); GpioCookie* gpioCookie = nullptr; diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index a46c74f1..b72bbf62 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,9 +1,14 @@ #include "CoreController.h" -#include "q7sConfig.h" +#include "OBSWConfig.h" #include "OBSWVersion.h" #include "fsfw/FSFWVersion.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#if OBSW_USE_TMTC_TCP_BRIDGE == 0 +#include "fsfw/osal/common/UdpTmTcBridge.h" +#else +#include "fsfw/osal/common/TcpTmTcBridge.h" +#endif #include "bsp_q7s/memory/scratchApi.h" #include "bsp_q7s/memory/SdCardManager.h" @@ -188,6 +193,7 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() { if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; } + initPrint(); return result; } @@ -349,3 +355,15 @@ ReturnValue_t CoreController::versionFileInit() { return HasReturnvaluesIF::RETURN_OK; } + +void CoreController::initPrint() { +#if OBSW_VERBOSE_LEVEL >= 1 +#if OBSW_USE_TMTC_TCP_BRIDGE == 0 + sif::info << "Created UDP server for TMTC commanding with listener port " << + TcpTmTcBridge::DEFAULT_UDP_SERVER_PORT << std::endl; +#else + sif::info << "Created TCP server for TMTC commanding with listener port " << + TcpTmTcBridge::DEFAULT_TCP_SERVER_PORT << std::endl; +#endif +#endif +} diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index d815f302..88415949 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -41,6 +41,7 @@ private: SdCardManager::SdStatusPair& statusPair); ReturnValue_t versionFileInit(); + void initPrint(); }; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 712cf9c8..a619da5a 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -82,19 +82,20 @@ void initmission::initTasks() { } /* UDP bridge */ - PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::UDP_BRIDGE); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_BRIDGE", objects::UDP_BRIDGE); + initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); } - PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_POLLING", objects::UDP_POLLING_TASK); + initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } + // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task PeriodicTaskIF* fsTask = factory->createPeriodicTask( @@ -133,8 +134,8 @@ void initmission::initTasks() { sif::info << "Starting tasks.." << std::endl; tmTcDistributor->startTask(); - udpBridgeTask->startTask(); - udpPollingTask->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); coreController->startTask(); taskStarter(pstTasks, "PST task vector"); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3e36e63d..53da02c5 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -63,9 +63,16 @@ #include "fsfw/tmtcservices/PusServiceBase.h" #include "fsfw/tmtcpacket/pus/tm.h" -/* UDP server includes */ +#if OBSW_USE_TMTC_TCP_BRIDGE == 0 +// UDP server includes #include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#else +// TCP server includes +#include "fsfw/osal/common/TcpTmTcBridge.h" +#include "fsfw/osal/common/TcpTmTcServer.h" +#endif + #include "linux/boardtest/SpiTestClass.h" #if TEST_LIBGPIOD == 1 @@ -83,7 +90,7 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::UDP_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; // No storage object for now. TmFunnel::storageDestination = objects::NO_OBJECT; @@ -131,8 +138,13 @@ void ObjectFactory::produce(void* args){ createReactionWheelComponents(gpioComIF); #endif /* TE7020 != 0 */ - new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE); +#if OBSW_USE_TMTC_TCP_BRIDGE == 0 + new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); +#else + new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); +#endif /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 6c5cb4c4..3d741bcf 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -3,5 +3,4 @@ #define OBSW_ADD_LWGPS_TEST 0 - #endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 0505e570..8c9a83b9 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -8,8 +8,8 @@ enum commonObjects: uint32_t { /* First Byte 0x50-0x52 reserved for PUS Services **/ CCSDS_PACKET_DISTRIBUTOR = 0x50000100, PUS_PACKET_DISTRIBUTOR = 0x50000200, - UDP_BRIDGE = 0x50000300, - UDP_POLLING_TASK = 0x50000400, + TMTC_BRIDGE = 0x50000300, + TMTC_POLLING_TASK = 0x50000400, FILE_SYSTEM_HANDLER = 0x50000500, /* 0x43 ('C') for Controllers */ diff --git a/fsfw b/fsfw index c5b4b013..1f6a5e63 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c5b4b0136217219a4443d858f42c368af9b15f27 +Subproject commit 1f6a5e635fcd6bd812e262cc65a15a8a054f7ecf diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index ab55537d..7a798717 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -17,6 +17,11 @@ /* These defines should be disabled for mission code but are useful for debugging. */ #define OBSW_VERBOSE_LEVEL 1 + +// Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally +// because UDP packets are not allowed in the VPN +#define OBSW_USE_TMTC_TCP_BRIDGE 0 + #define OBSW_PRINT_MISSED_DEADLINES 1 #define OBSW_ADD_TEST_CODE 1 #define OBSW_ADD_TEST_PST 1 diff --git a/scripts/q7s-port-tcp.sh b/scripts/q7s-port-tcp.sh new file mode 100755 index 00000000..9d370670 --- /dev/null +++ b/scripts/q7s-port-tcp.sh @@ -0,0 +1,11 @@ +#!/bin/bash +echo "Setting up all Q7S ports" +echo "-L 1534:192.168.133.10:1534 for connection to TCF agent" +echo "-L 1535:192.168.133.10:22 for file transfers" +echo "-L 1537:192.168.133.10:7303 to TMTC commanding using TCP" + +ssh -L 1534:192.168.133.10:1534 \ + -L 1535:192.168.133.10:22 \ + -L 1537:192.168.133.10:7303 \ + eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \ + -t 'CONSOLE_PREFIX="[Q7S Tunnel]" /bin/bash' diff --git a/scripts/q7s-port.sh b/scripts/q7s-port-udp.sh similarity index 84% rename from scripts/q7s-port.sh rename to scripts/q7s-port-udp.sh index 4bbf17e9..21393083 100755 --- a/scripts/q7s-port.sh +++ b/scripts/q7s-port-udp.sh @@ -2,7 +2,7 @@ echo "Setting up all Q7S ports" echo "-L 1534:192.168.133.10:1534 for connection to TCF agent" echo "-L 1535:192.168.133.10:22 for file transfers" -echo "-L 1536:192.168.133.10:7301 to TMTC commanding using TCP" +echo "-L 1536:192.168.133.10:7301 to TMTC commanding using UDP" ssh -L 1534:192.168.133.10:1534 \ -L 1535:192.168.133.10:22 \