Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lestarch: reworking posix tasks #992

Merged
merged 7 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void $(name)Init(void) {

void $(name)Start(void) {
// Active component startup
// start(identifier, priority, stack_size)
// start()
#for $startup_template in $component_startups:
${startup_template}
#end for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void construct$(name)Architecture(void) {
#else:
###
// Active component startup
// start(identifier, priority, stack_size)
// start()
#for $startup_template in $component_startups:
${startup_template}
#end for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,9 @@ def publicVisit(self, obj):
startup_template = ""
if component["kind"] == "active":
if obj.is_ptr:
startup_template = (
"""{name}_ptr->start(0, 100, 10 * 1024);""".format(**component)
)
startup_template = """{name}_ptr->start();""".format(**component)
else:
startup_template = """{name}.start(0, 100, 10 * 1024);""".format(
**component
)
startup_template = """{name}.start();""".format(**component)
c.component_startups.append(startup_template)
#

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,9 @@ def publicVisit(self, obj):
startup_template = ""
if component["kind"] == "active":
if obj.is_ptr:
startup_template = (
"""{name}_ptr->start(0, 100, 10 * 1024);""".format(**component)
)
startup_template = """{name}_ptr->start();""".format(**component)
else:
startup_template = """{name}.start(0, 100, 10 * 1024);""".format(
**component
)
startup_template = """{name}.start();""".format(**component)
c.component_startups.append(startup_template)
#

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,9 @@ def publicVisit(self, obj):
startup_template = ""
if component["kind"] == "active":
if obj.is_ptr:
startup_template = (
"""{name}_ptr->start(0, 100, 10 * 1024);""".format(**component)
)
startup_template = """{name}_ptr->start();""".format(**component)
else:
startup_template = """{name}.start(0, 100, 10 * 1024);""".format(
**component
)
startup_template = """{name}.start();""".format(**component)
c.component_startups.append(startup_template)
#

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,9 @@ def publicVisit(self, obj):
startup_template = ""
if component["kind"] == "active":
if obj.is_ptr:
startup_template = (
"""{name}_ptr->start(0, 100, 10 * 1024);""".format(**component)
)
startup_template = """{name}_ptr->start();""".format(**component)
else:
startup_template = """{name}.start(0, 100, 10 * 1024);""".format(
**component
)
startup_template = """{name}.start();""".format(**component)
c.component_startups.append(startup_template)
#

Expand Down
6 changes: 3 additions & 3 deletions Autocoders/Python/test/app1/DuckAppAcRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ void constructArchitecture(void) {

// Active component startup

// start(identifier, stack size, priority)
hueyComp_ptr->start(0, 10 * 1024, 100);
dueyComp_ptr->start(0, 10 * 1024, 100);
// start()
hueyComp_ptr->start();
dueyComp_ptr->start();

dumparch();
}
Expand Down
21 changes: 0 additions & 21 deletions Autocoders/Python/test/app1/ReadMe

This file was deleted.

46 changes: 0 additions & 46 deletions Autocoders/Python/test/app1/scons.log

This file was deleted.

6 changes: 3 additions & 3 deletions Autocoders/Python/test/app2/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void constructArchitecture(void) {

// Active component startup

// start(identifier, stack size, priority)
C1_ptr->start(0, 10 * 1024, 100);
C2_ptr->start(0, 10 * 1024, 100);
// start()
C1_ptr->start();
C2_ptr->start();

dumparch();

Expand Down
6 changes: 3 additions & 3 deletions Autocoders/Python/test/app2/test/ut/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void constructArchitecture(void) {

// Active component startup

// start(identifier, stack size, priority)
C1_ptr->start(0, 10 * 1024, 100);
C2_ptr->start(0, 10 * 1024, 100);
// start()
C1_ptr->start();
C2_ptr->start();

dumparch();

Expand Down
4 changes: 2 additions & 2 deletions Autocoders/Python/test/app4/app2AppAcRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void constructArchitecture(void) {
hueyComp_ptr->setoutputPort2Msg1OutputPort(0, hub1Comp_ptr->getinputPort2SerializeInputPort(0));

// Active component startup
// start(identifier, stack size, priority)
hueyComp_ptr->start(0, 10 * 1024, 100);
// start()
hueyComp_ptr->start();
dumparch();
}

Expand Down
4 changes: 2 additions & 2 deletions Autocoders/Python/test/cnt_only/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ int main(int argc, char* argv[]) {
constructArchitecture();

//Start Components
Huey_ptr->start(0, 10 * 1024, 100);
Duey_ptr->start(0, 10 * 1024, 100);
Huey_ptr->start();
Duey_ptr->start();

// Ask for input to huey or duey here.
char in[80];
Expand Down
4 changes: 2 additions & 2 deletions Autocoders/Python/test/cnt_only/test/ut/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ int main(int argc, char* argv[]) {
constructDuckArchitecture();

//Start Components
Huey.start(0, 10 * 1024, 100);
Duey.start(0, 10 * 1024, 100);
Huey.start();
Duey.start();

// Ask for input to huey or duey here.
char in[80];
Expand Down
2 changes: 1 addition & 1 deletion Autocoders/Python/test/command_string/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) {

TestCommand1Impl testImpl("TestCmdImpl");
testImpl.init(10);
testImpl.start(10,10*1024,100);
testImpl.start();
TestCommandSourceImpl cmdSrc("TestCmdSource");
cmdSrc.init();

Expand Down
4 changes: 2 additions & 2 deletions Autocoders/Python/test/partition/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void constructArchitecture(void) {
partitionComp_ptr->getoutputPort2SerializeOutputPort()->registerSerialPort(hueyComp_ptr->getinputPort3Msg3InputPort());

// Active component startup
// start(identifier, stack size, priority)
hueyComp_ptr->start(0, 10 * 1024, 100);
// start()
hueyComp_ptr->start();

dumparch();

Expand Down
4 changes: 2 additions & 2 deletions Autocoders/Python/test/passive/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void constructArchitecture(void) {

// Active component startup

// start(identifier, stack size, priority)
C1_ptr->start(0, 10 * 1024, 100);
// start()
C1_ptr->start();

dumparch();
}
Expand Down
2 changes: 1 addition & 1 deletion Autocoders/Python/test/serial_passive/test/ut/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(int argc, char* argv[]) {
serImpl.init(10,100);
ExampleComponents::ExampleComponentImpl exImpl("ExImpl");
exImpl.init();
serImpl.start(100,100,10*1024);
serImpl.start();

// connect ports
exImpl.set_exampleOutput_OutputPort(0,serImpl.get_SerialInSync_InputPort(0));
Expand Down
2 changes: 1 addition & 1 deletion Autocoders/Python/test/serialize_template/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) {
#endif

comp.init(10);
comp.start(10, 10 * 1024, 100);
comp.start();

AnotherExample::InputExamplePort* port = comp.getexampleInputExampleInputPort(0);

Expand Down
2 changes: 1 addition & 1 deletion Autocoders/Python/test/serialize_user/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) {
#endif

comp.init(10);
comp.start(10, 10 * 1024, 100);
comp.start();

AnotherExample::InputExamplePort* port = comp.get_exampleInput_InputPort(0);

Expand Down
2 changes: 1 addition & 1 deletion Autocoders/Python/test/stress/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) {
;
#endif
testImpl.init(10);
testImpl.start(10, 10 * 1024, 100);
testImpl.start();

TestCommandSourceImpl cmdSrc
#if FW_OBJECT_NAMES
Expand Down
4 changes: 2 additions & 2 deletions Drv/Ip/SocketReadTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ SocketReadTask::SocketReadTask() : m_stop(false) {}
SocketReadTask::~SocketReadTask() {}

void SocketReadTask::startSocketTask(const Fw::StringBase &name,
const bool reconnect,
const NATIVE_INT_TYPE priority,
const NATIVE_INT_TYPE stack,
const bool reconnect,
const NATIVE_INT_TYPE cpuAffinity) {
FW_ASSERT(not m_task.isStarted()); // It is a coding error to start this task multiple times
FW_ASSERT(not this->m_stop); // It is a coding error to stop the thread before it is started
m_reconnect = reconnect;
// Note: the first step is for the IP socket to open the the port
Os::Task::TaskStatus stat = m_task.start(name, 0, priority, stack, SocketReadTask::readTask, this, cpuAffinity);
Os::Task::TaskStatus stat = m_task.start(name, SocketReadTask::readTask, this, priority, stack, cpuAffinity);
FW_ASSERT(Os::Task::TASK_OK == stat, static_cast<NATIVE_INT_TYPE>(stat));
}

Expand Down
10 changes: 5 additions & 5 deletions Drv/Ip/SocketReadTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ class SocketReadTask {
* to the Os::Task::start call. cpuAffinity defaults to -1.
*
* \param name: name of the task
* \param priority: priority of the started task. See: Os::Task::start.
* \param stack: stack size provided to the task. See: Os::Task::start.
* \param reconnect: automatically reconnect socket when closed. Default: true.
* \param cpuAffinity: cpu affinity provided to task. See: Os::Task::start.
* \param priority: priority of the started task. See: Os::Task::start. Default: -1, not prioritized
* \param stack: stack size provided to the task. See: Os::Task::start. Default: -1, posix threads default
* \param cpuAffinity: cpu affinity provided to task. See: Os::Task::start. Default: -1, don't care
*/
void startSocketTask(const Fw::StringBase &name,
const NATIVE_INT_TYPE priority,
const NATIVE_INT_TYPE stack,
const bool reconnect = true,
const NATIVE_INT_TYPE priority = -1,
const NATIVE_INT_TYPE stack = -1,
const NATIVE_INT_TYPE cpuAffinity = -1);

/**
Expand Down
2 changes: 1 addition & 1 deletion Drv/Ip/docs/sdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ a Drv::SocketReadTask derived class is shown below.

```c++
Os::TaskString name("ReceiveTask");
uplinkComm.startSocketTask(name, 100, 10 * 1024); // Default reconnect=true
uplinkComm.startSocketTask(name); // Default reconnect=true
...

uplinkComm.stopSocketTask();
Expand Down
4 changes: 2 additions & 2 deletions Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ namespace Drv {
}

Os::Task::TaskStatus LinuxGpioDriverComponentImpl ::
startIntTask(NATIVE_INT_TYPE priority, NATIVE_INT_TYPE cpuAffinity) {
startIntTask(NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE cpuAffinity) {
Os::TaskString name;
name.format("GPINT_%s",this->getObjName()); // The task name can only be 16 chars including null
Os::Task::TaskStatus stat = this->m_intTask.start(name,0,priority,20*1024,LinuxGpioDriverComponentImpl::intTaskEntry,this,cpuAffinity);
Os::Task::TaskStatus stat = this->m_intTask.start(name, LinuxGpioDriverComponentImpl::intTaskEntry, this, priority, Os::Task::TASK_DEFAULT, cpuAffinity);

if (stat != Os::Task::TASK_OK) {
DEBUG_PRINT("Task start error: %d\n",stat);
Expand Down
2 changes: 1 addition & 1 deletion Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace Drv {
~LinuxGpioDriverComponentImpl(void);

//! Start interrupt task
Os::Task::TaskStatus startIntTask(NATIVE_INT_TYPE priority, NATIVE_INT_TYPE cpuAffinity = -1);
Os::Task::TaskStatus startIntTask(NATIVE_UINT_TYPE priority = Os::Task::TASK_DEFAULT, NATIVE_UINT_TYPE cpuAffinity = Os::Task::TASK_DEFAULT);

//! configure GPIO
enum GpioDirection {
Expand Down
2 changes: 1 addition & 1 deletion Drv/LinuxGpioDriver/LinuxGpioDriverComponentImplStub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Drv {
}

Os::Task::TaskStatus LinuxGpioDriverComponentImpl ::
startIntTask(NATIVE_INT_TYPE priority, NATIVE_INT_TYPE cpuAffinity) {
startIntTask(NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE cpuAffinity) {
return Os::Task::TASK_OK;
}

Expand Down
3 changes: 1 addition & 2 deletions Drv/LinuxSerialDriver/LinuxSerialDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ namespace Drv {
startReadThread(NATIVE_INT_TYPE priority, NATIVE_INT_TYPE stackSize, NATIVE_INT_TYPE cpuAffinity) {

Os::TaskString task("SerReader");
Os::Task::TaskStatus stat = this->m_readTask.start(task, 0, priority, stackSize,
serialReadTaskEntry, this, cpuAffinity);
Os::Task::TaskStatus stat = this->m_readTask.start(task, serialReadTaskEntry, this, priority, stackSize, cpuAffinity);
FW_ASSERT(stat == Os::Task::TASK_OK, stat);
}

Expand Down
3 changes: 2 additions & 1 deletion Drv/LinuxSerialDriver/LinuxSerialDriverComponentImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <Drv/LinuxSerialDriver/LinuxSerialDriverComponentAc.hpp>
#include <LinuxSerialDriverComponentImplCfg.hpp>
#include <Os/Mutex.hpp>
#include <Os/Task.hpp>

namespace Drv {

Expand Down Expand Up @@ -70,7 +71,7 @@ namespace Drv {
//! start the serial poll thread.
//! buffSize is the max receive buffer size
//!
void startReadThread(NATIVE_INT_TYPE priority, NATIVE_INT_TYPE stackSize, NATIVE_INT_TYPE cpuAffinity = -1);
void startReadThread(NATIVE_INT_TYPE priority = Os::Task::TASK_DEFAULT, NATIVE_INT_TYPE stackSize = Os::Task::TASK_DEFAULT, NATIVE_INT_TYPE cpuAffinity = Os::Task::TASK_DEFAULT);

//! Quit thread
void quitReadThread(void);
Expand Down
Loading