Re: How to wait for file closing?
- Posted by SnakeCharmer Dec 11, 2012
- 1685 views
Apparently, I won't be able to do without lock-files. I have C-code, that get data from optical sensors and Eu-code, that control robot.
Pseudo-code of C-part:
0. delete "whattodo", if it exist
1. get data from optic sensors
2. put data to file "thatisee"
3. create empty file "whattodo"
4. wait for file "turnleft", "turnrght" or "goahead"
5. send order to engines
6. delete files "turnleft", turnrhgt" and "goahead"
7. go to step 1
Pseudo-code of Eu-part:
1. wait for file "whattodo"
2. read file "thatisee"
3. get answer from AI
4. rename "whattodo" to "turnleft", "turnrght" or "goahead"
5. go to step 1
OK?
Whether additional actions are necessary? Whether it is necessary to check, what the file "thatisee" was really updated after step 2?