Hi, one thing you can do is if you need a specific output from the python code, you can define the following function in the C++ code:
string exec(const char* cmd){
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
You can make the python code such that it prints the needed output to stdout. Then to retrieve that output from C++ all you need is
string s=exec("C:/Users/User/AppData/Local/Programs/Python/Python36/python.exe C:/Users/User/Documents/folder/main.py");
Where 'C:/Users/User/Documents/folder/main.py' basically means whatever your python program is.
"s" is a string containing the output of the python code. This can always be converted to double or other data types as needed.'
If you want to supply input to the python code from OMNET++, one quick solution is to write to a file which is subsequently read by the running python code. Otherwise you will have to establish a server connection to python which may be more difficult.