Hello out there,
just asking for inspiration.
I have a simulation which executes commands - everything ok.
But now the program should also communicate with external hardware via
a serial connection and that is the problem:
- I don't want to block waiting for an answer since I also have a GUI.
- Turning to file events I now have the problem that the simulation
cannot continue before a particular call to the hardware is complete:
It may ask the hardware for a particular value which is to be used in
the next command.
So my question is: How do I block execution of the simulation part
until an answer arrives /without/ blocking the whole app?
- An attempt to use 'vwait' resulted in the whole app freezing.
- A separate thread would probably solve this problem.
- A coroutine would instinctively be a "lighter" solution but I have
so far never used coroutines and didn't find an example which seemed
to "fit" my situation.
- Any other way ...
Any idea, tip or link will be greatly appreciated
Helmut
Hello out there,
just asking for inspiration.
I have a simulation which executes commands - everything ok.
But now the program should also communicate with external hardware via
a serial connection and that is the problem:
- I don't want to block waiting for an answer since I also have a GUI.
- Turning to file events I now have the problem that the simulation
cannot continue before a particular call to the hardware is complete:
It may ask the hardware for a particular value which is to be used in
the next command.
So my question is: How do I block execution of the simulation part
until an answer arrives /without/ blocking the whole app?
- An attempt to use 'vwait' resulted in the whole app freezing.
- A separate thread would probably solve this problem.
- A coroutine would instinctively be a "lighter" solution but I have
so far never used coroutines and didn't find an example which seemed
to "fit" my situation.
- Any other way ...
Any idea, tip or link will be greatly appreciated
Helmut
Am 27.02.2024 um 22:29 schrieb Helmut Giese:
Hello out there,
just asking for inspiration.
I have a simulation which executes commands - everything ok.
But now the program should also communicate with external hardware via
a serial connection and that is the problem:
- I don't want to block waiting for an answer since I also have a GUI.
- Turning to file events I now have the problem that the simulation
cannot continue before a particular call to the hardware is complete:
It may ask the hardware for a particular value which is to be used in
the next command.
So my question is: How do I block execution of the simulation part
until an answer arrives /without/ blocking the whole app?
- An attempt to use 'vwait' resulted in the whole app freezing.
- A separate thread would probably solve this problem.
- A coroutine would instinctively be a "lighter" solution but I have
so far never used coroutines and didn't find an example which seemed
to "fit" my situation.
- Any other way ...
Any idea, tip or link will be greatly appreciated
Helmut
What about a program within a coroutine?
It is suspended until the condition arises.
You may link the coroutine to the fileevent.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 920 |
Nodes: | 10 (0 / 10) |
Uptime: | 104:31:02 |
Calls: | 12,189 |
Calls today: | 1 |
Files: | 186,527 |
Messages: | 2,237,522 |