Using QuarkTS with Omnet++ #28
Replies: 2 comments 1 reply
-
@kmilo17pet - I will give the implementation a try and also publish some results here - maybe this becomes handy for someone else in the future as well |
Beta Was this translation helpful? Give feedback.
-
Hi, #include <QuarkTS.h>
#include <omnetpp.h>
using namespace omnetpp;
void callback_1(qEvent_t arg)
{
EV << "Hello from callback 1.";
}
void callback_2(qEvent_t arg)
{
EV << "Hello from callback 2.";
}
class QuarkTS : public cSimpleModule
{
private:
cMessage *m_tick;
qTask_t m_task_1;
qTask_t m_task_2;
public:
QuarkTS();
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
Define_Module(QuarkTS);
QuarkTS::QuarkTS() :
m_task_1({0}),
m_task_2({0}),
m_tick(nullptr)
{
}
void QuarkTS::initialize()
{
m_tick = new cMessage("QuarkTS-Tick");
qOS_Setup(NULL, (float)0.001, NULL);
qOS_Add_Task(&m_task_1, callback_1, qHigh_Priority, (float)0.010, qPeriodic, qEnabled, NULL);
qOS_Add_Task(&m_task_2, callback_2, qHigh_Priority, (float)0.045, qPeriodic, qEnabled, NULL);
scheduleAt(simTime()+0.001, m_tick);
}
void QuarkTS::handleMessage(cMessage *msg)
{
if (msg == m_tick) {
// Give Scheduler the chance to run once before tick
qOS_Scheduler_Release();
qOS_Run();
// Execute Tick
qClock_SysTick();
// Give tasks the chance to run
qOS_Scheduler_Release();
qOS_Run();
// Schedule next tick event
scheduleAt(simTime()+0.001, m_tick);
}
} which gives the following simulation results:
This proves the concept of at least running time-scheduled tasks with this simple code. I will now try to simulate more complex network code, but the first steps are really promising. PS: Please don't mind the |
Beta Was this translation helpful? Give feedback.
-
Hi,
Repost of original Issue to track proceedings in the discussion: #26
Recently I came across a scenario where I may need to time tasks below 1 Millisecond - mainly within a simulation framework like Omnetpp. I somehow like the idea of using QuarkTS with Omnet as it would allow me to reuse a lot of code I will write for the simulation than in the actual firmware.
The plan is to use Omnetpp Self-Messages to simulate the ticks for QuarkTs. As I won't use a custom IDLE function, I thought about executing the QuarkTs Run Function after every Tick call and/or events. This should then execute all timed and event-driven tasks when I remember the kernel code correctly.
Coming to my questions:
Thanks for your effort!
Beta Was this translation helpful? Give feedback.
All reactions