summaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-04 15:24:23 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-04 15:24:23 +0100
commit55c894778414d0be0a04929770bc7d4862d416d0 (patch)
tree304135621d7b73b295e95fc7031fdfb0756bcf60 /monitor
parent646720fdd975f30d7d1ef076feeda7b0d9b18c9a (diff)
downloadSystDigit-Projet-55c894778414d0be0a04929770bc7d4862d416d0.tar.gz
SystDigit-Projet-55c894778414d0be0a04929770bc7d4862d416d0.zip
Nothingness...
Diffstat (limited to 'monitor')
-rw-r--r--monitor/disp.c42
-rw-r--r--monitor/mon.c31
2 files changed, 46 insertions, 27 deletions
diff --git a/monitor/disp.c b/monitor/disp.c
index afefe41..7b11bef 100644
--- a/monitor/disp.c
+++ b/monitor/disp.c
@@ -15,7 +15,7 @@ static void disp_cmdline();
static char command[100];
static int cmd_pos = 0;
-static WINDOW *wpstatus, *wpoutput, *wcmdline;
+static WINDOW *wpstatus, *wpstatus2, *wpoutput, *wcmdline;
void disp_init() {
initscr();
@@ -24,9 +24,10 @@ void disp_init() {
noecho();
nonl();
- const int status_win_width = COLS / 2 + 5;
+ const int status_win_width = COLS / 2;
wpstatus = newwin(LINES - 4, status_win_width, 1, 1);
- wpoutput = newwin(LINES - 4, COLS - status_win_width - 3, 1, status_win_width + 2);
+ wpstatus2 = newwin(10, COLS - status_win_width - 3, 1, status_win_width + 2);
+ wpoutput = newwin(LINES - 13, COLS - status_win_width - 3, 11, status_win_width + 2);
wcmdline = newwin(1, COLS - 2, LINES - 2, 1);
intrflush(wcmdline, FALSE);
@@ -102,31 +103,38 @@ void disp_display(t_mon *mon) {
}
if (mon->n_outputs == 0) wprintw(wpstatus, "\t(none)\n");
- if (mon->ser_in_in != -1) {
- wprintw(wpstatus, "\nSerial buffer:\n%s\n", mon->ser_buf);
- }
+ wrefresh(wpstatus);
+
+ werase(wpstatus2);
- wprintw(wpstatus, "\n\n");
for (i = 0; i < 8; i++)
- wprintw(wpstatus, " %s ", (mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[0] == '1' ? "---" : " "));
- wprintw(wpstatus, "\n");
+ wprintw(wpstatus2, " %s ", (mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[0] == '1' ? "---" : " "));
+ wprintw(wpstatus2, "\n");
for (i = 0; i < 8; i++)
- wprintw(wpstatus, " %c %c",
+ wprintw(wpstatus2, " %c %c",
(mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[1] == '1' ? '|' : ' '),
(mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[2] == '1' ? '|' : ' '));
- wprintw(wpstatus, "\n");
+ wprintw(wpstatus2, "\n");
for (i = 0; i < 8; i++)
- wprintw(wpstatus, " %s ", (mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[3] == '1' ? "---" : " "));
- wprintw(wpstatus, "\n");
+ wprintw(wpstatus2, " %s ", (mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[3] == '1' ? "---" : " "));
+ wprintw(wpstatus2, "\n");
for (i = 0; i < 8; i++)
- wprintw(wpstatus, " %c %c",
+ wprintw(wpstatus2, " %c %c",
(mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[4] == '1' ? '|' : ' '),
(mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[5] == '1' ? '|' : ' '));
- wprintw(wpstatus, "\n");
+ wprintw(wpstatus2, "\n");
for (i = 0; i < 8; i++)
- wprintw(wpstatus, " %s ", (mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[6] == '1' ? "---" : " "));
+ wprintw(wpstatus2, " %s ", (mon->d7[i] != -1 && mon->outputs[mon->d7[i]].v_bin[6] == '1' ? "---" : " "));
- wrefresh(wpstatus);
+ if (mon->ser_in_in != -1) {
+ wprintw(wpstatus2, "\nSerial buffer:\n%s\n", mon->ser_buf);
+ }
+
+ if (mon->ser_out != -1) {
+ wmove(wpstatus2, 9, 0);
+ wprintw(wpstatus2, "Serial output:");
+ }
+ wrefresh(wpstatus2);
if (mon->ser_out_buf != 0) {
wprintw(wpoutput, "%c", mon->ser_out_buf);
diff --git a/monitor/mon.c b/monitor/mon.c
index 22197e9..19259a1 100644
--- a/monitor/mon.c
+++ b/monitor/mon.c
@@ -167,21 +167,32 @@ void mon_handle_command(t_mon *mon, const char *c) {
if (c[1] == 0) {
mon->ser_in_in = mon->ser_in_busy_out = mon->ser_out = -1;
} else {
- int u = 0, v = 0, w = 0;
+ int u = -1, v = -1, w = -1;
const char *p = c + 1;
while (isspace(*p)) p++;
- while (isdigit(*p)) u = u * 10 + (*(p++) - '0');
+ if (*p == '-') {
+ p++;
+ } else if (*p != 0) {
+ u = 0;
+ while (isdigit(*p)) u = u * 10 + (*(p++) - '0');
+ }
while (isspace(*p)) p++;
- while (isdigit(*p)) v = v * 10 + (*(p++) - '0');
+ if (*p == '-') {
+ p++;
+ } else if (*p != 0) {
+ v = 0;
+ while (isdigit(*p)) v = v * 10 + (*(p++) - '0');
+ }
while (isspace(*p)) p++;
- while (isdigit(*p)) w = w * 10 + (*(p++) - '0');
- if (u >= 0 && u < mon->n_inputs &&
- v >= 0 && v < mon->n_outputs &&
- w >= 0 && w < mon->n_outputs) {
- mon->ser_in_in = u;
- mon->ser_in_busy_out = v;
- mon->ser_out = w;
+ if (*p == '-') {
+ p++;
+ } else if (*p != 0) {
+ w = 0;
+ while (isdigit(*p)) w = w * 10 + (*(p++) - '0');
}
+ if (u < mon->n_inputs) mon->ser_in_in = u;
+ if (v < mon->n_outputs) mon->ser_in_busy_out = v;
+ if (w < mon->n_outputs) mon->ser_out = w;
}
} else if (c[0] == ':') {