Skip to content

Commit 45aa5f3

Browse files
vigneshraja123717root
authored andcommitted
made scrollable window to standby unless user sends q character to quit the window
1 parent 76685c7 commit 45aa5f3

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

cli/diag.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ int eye_observe_dev(struct switchtec_dev *dev, unsigned int error_threshold,
202202
struct switchtec_diag_port_6p_eye_data data_6p_out;
203203
int eye_data[4];
204204
int eye_6p_data[6];
205+
unsigned int w2h_score;
205206

206207
if (eye_capture_type == SWTEC_EOM_4P_CAPTURE)
207208
{
@@ -216,7 +217,7 @@ int eye_observe_dev(struct switchtec_dev *dev, unsigned int error_threshold,
216217

217218
if (!ret)
218219
{
219-
eye_plot_graph(eye_data, false);
220+
eye_plot_graph(eye_data, false, 0);
220221
}
221222
}
222223
else
@@ -232,8 +233,9 @@ int eye_observe_dev(struct switchtec_dev *dev, unsigned int error_threshold,
232233

233234
if (!ret)
234235
{
235-
printf("W2H Score for Lane %d is %d\n", lane_id, calculate_w2h_score(&data_6p_out));
236-
eye_plot_graph(eye_6p_data, true);
236+
w2h_score = calculate_w2h_score(&data_6p_out);
237+
printf("W2H Score for Lane %d is %d\n", lane_id, w2h_score);
238+
eye_plot_graph(eye_6p_data, true, w2h_score);
237239
}
238240
}
239241

cli/graph.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void plot_point(int x, int y)
384384
mvprintw(y/Y_SCALE, x*X_SCALE, "O (%d,%d)", x-Y_PRINT_OFFSET, y-X_PRINT_OFFSET);
385385
}
386386

387-
int eye_plot_graph(int *data, bool plot_6p_points)
387+
int eye_plot_graph(int *data, bool plot_6p_points, unsigned int w2h_score)
388388
{
389389
initscr();
390390
noecho();
@@ -406,6 +406,12 @@ int eye_plot_graph(int *data, bool plot_6p_points)
406406
mvprintw(y/Y_SCALE, 0, "%2d", y);
407407
}
408408

409+
char legend[32];
410+
snprintf(legend, sizeof(legend), "W2H SCORE = %u", w2h_score);
411+
412+
if (plot_6p_points == true)
413+
mvprintw(0, COLS - strlen(legend) - 1, "%s", legend);
414+
409415
//Adjusting the eye points to plot from 0 to 42 for x-axis and 0 t0 100 for Y-axis
410416
//as ncurses library did not support negative ploting
411417
data[0] = data[0] + X_LAYOUT_SHIFT;
@@ -435,8 +441,14 @@ int eye_plot_graph(int *data, bool plot_6p_points)
435441
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[3] + X_PRINT_OFFSET);
436442
}
437443

444+
mvprintw(LINES - 1, 0, "Press 'q' to quit.");
438445
refresh();
439-
getch();
446+
447+
int ch;
448+
while ((ch = getch()) != 'q') {
449+
// Standby, do nothing
450+
}
451+
440452
endwin();
441453
return 0;
442454
}

cli/graph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ int graph_draw_win(struct range *X, struct range *Y, int *data, int *shades,
8484
const char *title, char x_title, char y_title, char *status,
8585
graph_anim_fn *anim, void *opaque);
8686

87-
int eye_plot_graph(int *data, bool plot_6p_points);
87+
int eye_plot_graph(int *data, bool plot_6p_points, unsigned int w2h_score);
8888

8989
#endif

lib/diag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int switchtec_diag_eye_6p_data_fetch(struct switchtec_dev *dev, struct switchtec
256256
}
257257

258258
if (out.status == EOM_IN_PROGRESS) {
259-
usleep(5000);
259+
usleep(500000);
260260
goto retry;
261261
}
262262
else if(out.status == EOM_SUCCESS)
@@ -318,7 +318,7 @@ int switchtec_diag_eye_fetch(struct switchtec_dev *dev, struct switchtec_diag_po
318318
}
319319

320320
if (out.status == EOM_IN_PROGRESS) {
321-
usleep(5000);
321+
usleep(500000);
322322
goto retry;
323323
}
324324
else if(out.status == EOM_SUCCESS)

0 commit comments

Comments
 (0)