diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 213ceb3e..2d6b6ad9 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -12,6 +12,7 @@ cmake cmakelists cmp commonprefix +Comms config configparser configs @@ -32,7 +33,7 @@ datetime dedent deduplicated deepcopy -Deframer +deframer deframing DEPS deser @@ -50,7 +51,7 @@ dirone dirs distutils doctest -Drv +drv dumpable Dxyz elif diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/instances.fpp b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/instances.fpp index e08dd63a..00f7acd6 100644 --- a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/instances.fpp +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/instances.fpp @@ -43,17 +43,22 @@ module {{cookiecutter.deployment_name}} { stack size Default.STACK_SIZE \ priority 100 - instance fileDownlink: Svc.FileDownlink base id 0x0700 \ + instance comQueue: Svc.ComQueue base id 0x0700 \ + queue size Default.QUEUE_SIZE \ + stack size Default.STACK_SIZE \ + priority 100 \ + + instance fileDownlink: Svc.FileDownlink base id 0x0800 \ queue size 30 \ stack size Default.STACK_SIZE \ priority 100 - instance fileManager: Svc.FileManager base id 0x0800 \ + instance fileManager: Svc.FileManager base id 0x0900 \ queue size 30 \ stack size Default.STACK_SIZE \ priority 100 - instance fileUplink: Svc.FileUplink base id 0x0900 \ + instance fileUplink: Svc.FileUplink base id 0x0A00 \ queue size 30 \ stack size Default.STACK_SIZE \ priority 100 @@ -95,17 +100,17 @@ module {{cookiecutter.deployment_name}} { @ Communications driver. May be swapped with other comm drivers like UART @ Note: Here we have TCP reliable uplink and UDP (low latency) downlink - instance comm: Drv.ByteStreamDriverModel base id 0x4000 \ + instance comDriver: Drv.ByteStreamDriverModel base id 0x4000 \ type "Drv::TcpClient" \ # type specified to select implementor of ByteStreamDriverModel at "../../Drv/TcpClient/TcpClient.hpp" # location of above implementor must also be specified - instance downlink: Svc.Framer base id 0x4100 + instance framer: Svc.Framer base id 0x4100 instance fatalAdapter: Svc.AssertFatalAdapter base id 0x4200 instance fatalHandler: Svc.FatalHandler base id 0x4300 - instance fileUplinkBufferManager: Svc.BufferManager base id 0x4400 + instance bufferManager: Svc.BufferManager base id 0x4400 instance linuxTime: Svc.Time base id 0x4500 \ type "Svc::LinuxTime" \ @@ -113,12 +118,12 @@ module {{cookiecutter.deployment_name}} { instance rateGroupDriver: Svc.RateGroupDriver base id 0x4600 - instance staticMemory: Svc.StaticMemory base id 0x4700 - instance textLogger: Svc.PassiveTextLogger base id 0x4800 - instance uplink: Svc.Deframer base id 0x4900 + instance deframer: Svc.Deframer base id 0x4900 instance systemResources: Svc.SystemResources base id 0x4A00 + instance comStub: Svc.ComStub base id 0x4B00 + } diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/topology.fpp b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/topology.fpp index 9a80009a..5a2f1ff2 100644 --- a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/topology.fpp +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/topology.fpp @@ -10,11 +10,6 @@ module {{cookiecutter.deployment_name}} { rateGroup3 } - enum Ports_StaticMemory { - downlink - uplink - } - topology {{cookiecutter.deployment_name}} { # ---------------------------------------------------------------------- @@ -26,24 +21,25 @@ module {{cookiecutter.deployment_name}} { instance tlmSend instance cmdDisp instance cmdSeq - instance comm - instance downlink + instance comDriver + instance comQueue + instance comStub + instance deframer instance eventLogger instance fatalAdapter instance fatalHandler instance fileDownlink instance fileManager instance fileUplink - instance fileUplinkBufferManager + instance bufferManager + instance framer instance linuxTime instance prmDb instance rateGroup1 instance rateGroup2 instance rateGroup3 instance rateGroupDriver - instance staticMemory instance textLogger - instance uplink instance systemResources # ---------------------------------------------------------------------- @@ -70,15 +66,23 @@ module {{cookiecutter.deployment_name}} { connections Downlink { - tlmSend.PktSend -> downlink.comIn - eventLogger.PktSend -> downlink.comIn - fileDownlink.bufferSendOut -> downlink.bufferIn + eventLogger.PktSend -> comQueue.comQueueIn[0] + tlmSend.PktSend -> comQueue.comQueueIn[1] + fileDownlink.bufferSendOut -> comQueue.buffQueueIn[0] + + comQueue.comQueueSend -> framer.comIn + comQueue.buffQueueSend -> framer.bufferIn - downlink.framedAllocate -> staticMemory.bufferAllocate[Ports_StaticMemory.downlink] - downlink.framedOut -> comm.send - downlink.bufferDeallocate -> fileDownlink.bufferReturn + framer.framedAllocate -> bufferManager.bufferGetCallee + framer.framedOut -> comStub.comDataIn + framer.bufferDeallocate -> fileDownlink.bufferReturn - comm.deallocate -> staticMemory.bufferDeallocate[Ports_StaticMemory.downlink] + comDriver.deallocate -> bufferManager.bufferSendIn + comDriver.ready -> comStub.drvConnected + + comStub.comStatus -> framer.comStatusIn + framer.comStatusOut -> comQueue.comStatusIn + comStub.drvDataOut -> comDriver.send } @@ -104,7 +108,7 @@ module {{cookiecutter.deployment_name}} { rateGroupDriver.CycleOut[Ports_RateGroups.rateGroup3] -> rateGroup3.CycleIn rateGroup3.RateGroupMemberOut[0] -> $health.Run rateGroup3.RateGroupMemberOut[1] -> blockDrv.Sched - rateGroup3.RateGroupMemberOut[2] -> fileUplinkBufferManager.schedIn + rateGroup3.RateGroupMemberOut[2] -> bufferManager.schedIn } connections Sequencer { @@ -114,17 +118,19 @@ module {{cookiecutter.deployment_name}} { connections Uplink { - comm.allocate -> staticMemory.bufferAllocate[Ports_StaticMemory.uplink] - comm.$recv -> uplink.framedIn - uplink.framedDeallocate -> staticMemory.bufferDeallocate[Ports_StaticMemory.uplink] + comDriver.allocate -> bufferManager.bufferGetCallee + comDriver.$recv -> comStub.drvDataIn + comStub.comDataOut -> deframer.framedIn + + deframer.framedDeallocate -> bufferManager.bufferSendIn + deframer.comOut -> cmdDisp.seqCmdBuff - uplink.comOut -> cmdDisp.seqCmdBuff - cmdDisp.seqCmdStatus -> uplink.cmdResponseIn + cmdDisp.seqCmdStatus -> deframer.cmdResponseIn - uplink.bufferAllocate -> fileUplinkBufferManager.bufferGetCallee - uplink.bufferOut -> fileUplink.bufferSendIn - uplink.bufferDeallocate -> fileUplinkBufferManager.bufferSendIn - fileUplink.bufferSendOut -> fileUplinkBufferManager.bufferSendIn + deframer.bufferAllocate -> bufferManager.bufferGetCallee + deframer.bufferOut -> fileUplink.bufferSendIn + deframer.bufferDeallocate -> bufferManager.bufferSendIn + fileUplink.bufferSendOut -> bufferManager.bufferSendIn } connections {{cookiecutter.deployment_name}} { diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Packets.xml b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Packets.xml index 9de89ec2..c07c4dcd 100644 --- a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Packets.xml +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Packets.xml @@ -13,9 +13,9 @@ - - - + + + @@ -32,8 +32,8 @@ - - + + @@ -41,6 +41,11 @@ + + + + + diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Topology.cpp b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Topology.cpp index eb3774eb..87c0a385 100644 --- a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Topology.cpp +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Topology.cpp @@ -30,6 +30,8 @@ Fw::MallocAllocator mallocator; Svc::FprimeFraming framing; Svc::FprimeDeframing deframing; +Svc::ComQueue::QueueConfigurationTable configurationTable; + // The reference topology divides the incoming clock signal (1Hz) into sub-signals: 1Hz, 1/2Hz, and 1/4Hz NATIVE_INT_TYPE rateGroupDivisors[Svc::RateGroupDriver::DIVIDER_SIZE] = {1, 2, 4}; @@ -48,9 +50,14 @@ enum TopologyConstants { FILE_DOWNLINK_FILE_QUEUE_DEPTH = 10, HEALTH_WATCHDOG_CODE = 0x123, COMM_PRIORITY = 100, - UPLINK_BUFFER_MANAGER_STORE_SIZE = 3000, - UPLINK_BUFFER_MANAGER_QUEUE_SIZE = 30, - UPLINK_BUFFER_MANAGER_ID = 200 + // bufferManager constants + FRAMER_BUFFER_SIZE = FW_MAX(FW_COM_BUFFER_MAX_SIZE, FW_FILE_BUFFER_MAX_SIZE + sizeof(U32)) + HASH_DIGEST_LENGTH + Svc::FpFrameHeader::SIZE, + FRAMER_BUFFER_COUNT = 30, + DEFRAMER_BUFFER_SIZE = FW_MAX(FW_COM_BUFFER_MAX_SIZE, FW_FILE_BUFFER_MAX_SIZE + sizeof(U32)), + DEFRAMER_BUFFER_COUNT = 30, + COM_DRIVER_BUFFER_SIZE = 3000, + COM_DRIVER_BUFFER_COUNT = 30, + BUFFER_MANAGER_ID = 200 }; // Ping entries are autocoded, however; this code is not properly exported. Thus, it is copied here. @@ -102,16 +109,29 @@ void configureTopology() { // Buffer managers need a configured set of buckets and an allocator used to allocate memory for those buckets. Svc::BufferManager::BufferBins upBuffMgrBins; memset(&upBuffMgrBins, 0, sizeof(upBuffMgrBins)); - upBuffMgrBins.bins[0].bufferSize = UPLINK_BUFFER_MANAGER_STORE_SIZE; - upBuffMgrBins.bins[0].numBuffers = UPLINK_BUFFER_MANAGER_QUEUE_SIZE; - fileUplinkBufferManager.setup(UPLINK_BUFFER_MANAGER_ID, 0, mallocator, upBuffMgrBins); + upBuffMgrBins.bins[0].bufferSize = FRAMER_BUFFER_SIZE; + upBuffMgrBins.bins[0].numBuffers = FRAMER_BUFFER_COUNT; + upBuffMgrBins.bins[1].bufferSize = DEFRAMER_BUFFER_SIZE; + upBuffMgrBins.bins[1].numBuffers = DEFRAMER_BUFFER_COUNT; + upBuffMgrBins.bins[2].bufferSize = COM_DRIVER_BUFFER_SIZE; + upBuffMgrBins.bins[2].numBuffers = COM_DRIVER_BUFFER_COUNT; + bufferManager.setup(BUFFER_MANAGER_ID, 0, mallocator, upBuffMgrBins); // Framer and Deframer components need to be passed a protocol handler - downlink.setup(framing); - uplink.setup(deframing); + framer.setup(framing); + deframer.setup(deframing); // Note: Uncomment when using Svc:TlmPacketizer //tlmSend.setPacketList({{cookiecutter.deployment_name}}PacketsPkts, {{cookiecutter.deployment_name}}PacketsIgnore, 1); + + // Events (highest-priority) + configurationTable.entries[0] = {.depth = 100, .priority = 0}; + // Telemetry + configurationTable.entries[1] = {.depth = 500, .priority = 2}; + // File Downlink + configurationTable.entries[2] = {.depth = 100, .priority = 1}; + // Allocation identifier is 0 as the MallocAllocator discards it + comQueue.configure(configurationTable, 0, mallocator); } // Public functions for use in main program are namespaced with deployment name {{cookiecutter.deployment_name}} @@ -135,8 +155,8 @@ void setupTopology(const TopologyState& state) { if (state.hostname != nullptr && state.port != 0) { Os::TaskString name("ReceiveTask"); // Uplink is configured for receive so a socket task is started - comm.configure(state.hostname, state.port); - comm.startSocketTask(name, true, COMM_PRIORITY, Default::STACK_SIZE); + comDriver.configure(state.hostname, state.port); + comDriver.startSocketTask(name, true, COMM_PRIORITY, Default::STACK_SIZE); } } @@ -172,11 +192,11 @@ void teardownTopology(const TopologyState& state) { freeThreads(state); // Other task clean-up. - comm.stopSocketTask(); - (void)comm.joinSocketTask(nullptr); + comDriver.stopSocketTask(); + (void)comDriver.joinSocketTask(nullptr); // Resource deallocation cmdSeq.deallocateBuffer(mallocator); - fileUplinkBufferManager.cleanup(); + bufferManager.cleanup(); } }; // namespace {{cookiecutter.deployment_name}}