I'm trying to schedule execution of a python function at a later time using ns.Simulator.Schedule. For example,
def my_function():
print("Hello from a function")t,
ns.Simulator.Schedule(ns.Seconds(5), my_function)
This doesn't work. Looks like, a pointer to my_function is needed on the C++ side. I don't know how to do that. Can you please suggest a way around?
FYI, I get the following error:
Traceback (most recent call last):
File "/home/shyam/repos1/ns-3-allinone/ns-3.37/scratch/lena-simple-try.py", line 10, in <module>
ns.Simulator.Schedule(ns.Seconds(5), my_function)
TypeError: Template method resolution failed:
static ns3::EventId ns3::Simulator::Schedule(const ns3::Time& delay, const ns3::Ptr<ns3::EventImpl>& event) =>
TypeError: could not convert argument 2
Failed to instantiate "Schedule(ns3::Time&,function)"
Failed to instantiate "Schedule(ns3::Time*,function)"
Failed to instantiate "Schedule(ns3::Time,function)"
Command 'python3 /home/shyam/repos1/ns-3-allinone/ns-3.37/scratch/lena-simple-try.py' returned non-zero exit status 1.
Thanks,
Shyam