|
7 | 7 | #define TIME_STEP 32 |
8 | 8 |
|
9 | 9 | int main(int argc, char **argv) { |
10 | | - bool configured = false, received = false; |
11 | 10 | ts_setup(argv[0]); |
12 | 11 |
|
13 | | - while (!configured) { // receive message sent by the robot window. |
| 12 | + for (;;) { // receive message sent by the robot window. |
14 | 13 | wb_robot_step(TIME_STEP); |
15 | | - const char *configure_message; |
16 | | - while ((configure_message = wb_robot_wwi_receive_text())) { |
| 14 | + const char *configure_message = wb_robot_wwi_receive_text(); |
| 15 | + if (configure_message) { |
17 | 16 | if (strcmp(configure_message, "configure") == 0) { |
18 | | - configured = true; |
19 | | - wb_robot_wwi_send_text("test wwi functions from complete_test controller."); |
| 17 | + wb_robot_wwi_send_text("test wwi functions from robot_window_html controller."); |
| 18 | + break; |
20 | 19 | } else |
21 | 20 | ts_send_error_and_exit("Wrong configure message received from the HTML robot-window: %s", configure_message); |
22 | 21 | } |
23 | 22 | } |
24 | 23 |
|
25 | | - while (!received) { // receive message sent by Webots. |
| 24 | + for (;;) { // receive message sent by Webots. |
26 | 25 | wb_robot_step(TIME_STEP); |
27 | | - const char *test_message; |
28 | | - while ((test_message = wb_robot_wwi_receive_text())) { |
29 | | - if (strcmp(test_message, "Answer: test wwi functions from complete_test controller.") == 0) |
30 | | - received = true; |
| 26 | + const char *test_message = wb_robot_wwi_receive_text(); |
| 27 | + if (test_message) { |
| 28 | + if (strcmp(test_message, "Answer: test wwi functions from robot_window_html controller.") == 0) |
| 29 | + break; |
31 | 30 | else |
32 | 31 | ts_send_error_and_exit("Wrong test message received from the HTML robot-window: %s", test_message); |
33 | 32 | } |
|
0 commit comments