I am writing a robot simulation scenario. The robots a programmed in C and use calls to a special API.
My plan is to compile the robot programs to a DLL and at the start of the simulation I'm going to call that DLL's main function to get it started.
The issue I have is how the DLL is going to communicate back. I will give an example of this in pseudo-code
Say the robot program is simply "SetLeftWheelSpeed(100)" and then "Wait(1500)" to get it to move its left wheel and then wait for 1.5s.
When I call the the robot's program how would I get SetLeftWheelSpeed(int speed) to communicate back with my simulator? I think of DLL as libraries of tools that you call a method on and it gives you a return. I have to keep it running in a loop so I can't just use return values I don't think .
EDIT:
Some more thought has led me to a fundamental problem. In my given example I wouldn't be able to compile the robot code because it doesn't have definitions for things like moving the wheels. For this I would have to link it to the API which is in the simulator. So maybe I have to link the API to the robot code, link the robot code to the simulator, and somehow link simulator to the API so that it implements what it is supposed to do.