Example #1
0
void 
print_channel(struct deviceinfo *unit)
{
	int i = 0, option = EOF, scr_opt = 0;

	int rc;
	fd_set rfds;
	struct timeval tv;
	int max_fd;

	struct digi_node node;
	struct digi_chan chan;
	int port = 0;
	char ttyname[100];


	int d_invokes_capture = 1;   /* 0 if 'D' should invoke "exam_panel" */
	                             /* 1 if 'D' should invoke "scope_panel" */


	WINDOW *chanwin = GetWin(ChanWin);

	/* 
	 * scr_opt is just used to determine which field to 
	 * highlight.
	 */

	show_panel (GetPan(ChanWin));
	update_panels ();
	doupdate ();

	DPAOpenDevice(unit);

	while ((option != 'Q') && (option != 'q') && (option != ESC))
	{

		/* Get port info for current port */
		DPAGetNode(unit, &node);
		DPAGetChannel(unit, &chan, port);

		if (DPAGetPortName(unit, &node, &chan, port, ttyname) == NULL) {
			ttyname[0] = '\0';
		}

		max_fd = 0;
		FD_ZERO(&rfds);
		FD_SET(0, &rfds);

		mvwprintw (chanwin, 1, 2, "Device Description: %-54.54s", node.nd_ps_desc);

		mvwprintw (chanwin, 5, 35, "Name: %-10.10s", ttyname);

		wattrset (chanwin, make_attr (A_BOLD, WHITE, BLACK));

		mvwprintw (chanwin, 5, 56, "Status: %-10.10s",
		           chan.ch_open ? "Open" : "Closed");
		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));

		if (scr_opt == 1)
		{
			wattrset (chanwin, make_attr (A_REVERSE | A_STANDOUT, WHITE, BLACK));
			mvwprintw (chanwin, 3, 5, "Unit IP Address: %-15.15s", unit->host);
			wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
			mvwprintw (chanwin, 5, 8, "Port Number : %-2d", port + 1);
		}
		else if (scr_opt == 2)
		{
			wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
			mvwprintw (chanwin, 3, 5, "Unit IP Address: %-15.15s", unit->host);
			wattrset (chanwin, make_attr (A_REVERSE | A_STANDOUT, WHITE, BLACK));
			mvwprintw (chanwin, 5, 8, "Port Number : %-2d", port + 1);
			wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
		}
		else
		{
			mvwprintw (chanwin, 3, 5, "Unit IP Address: %-15.15s", unit->host);
			mvwprintw (chanwin, 5, 8, "Port Number : %-2d", port + 1);
		}

		if (!vanilla) wattrset (chanwin, make_attr (A_ALTCHARSET, GREEN, BLACK));
		else wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK));

		for (i = 0; i < 62; i++)
			mvwaddch (chanwin, 6, 8 + i, mapchar(ACS_HLINE));
		mvwaddch (chanwin, 6, 7, mapchar(ACS_ULCORNER));
		mvwaddch (chanwin, 6, 70, mapchar(ACS_URCORNER));
		mvwaddch (chanwin, 7, 7, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 7, 70, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 8, 7, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 8, 70, mapchar(ACS_VLINE));

		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
		mvwprintw (chanwin, 12, 24, "Signal Active = ");
		wattrset (chanwin, make_attr (A_STANDOUT, WHITE, GREEN));
		waddstr (chanwin, "X");

		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
		mvwaddstr (chanwin, 12, 46, "Inactive =");
		wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK));
		mvwaddstr (chanwin, 12, 57, "_");
		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));

		mvwaddstr (chanwin, 8, 13,
				   "Tx:             RTS  CTS  DSR  DCD  DTR  RI  OFC  IFC");
		mvwaddstr (chanwin, 9, 13,
				   "Rx:                                                  ");

		if (!vanilla)
			wattrset (chanwin, make_attr (A_ALTCHARSET, GREEN, BLACK));
		else
			wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK));

		mvwaddch (chanwin, 9, 7, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 9, 70, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 10, 7, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 10, 70, mapchar(ACS_VLINE));
		mvwaddch (chanwin, 11, 7, mapchar(ACS_LLCORNER));
		mvwaddch (chanwin, 11, 70, mapchar(ACS_LRCORNER));

		for (i = 0; i < 62; i++)
			mvwaddch (chanwin, 11, 8 + i, mapchar(ACS_HLINE));

		wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK));

		mvwprintw (chanwin, 8, 17, "%-10d", chan.ch_txcount);
		mvwprintw (chanwin, 9, 17, "%-10d", chan.ch_rxcount);

		{
			int msigs=6;
			int   mbits[] = { MS_RTS, MS_CTS, MS_DSR, MS_DCD, MS_DTR, MS_RI };
			char *mhstr[] = { "X",    "X",    "X",    "X",    "X",    "X"   };
			char *mlstr[] = { "_",    "_",    "_",    "_",    "_",    "_"   };
			int   mpos[]  = { 30,     35,     40,     45,     50,     55    };
			int sig=0;

			for(sig = 0; sig < msigs; sig++)
			{
				if (chan.ch_s_mstat & mbits[sig])
				{
					wattrset (chanwin, make_attr (A_STANDOUT, WHITE, GREEN));
					mvwprintw (chanwin, 9, mpos[sig], mhstr[sig]);
				}
				else
				{
					wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK));
					mvwprintw (chanwin, 9, mpos[sig], mlstr[sig]);
				}
			}
		}
		{
			int events=2;
			int   ebits[] = { EV_OPALL, EV_IPALL };
			char *ehstr[] = { "X",      "X"      };
			char *elstr[] = { "_",      "_"      };
			int   epos[]  = { 59,       64       };
			int ev=0;

			for(ev=0; ev<events; ev++)
			{
				if (chan.ch_s_estat & ebits[ev])
				{
					wattrset (chanwin, make_attr (A_STANDOUT, WHITE, GREEN));
					mvwprintw (chanwin, 9, epos[ev], ehstr[ev]);
				}
				else
				{
					wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK));
					mvwprintw (chanwin, 9, epos[ev], elstr[ev]);
				}
			}
		}

		wattrset (chanwin, make_attr (A_BOLD, WHITE, BLACK));
		mvwaddstr (chanwin, 14, 1, "  Input Modes ");
		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
		wprintw (chanwin, "                                                           ");
		wmove (chanwin, 14, 15);

		if (chan.ch_s_iflag & IF_IGNBRK)
			wprintw (chanwin, ":IGNBRK");
		if (chan.ch_s_iflag & IF_BRKINT)
			wprintw (chanwin, ":BRKINT");
		if (chan.ch_s_iflag & IF_IGNPAR)
			wprintw (chanwin, ":IGNPAR");
		if (chan.ch_s_iflag & IF_PARMRK)
			wprintw (chanwin, ":PARMRK");
		if (chan.ch_s_iflag & IF_INPCK)
			wprintw (chanwin, ":INPCK");
		if (chan.ch_s_iflag & IF_ISTRIP)
			wprintw (chanwin, ":ISTRIP");
		if (chan.ch_s_iflag & IF_IXON)
			wprintw (chanwin, ":IXON");
		if (chan.ch_s_iflag & IF_IXANY)
			wprintw (chanwin, ":IXANY");
		if (chan.ch_s_iflag & IF_IXOFF)
			wprintw (chanwin, ":IXOFF");
		if (chan.ch_s_xflag & XF_XIXON)
			wprintw (chanwin, ":IXONA");
		if (chan.ch_s_xflag & XF_XTOSS)
			wprintw (chanwin, ":ITOSS");
		if (chan.ch_s_iflag & IF_DOSMODE)
			wprintw (chanwin, ":DOSMODE");

		wprintw (chanwin, ":");
		wattrset (chanwin, make_attr (A_BOLD, WHITE, BLACK));
		mvwprintw (chanwin, 15, 1, " Output Modes ");
		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
		wprintw (chanwin, "                                                           ");
		wmove (chanwin, 15, 15);

		if (chan.ch_s_xflag & XF_XCASE)
			wprintw (chanwin, ":XCASE");
		if (chan.ch_s_oflag & OF_OLCUC)
			wprintw (chanwin, ":OLCUC");
		if (chan.ch_s_oflag & OF_ONLCR)
			wprintw (chanwin, ":ONLCR");
		if (chan.ch_s_oflag & OF_OCRNL)
			wprintw (chanwin, ":OCRNL");
		if (chan.ch_s_oflag & OF_ONOCR)
			wprintw (chanwin, ":ONOCR");
		if (chan.ch_s_oflag & OF_ONLRET)
			wprintw (chanwin, ":ONLRET");

		/* TODO -- tab expansion / TABDLY interpretation */

		wprintw (chanwin, ":");
		wattrset (chanwin, make_attr (A_BOLD, WHITE, BLACK));
		mvwprintw (chanwin, 16, 1, "Control Modes ");
		wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK));
		/*
		 * clear the field, then write the new one
		 */
		wprintw (chanwin, "                                                              ");
		wmove (chanwin, 16, 15);

		if (chan.ch_open) {
/* Jira RP-77: In early stages of a port open, ch_open is set before ch_s_brate
 * is initialized, which, undetected, causes an arithmetic exception here.
 */
                	if (chan.ch_s_brate)
                		wprintw (chanwin, ":%d Baud", PDIVIDEND / chan.ch_s_brate);
			else
                		wprintw (chanwin, ":?? Baud");

			switch (chan.ch_s_cflag & CF_CSIZE)
			{
			case CF_CS5:
				wprintw (chanwin, ":5 Char Bits");
				break;
			case CF_CS6:
				wprintw (chanwin, ":6 Char Bits");
				break;
			case CF_CS7:
				wprintw (chanwin, ":7 Char Bits");
				break;
			case CF_CS8:
				wprintw (chanwin, ":8 Char Bits");
				break;
			default:
				wprintw (chanwin, ":No Char Bits");
				break;
			}

			if (chan.ch_s_cflag & CF_CSTOPB)
				wprintw (chanwin, ":2 Stop Bits");
			else
				wprintw (chanwin, ":1 Stop Bits");

			if (chan.ch_s_cflag & CF_PARENB)
			{
				if (chan.ch_s_xflag & XF_XPAR)
				{
					if (chan.ch_s_cflag & CF_PARODD)
						wprintw (chanwin, ":Parity Odd");
					else
						wprintw (chanwin, ":Parity Even");
				}
				else
				{
					if (chan.ch_s_cflag & CF_PARODD)
						wprintw (chanwin, ":Parity Space");
					else
						wprintw (chanwin, ":Parity Mark");
				}
			}
			else
			{
				wprintw (chanwin, ":No Parity");
			}
		}
		else {
                	wprintw (chanwin, ":");
		}

		wattrset (GetWin(MainWin), make_attr (A_NORMAL, WHITE, BLUE));

		commandline (clbuf, helpstr, "ESC=Quit", lrudstr,
		             "T=LoopBack", "D=DataMonitor", "^P=Print", NULL);
		mvwprintw (GetWin(MainWin), KEY_LINE, 0, clbuf);

		wattroff (GetWin(MainWin), make_attr (A_NORMAL, WHITE, BLUE));
		wrefresh (GetWin(MainWin));
		wrefresh (chanwin);

		change_term (0, TIMEOUT);

		option = EOF;

		tv.tv_sec = 0;  tv.tv_usec = 500000;
		rc = select( max_fd + 1, &rfds, NULL, NULL, &tv );

		if (rc < 0)
		{
			fprintf (stderr, "FATAL ERROR: select failure.\n");
			EndCurses (-13);
			/* FIXME: This code will not be executed as 
			   EndCurses() calls exit(). */
			exit (-2);
		}
		else if (rc > 0)
		{
			if (FD_ISSET(0, &rfds))
			{
				option = getch();
			}

		}
		else
		{
			scr_opt = 0;
		}

		/*
		 * If the user hasn't selected anything keep doing the 
		 * original screen. 
		 */

		switch (option)
		{
		case EOF:
			break;

		case '':
			scr_opt = 0;
			refresh_screen ();
			break;

#ifdef KEY_LEFT
		case KEY_LEFT:
#endif
		case 'H':
		case 'h':

			port--;
			if (port < 0)
				port = unit->nports - 1;

			scr_opt = 2;
			break;

#ifdef KEY_RIGHT
		case KEY_RIGHT:
#endif
		case 'L':
		case 'l':

			port++;
			if (port >= (int) unit->nports)
				port = 0;

			scr_opt = 2;
			break;

#ifdef KEY_UP
		case KEY_UP:
#endif
		case 'K':
		case 'k':
			{
				int curr_unit = unit->unit_number;
				do {
					curr_unit--;
					if (curr_unit < 0)
						curr_unit = num_devices - 1;
				}
				while (device_info[curr_unit].status != UP);

				unit = &device_info[curr_unit];

				if (port >= (int) unit->nports)
					port = unit->nports - 1;
			}

			scr_opt = 1;
			break;

#ifdef KEY_DOWN
		case KEY_DOWN:
#endif
		case 'J':
		case 'j':
			{
				int curr_unit = unit->unit_number;
				do {
					if (curr_unit < num_devices - 1)
						curr_unit++;
					else
						curr_unit = 0;
				}
				while (device_info[curr_unit].status != UP);

				unit = &device_info[curr_unit];

				if (port >= (int) unit->nports)
					port = unit->nports - 1;

			}

			scr_opt = 1;
			break;

		case 'q':
		case 'Q':
		case ESC:
			hide_panel (GetPan(ChanWin));
			erase_win (ChanWin);
			update_panels ();
			doupdate ();
			scr_opt = 0;
			break;

		case 'T':
		case 't':
			scr_opt = 0;

			hide_panel (GetPan(ChanWin));
			update_panels ();
			doupdate ();

			handle_loopback(unit, &node, &chan, port);

			change_term (0, TIMEOUT);

			show_panel (GetPan(ChanWin));
			update_panels ();
			doupdate ();
			wrefresh (chanwin);
			break;

		case 'D':
		case 'd':
			scr_opt = 0;

			{
				int invoke_one = 1;

				while (invoke_one)
				{
					if (d_invokes_capture)
					{
						invoke_one = handle_scope (unit, &node,  &chan, port);
					}
					else
					{
						invoke_one = handle_exam (unit, &node, port);
					}

					if (invoke_one)
						d_invokes_capture = 1 - d_invokes_capture;
				}
			}

			touchwin (chanwin);
			wrefresh (chanwin);
			update_panels ();
			doupdate ();
			break;


#ifdef KEY_PRINT
		case KEY_PRINT:
#endif
		case '':
			scr_opt = 0;

			screen_save (ChanWin, logfile);
			touchwin (chanwin);
			wrefresh (chanwin);
			update_panels ();
			doupdate ();
			break;

		case KEY_F (1):		   /*  Help info  */
		case '?':
			scr_opt = 0;
			info_screen (dpa_info2, dpa_info2_len, NULL);
			update_panels ();
			doupdate ();
			break;

		default:
			scr_opt = 0;
			mvwprintw (chanwin, 16, 60, "Invalid key");
			wrefresh (chanwin);
			sleep (1);
			mvwprintw (chanwin, 16, 60, "           ");
			wrefresh (chanwin);
			break;
		}						   /* End Case */
	}							   /* End While */
}
Example #2
0
void go_plot_contours(
    char *device, char *title, char *xvar, char *yvar, char *topline,
    double **data, double xmin, double xmax, double ymin, double ymax,
    double dx, double dy, long nx, long ny,
    double *contour_level, long n_contours, long contour_label_interval,
    long contour_label_offset, long layout[2], long ix, long iy,
    char *shapes, int *pen, long flags, long pause_interval,
    SHAPE_DATA *shape, long nshapes, unsigned long long tsetFlags, double xlableScale, double ylabelScale)
{
    double map[4], average, spread;
    double pmin, pmax, qmin, qmax;
    double wpmin, wpmax=0, wqmin, wqmax=0;
    long title_at_top=0;
    char newLabel[50];
    time_t timeValue;

    if (!(flags&DEVICE_DEFINED)) 
      change_term(device, strlen(device));
    if ((ix == 0) && (iy == 0))
      graphics_on();
    if (layout[0] && layout[1]) {
      wpmin = (1.0*ix+0)/layout[0];
      wpmax = (1.0*ix+1)/layout[0];
      wqmin = (layout[1]*1.0 - 1 - iy)/layout[1];
      wqmax = (layout[1]*1.0 - 0 - iy)/layout[1];
      set_wspace(wpmin, wpmax, wqmin, wqmax);
      pmin = (wpmax - wpmin) * .15 + wpmin;
      pmax = wpmax - (wpmax - wpmin) * .1;
      qmin = (wqmax - wqmin) * .17 + wqmin;
      qmax = wqmax - (wqmax - wqmin) * .08;
      set_pspace(pmin, pmax, qmin, qmax);
    }

    if (contour_label_interval<0) {
      get_pspace(&pmin, &pmax, &qmin, &qmax);
      set_pspace(pmin, 0.9 * wpmax, qmin, 0.85 * wqmax);
    }
    if (flags&TITLE_AT_TOP) {
      /* adjust pspace to make room at top for the title */
      get_pspace(&pmin, &pmax, &qmin, &qmax);
      spread = qmax-qmin;
      qmax -= 0.04*spread;
      qmin -= 0.04*spread;
      /*    qmax -= 0.04;
            qmin -= 0.04;*/
      set_pspace(pmin, pmax, qmin, qmax);
      title_at_top = 1;
    }
    set_clipping(1, 1, 1);


    if (flags&EQUAL_ASPECT1) 
        set_aspect(1.0L);
    else if (flags&EQUAL_ASPECT_1)
        set_aspect(-1.0L);

    set_linetype(pen[0]);
    get_mapping(map, map+1, map+2, map+3);
    if (map[0]==map[1]) {
        average  = (xmax+xmin)/2;
        spread   = (xmax-xmin)/2;
        map[0]   = average - spread*1.05;
        map[1]   = average + spread*1.05;
        }
    if (map[2]==map[3]) {
        average  = (ymax+ymin)/2;
        spread   = (ymax-ymin)/2;
        map[2]   = average - spread*1.05;
        map[3]   = average + spread*1.05;
        }
    set_mapping(map[0], map[1], map[2], map[3]);
    get_pspace(&pmin, &pmax, &qmin, &qmax);
    get_wspace(&wpmin, &wpmax, &wqmin, &wqmax);

    if (!(flags&NO_BORDER)) {
      border();
      if (!(flags&NO_SCALES)) {
        if (tsetFlags&TICKSET_XTIME) {
          timeValue = map[0];
          if (timeValue!=DBL_MAX)
            sprintf(newLabel, "Time starting %s", ctime(&timeValue));
          else
            sprintf(newLabel, "Undefined time values!");
          delete_chars(newLabel, "\n");
          makeTimeScales(0, 0.02, 0, map[2], map[2], newLabel, 
                         0, 0.67*(qmin-wqmin)*(map[3]-map[2])/(qmax-qmin), 
                         0, 1, 1);
        } else {
          make_scales_with_label(0, 0, 1, 0.0, 0.02, 0.0, 
                                 0.0, 1.0, 0, 0, 
                                 0, 0, 0, 0, xvar, 0, 0, xlableScale);
        }
	if (!(flags&NO_YSCALES)) {
          if (tsetFlags&TICKSET_YTIME) {
            timeValue = map[2];
            if (timeValue!=DBL_MAX)
              sprintf(newLabel, "Time starting %s", ctime(&timeValue));
            else
              sprintf(newLabel, "Undefined time values!");
            delete_chars(newLabel, "\n");
            makeTimeScales(1, 0.0125, 0, map[0], map[0], newLabel, 
                           0, (pmin-wpmin)*(map[1]-map[0])/(pmax-pmin), 
                           0, 1, 1);
          } else {
            make_scales_with_label(1, 0, 1, 0.0, 0.0125, 0.0, 
                                   0.0, 1.0, 0, 0, 
                                   0, 0, 0, 0, yvar, 0, 0, ylabelScale);
          }
	}
      }
    }
    if (!(flags&NO_LABELS)) {
      plotTitle(title, 1, title_at_top, 1.0, 0.0, 0, 0);
      if (contour_label_interval>=0)
	plotTitle(topline, 0, 0, 1.0, 0.0, 0, 0);
    }
    set_linetype(pen[1]);
    draw_contours(data, xmin, xmax, ymin, ymax, nx, ny, contour_level, n_contours);
    if (contour_label_interval!=0) {
        set_linetype(pen[2]);
        label_contours(data, nx, ny, contour_level, n_contours,
            contour_label_interval, contour_label_offset,
            xmin, (double)dx, ymin, (double)dy);
        }
    set_linetype(pen[0]);

    if (nshapes)
      PlotShapesData(shape, nshapes, xmin, xmax, ymin, ymax);

    if (flags&DATE_STAMP)
        time_date_stamp();

    }
