summaryrefslogtreecommitdiff
path: root/monitor/mon.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-09 16:02:56 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-09 16:02:56 +0100
commit35e0c0f16f58a7503045de5e047e029dd06983a2 (patch)
treec2cf5661ae346644cb1c3eee7aeb2eb9edabffc6 /monitor/mon.c
parentf8c7333c7045ee9e4dae38933c29c6db12dd2501 (diff)
downloadSystDigit-Projet-35e0c0f16f58a7503045de5e047e029dd06983a2.tar.gz
SystDigit-Projet-35e0c0f16f58a7503045de5e047e029dd06983a2.zip
Added FEED/FED signals in protocol.
Diffstat (limited to 'monitor/mon.c')
-rw-r--r--monitor/mon.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/monitor/mon.c b/monitor/mon.c
index baef98b..780e8ba 100644
--- a/monitor/mon.c
+++ b/monitor/mon.c
@@ -82,7 +82,7 @@ void mon_loop(t_mon *mon) {
int displayer_steps = 0;
- while (mon->status != MS_FINISH) {
+ while (1) {
handle_kbd(mon);
if (mon->status == MS_AUTO) {
mon_step(mon);
@@ -125,8 +125,10 @@ void mon_loop(t_mon *mon) {
}
int sleep = 1000000 / mon->target_freq - mon->calc_time_usec;
if (sleep > 0) usleep(sleep);
- } else {
+ } else if (mon->status == MS_RUN) {
usleep(10000);
+ } else {
+ break;
}
}
}
@@ -266,12 +268,19 @@ void mon_step(t_mon *mon) {
}
// Send inputs to simulator
+ fprintf(mon->to_sim, "FEED\n");
for (i = 0; i < mon->n_inputs; i++) {
fprintf(mon->to_sim, "%s\n", mon->inputs[i].value);
}
fflush(mon->to_sim);
// Read outputs from simulator
+ int magic;
+ fscanf(mon->from_sim, " %x", &magic);
+ if (magic != 0xFED) {
+ mon->status = MS_PERROR;
+ return;
+ }
for (i = 0; i < mon->n_outputs; i++) {
fscanf(mon->from_sim, " %s %s %d",
mon->outputs[i].name,