Example #3
0
void 
handle_loopback (struct deviceinfo *unit, struct digi_node *node, struct digi_chan *chan, int port)
{
	char full_line[81];

	int i = 0, option = EOF;

	struct termios sv_tios;
	char test_data[TBUFSIZ + 1];
	char read_data[TBUFSIZ + 1];
	char string[200], ttyname[200];

	int r = 3;
	int rwfd;

	WINDOW *lbwin = GetWin(LBWin);

#define TITLE_LINE  1
#define DESC_LINE   2
#define DESC2_LINE  3
#define SEP_LINE    4
#define FIRST_DATA  5
#define SEP2_LINE   15
#define RESULT_LINE 16

	show_panel (GetPan(LBWin));
	update_panels ();
	doupdate ();

	next_result = 0;
	test_cases = 0;
	test_passes = 0;

	if (DPAGetPortName(unit, node, chan, port, ttyname) == NULL) {
		ttyname[0] ='\0';
	}

	while (option == EOF)
	{
		erase_win (LBWin);
		wattrset (lbwin, make_attr (A_BOLD, WHITE, BLUE));
		mvwprintw (lbwin, TITLE_LINE,  1, "%-*.*s", 76, 76, " ");
		mvwprintw (lbwin, RESULT_LINE, 1, "%-*.*s", 76, 76, " ");
		mvwprintw (lbwin, TITLE_LINE, 32, " Loop Back Test ");
		sprintf (full_line, "Tests Executed: %-12d Passed: %-12d Failed: %d",
		         test_cases, test_passes, test_cases - test_passes);
		mvwprintw (lbwin, RESULT_LINE,
		           center(LBWin, strlen(full_line)), full_line);

		sprintf (clbuf, "Unit IP Address: %s       Port #: %d            Name: %s",
		         unit->host, port + 1, ttyname);
		i = strlen (clbuf);
		mvwprintw (GetWin(LBWin), DESC_LINE, 1, "%*s",
		           GetWidth(LBWin) - 2, " ");

		mvwprintw (GetWin(LBWin), DESC2_LINE, 1, "%*s",
		           GetWidth(LBWin) - 2, " ");

		mvwprintw (lbwin, DESC2_LINE, 2, clbuf);

		mvwprintw (lbwin, DESC_LINE, 2, "Device Description: %-*.*s",
		           GetWidth(LBWin) - 2 - 2 - 2 - 20,
		           GetWidth(LBWin) - 2 - 2 - 2 - 20,
		           node->nd_ps_desc);

		if (!vanilla)
			wattrset (lbwin, make_attr (A_ALTCHARSET, CYAN, BLACK));
		else
			wattrset (lbwin, make_attr (A_NORMAL, CYAN, BLACK));

		wmove (lbwin, SEP_LINE, 1);
		for (i = 0; i < 77; i++)
			waddch (lbwin, mapchar(ACS_HLINE));
		mvwaddch (lbwin, SEP_LINE, 0, mapchar(ACS_LTEE));
		mvwaddch (lbwin, SEP_LINE, 77, mapchar(ACS_RTEE));

		wmove (lbwin, SEP2_LINE, 1);
		for (i = 0; i < 77; i++)
			waddch (lbwin, mapchar(ACS_HLINE));
		mvwaddch (lbwin, SEP2_LINE, 0, mapchar(ACS_LTEE));
		mvwaddch (lbwin, SEP2_LINE, 77, mapchar(ACS_RTEE));

		wattrset (lbwin, make_attr (A_NORMAL, WHITE, BLACK));

		wrefresh (lbwin);

		wattrset (GetWin(MainWin), make_attr (A_NORMAL, WHITE, BLUE));
		commandline (clbuf, "Press ANY key to Halt the test", NULL);
		mvwprintw (GetWin(MainWin), KEY_LINE, 0, clbuf);
		wattroff (GetWin(MainWin), make_attr (A_NORMAL, WHITE, BLUE));
		wrefresh (GetWin(MainWin));

		change_term (0, 10);

		option = EOF;
		r = 5;

		if (chan->ch_open) {
			mvwprintw (lbwin, r++, 2, "***** Port is Busy.");
                        wrefresh(lbwin);
			test_cases++;
			sleep(1);
			goto user_input;
		}

		for (i = 0; i < 256; i++) {
			test_data[i] = (char) i;
		}

		test_data[TBUFSIZ]='\0';

		/* Get port name.  Can't run the test without it. */
		if (DPAGetPortName(unit, node, chan, port, ttyname) == NULL) {
                        mvwprintw (lbwin, r++, 2,
                        "***** Loop Back Test Failure. Port has no known tty name");
			test_cases++;
                        wrefresh (lbwin);
			sleep(1);
			goto user_input;
                }

		sprintf(string, "/dev/%s", ttyname);

		if( (rwfd = tty_open(string, &sv_tios )) < 0 ) {
			test_cases++;
			goto user_input;
		}

		tcflush(rwfd, TCIOFLUSH);

                if ((i = test_send (test_data, TBUFSIZ, rwfd)) != 0)
                {
                        mvwprintw (lbwin, r++, 2,
                        "***** Loop Back Test Failure=%d, Sending %d Bytes", i, TBUFSIZ);
                        wrefresh (lbwin);
                        tty_close (rwfd, &sv_tios);
                        test_cases++;
			goto user_input;
                }

                mvwprintw (lbwin, r++, 2, "Loop Back: %d Bytes Sent.", TBUFSIZ);
                wrefresh (lbwin);
                mvwprintw (lbwin, r++, 2, "Loop Back: Receiving %d Bytes.", TBUFSIZ);
                wrefresh (lbwin);

                if ((i = test_recv (read_data, TBUFSIZ, 5, rwfd)) != TBUFSIZ)
                {
                        mvwprintw (lbwin, r++, 2,
                                "***** Loop Back Failure=%d Receiving %d bytes.", i, TBUFSIZ);
                        wrefresh (lbwin);  
                        tty_close (rwfd, &sv_tios);
                        test_cases++;
			goto user_input;
                }


                /* Reset termios as before and close channel */
                tty_close (rwfd, &sv_tios);

                mvwprintw (lbwin, r++, 2, "Loop Back: Verifying %d bytes.", TBUFSIZ);
                wrefresh (lbwin);

                if (memcmp (test_data, read_data, TBUFSIZ))
                {
                        mvwprintw (lbwin, r++, 2,
                                "***** Loop Back Failure Verifying %d Bytes.", TBUFSIZ);
                        mvwprintw (lbwin, r++, 2, "***** Data Incorrectly Transferred.");
                        wrefresh (lbwin);
                        test_cases++;
			goto user_input;
                }
                else
                {
                        mvwprintw (lbwin, r++, 2, "Loop Back: Test Passed.");
                        wrefresh (lbwin);
                        test_cases++;
                        test_passes++;
                }


user_input:

		option = getch();


		/*
		 * If the user hasn't selected anything, loop.
		 * Otherwise, break.
		 */

		switch (option)
		{
		case EOF:
			break;

		case '':
			refresh_screen ();
			option = EOF;
			break;

#ifdef KEY_PRINT
		case KEY_PRINT:
#endif
		case '':
			screen_save (LBWin, logfile);
			touchwin (lbwin);
			wrefresh (lbwin);
			update_panels ();
			doupdate ();
			option = EOF;
			break;

		default:
			break;
		}						   /* End Case */
	}							   /* End While */

	hide_panel (GetPan(LBWin));
	update_panels ();
	doupdate ();
	return;
}