void ShowTaskInfo(Serial *serial, unsigned int argc, char **argv)
{
    putHeader(serial, "Task Info");

    serial->put_s("Status\tPri\tStackHR\tTask#\tName");
    put_crlf(serial);

    /*
     * Memory info from vTaskList can be misleading.  See
     * http://www.freertos.org/uxTaskGetSystemState.html for
     * more detail about how it works and value meanings.
     */
    char *taskList = (char *) portMalloc(1024);
    if (NULL != taskList) {
        vTaskList(taskList);
        serial->put_s(taskList);
        portFree(taskList);
    } else {
        serial->put_s("Out of Memory!");
    }
    put_crlf(serial);

    put_crlf(serial);
    serial->put_s("[Note] StackHR: If StackHR < 0; then stack smash");
    put_crlf(serial);
}
Beispiel #2
0
/*
**	verify_time()
**
**	verify that the time tests are ready to run.
**	If the baud rate is not set then compute it.
*/
void
verify_time(void)
{
	int status, ch;

	if (tty_can_sync == SYNC_FAILED) {
		return;
	}
	probe_enq_ok();
	put_crlf();
	if (tty_can_sync == SYNC_TESTED) {
		put_crlf();
		if (ACK_terminator >= 0) {
			ptext("ACK terminating character: ");
			temp[0] = ACK_terminator;
			temp[1] = '\0';
			ptextln(expand(temp));
		} else {
			sprintf(temp, "Fixed length ACK, %d characters",
				ACK_length);
			ptextln(temp);
		}
	}
	if (tty_baud_rate == 0) {
		sync_home(&sync_test_list[0], &status, &ch);
	}
}
static void putHeader(const Serial *serial, const char *str)
{
    put_crlf(serial);
    serial->put_s("- - - ");
    serial->put_s(str);
    serial->put_s(" - - -");
    put_crlf(serial);
}
void show_welcome(Serial *serial){
	put_crlf(serial);
	size_t len = strlen(welcomeMsg);
	send_header(serial, len);
	serial->put_s(welcomeMsg);
	put_crlf(serial);
	send_header(serial, len);
	put_crlf(serial);
	show_help(serial);
}
void ShowStats(Serial *serial, unsigned int argc, char **argv){

	serial->put_s("== Memory Info ==\r\n");
	unsigned long heap = (unsigned long)_heap_address;
	unsigned long lastPointer = getLastPointer();
	serial->put_s("Heap address         :");
	put_uint(serial, heap);
	put_crlf(serial);
	serial->put_s("Last pointer address :");
	put_uint(serial, lastPointer);
	put_crlf(serial);
	serial->put_s("Heap size            :");
	put_uint(serial, (unsigned int)&_CONFIG_HEAP_SIZE);
	put_crlf(serial);
	serial->put_s("Estimated Usage      :");
	put_uint(serial, lastPointer - heap);
	put_crlf(serial);
	serial->put_s("== Lua Info ==\r\n");
	lua_State *L = getLua();
	lua_gc(L,LUA_GCCOLLECT,0);
	serial->put_s("Lua Top              :");
	put_int(serial, lua_gettop(L));
	put_crlf(serial);
	serial->put_s("Lua GC Count         :");
	put_int(serial, lua_gc(L,LUA_GCCOUNT,0));
	put_crlf(serial);
	serial->put_s("== Misc ==\r\n");
	serial->put_s("sizeof LoggerConfig  :");
	put_int(serial, sizeof(LoggerConfig));
	put_crlf(serial);
	serial->put_s("sizeof SampleRecord  :");
	put_int(serial, sizeof(SampleRecord));
	put_crlf(serial);
}
Beispiel #6
0
/*
**	funkey_meta(test_list, status, ch)
**
**	Test meta key (km) (smm) (rmm)
*/
static void
funkey_meta(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (has_meta_key) {
	int i, j, k, len;
	char outbuf[256];

	put_crlf();
	if (char_mask != ALLOW_PARITY) {
	    if (tty_meta_prep()) {
		ptext("\nHit any key to continue > ");
		(void) wait_here();
		put_crlf();
	    }
	}
	ptext("Begin meta key test. (km) (smm) (rmm)  Hit any key");
	ptext(" with the meta key.  The character will be");
	ptext(" displayed in hex.  If the meta key is working");
	ptext(" then the most significant bit will be set.  Type");
	ptextln(" 'end' to exit.");
	tty_raw(1, ALLOW_PARITY);
	tc_putp(meta_on);

	for (i = j = k = len = 0; i != 'e' || j != 'n' || k != 'd';) {
	    i = j;
	    j = k;
	    k = getchp(ALLOW_PARITY);
	    if (k == EOF) {
		break;
	    }
	    if ((len += 3) >= columns) {
		put_crlf();
		len = 3;
	    }
	    sprintf(outbuf, "%02X ", k);
	    put_str(outbuf);
	    k &= STRIP_PARITY;
	}
	tc_putp(meta_off);
	put_crlf();
	tty_set();
	put_crlf();
    } else {
	ptext("(km) Has-meta-key is not set.  ");
    }
    generic_done_message(t, state, ch);
}
Beispiel #7
0
/*
**	put_new_lines(count)
**
**	Send a number of newlines. (nel)
*/
void
put_newlines(int n)
{
	while (n-- > 0) {
		put_crlf();
	}
}
Beispiel #8
0
/*
**	crum_os(test_list, status, ch)
**
**	(cup) test Cursor position on overstrike terminals
*/
static void
crum_os(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i;

	if (cursor_address && over_strike) {
		put_clear();
		for (i = 0; i < columns - 2; i++) {
			tc_putch('|');
		}
		for (i = 1; i < lines - 2; i++) {
			put_crlf();
			tc_putch('_');
		}
		for (i = 0; i < columns - 2; i++) {
			tputs(TPARM_2(cursor_address, 0, i), lines, tc_putch);
			tc_putch('+');
		}
		for (i = 0; i < lines - 2; i++) {
			tputs(TPARM_2(cursor_address, i, 0), lines, tc_putch);
			tc_putch(']');
			tc_putch('_');
		}
		go_home();
		put_newlines(3);
		ptext("    All the characters should look the same.  ");
		generic_done_message(t, state, ch);
		put_clear();
	}
}
Beispiel #9
0
/*
**	show_cap_results(index)
**
**	Display the previous results
*/
static void
show_cap_results(
	int x)
{
	struct test_results *r;		/* a result */
	int delay;

	if ((r = pads[x])) {
		sprintf(temp, "(%s)", strnames[x]);
		ptext(temp);
		while (r) {
			sprintf(temp, "$<%d>", r->delay / 1000);
			put_columns(temp, strlen(temp), 10);
			r = r->next;
		}
		r = pads[x];
		while (r) {
			if (r->reps > 1) {
				delay = r->delay / (r->reps * 100);
				sprintf(temp, "$<%d.%d*>", delay / 10, delay % 10);
				put_columns(temp, strlen(temp), 10);
			}
			r = r->next;
		}
		put_crlf();
	}
}
Beispiel #10
0
static void
line_pattern(void)
{				/* put up a pattern that will help count the
				   number of lines */
    int i;

    put_clear();
    if (over_strike) {
	for (i = 0; i < 100; i++) {
	    int j;

	    if (i) {
		put_crlf();
	    }
	    for (j = i / 10; j; j--) {
		put_this(' ');
	    }
	    put_this('0' + ((i + 1) % 10));
	}
    } else {			/* I assume it will scroll */
	for (i = 100; i; i--) {
	    sprintf(temp, "\r\n%d", i);
	    put_str(temp);
	}
    }
}
Beispiel #11
0
void
ptextln(const char *s)
{				/* print the text using ptext() then add a CR
				   LF */
	ptext(s);
	put_crlf();
}
void ShowTaskInfo(Serial *serial, unsigned int argc, char **argv){

	serial->put_s("Task Info");
	put_crlf(serial);
	serial->put_s("Status\tPri\tStack\tTask#\tName");
	put_crlf(serial);
	char *taskList = (char *)portMalloc(1024);
	if (NULL != taskList){
		vTaskList(taskList);
		serial->put_s(taskList);
		portFree(taskList);
	}
	else{
		serial->put_s("Out of Memory!");
	}
	put_crlf(serial);
}
Beispiel #13
0
/*
**	subtest_msgr(test_list, status, ch)
**
**	(msgr) move in sgr mode
*/
static void
subtest_msgr(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i;

	if (cursor_address &&
		((enter_standout_mode && exit_standout_mode) ||
		(enter_alt_charset_mode && exit_alt_charset_mode))) {
		put_crlf();
		i = line_count + 1;
		tputs(tparm(cursor_address, i, 0), lines, tc_putch);
		put_mode(enter_alt_charset_mode);
		put_crlf();
		/*
		   some versions of the wy-120 can not clear lines or
		   screen when in alt charset mode.  If (el) and (ed)
		   are defined then I can test them.  If they are not
		   defined then they can not break (msgr)
		*/
		tc_putp(clr_eos);
		tc_putp(clr_eol);
		put_mode(exit_alt_charset_mode);
		put_mode(enter_standout_mode);
		putchp('X');
		tputs(tparm(cursor_address, i + 2, 1), lines, tc_putch);
		putchp('X');
		tputs(tparm(cursor_address, i + 3, 2), lines, tc_putch);
		putchp('X');
		tputs(tparm(cursor_address, i + 4, 3), lines, tc_putch);
		putchp('X');
		put_mode(exit_standout_mode);
		put_crlf();
		tc_putp(clr_eos);	/* OK if missing */
		put_crlf();
		ptextln("If you see a diagonal line of standout X's then (msgr) should be true.  If any of the blanks are standout then (msgr) should be false.");
		sprintf(temp, "(msgr) Move-in-SGR-mode is %s in the data base",
			move_standout_mode ? "true" : "false");
		ptextln(temp);
	} else {
		ptextln("(smso) (rmso) (smacs) (rmacs) missing; (msgr) Move-in-SGR-mode not tested.");
	}
	generic_done_message(t, state, ch);
}
void GetVersion(Serial *serial, unsigned int argc, char **argv)
{
    putHeader(serial, "Version Info");
    put_nameString(serial, "major", MAJOR_REV_STR);
    put_nameString(serial, "minor", MINOR_REV_STR);
    put_nameString(serial, "bugfix", BUGFIX_REV_STR);
    put_nameString(serial, "serial", cpu_get_serialnumber());
    put_crlf(serial);
}
Beispiel #15
0
/*
**	page_loop()
**
**	send CR/LF or go home and bump letter
*/
void
page_loop(void)
{
	if (line_count + 2 >= lines) {
		NEXT_LETTER;
		go_home();
	} else {
		put_crlf();
	}
}
void ExecLuaInterpreter(Serial *serial, unsigned int argc, char **argv)
{

    g_interactive_mode = 1;
    serial->put_s("Entering Lua Interpreter. enter 'exit' to leave");
    put_crlf(serial);

    lua_State *L = getLua();

    cmd_context *cmdContext = get_command_context();
    char * luaLine = cmdContext->lineBuffer;

    int result;
    while(1) {
        serial->put_s("> ");
        interactive_read_line(serial, luaLine, cmdContext->lineBufferSize);
        if (strcmp(luaLine,"exit") == 0) break;
        lockLua();
        lua_gc(L,LUA_GCCOLLECT,0);
        result = luaL_loadbuffer(L, luaLine, strlen(luaLine), "");
        if (0 != result) {
            serial->put_s("error: (");
            serial->put_s(lua_tostring(L,-1));
            serial->put_s(")");
            put_crlf(serial);
            lua_pop(L,1);
        } else {
            lua_pushvalue(L,-1);
            result = lua_pcall(L,0,0,0);
            if (0 != result) {
                serial->put_s("error: (");
                serial->put_s(lua_tostring(L,-1));
                serial->put_s(")");
                put_crlf(serial);
                lua_pop(L,1);
            }
            lua_pop(L,1);
        }
        unlockLua();
    }
    g_interactive_mode = 0;
}
Beispiel #17
0
/*
**	subtest_ul(test_list, status, ch)
**
**	test transparent underline (ul)
*/
static void
subtest_ul(
	struct test_list *t,
	int *state,
	int *ch)
{
	if (!over_strike) {
		/* (ul) is used only if (os) is reset */
		put_crlf();
		sprintf(temp, "This text should %sbe underlined.",
			transparent_underline ? "" : "not ");
		uprint(temp);
		put_crlf();
		ptextln("If the above line is not underlined the (ul) should be false.");
		sprintf(temp, "(ul) Transparent-underline is %s in the data base",
			transparent_underline ? "true" : "false");
		ptextln(temp);
		generic_done_message(t, state, ch);
	}
}
static void show_help(Serial *serial){
	serial->put_s("Available Commands:");
	put_crlf(serial);
	put_crlf(serial);

	const cmd_t * cmd = commands;
	while (cmd->cmd != NULL){
		serial->put_s(cmd->cmd);
		int padding = menuPadding - strlen(cmd->cmd);
		while (padding-- > 0) serial->put_s(" ");
		serial->put_s(": ");
		serial->put_s(cmd->help);
		serial->put_s(" ");
		serial->put_s("Usage: ");
		serial->put_s(cmd->cmd);
		serial->put_s(" ");
		serial->put_s(cmd->paramHelp);
		put_crlf(serial);
		cmd++;
	}
}
Beispiel #19
0
/*
**	dump_test_stats(test_list, status, ch)
**
**	Dump the statistics about the last test
*/
void
dump_test_stats(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, j;
	char tbuf[32];
	int x[32];

	put_crlf();
	if (tx_source && tx_source->caps_done) {
		cap_index(tx_source->caps_done, x);
		if (x[0] >= 0) {
			sprintf(temp, "Caps summary for (%s)",
				tx_source->caps_done);
			ptextln(temp);
			for (i = 0; x[i] >= 0; i++) {
				show_cap_results(x[i]);
			}
			put_crlf();
		}
	}
	sprintf(tbuf, "%011u", usec_run_time);
	sprintf(temp, "Test time: %d.%s, characters per second %d, characters %d",
		usec_run_time / 1000000, &tbuf[5], tx_cps, tx_characters);
	ptextln(temp);
	for (i = 0; i < txp; i++) {
		if ((j = get_string_cap_byvalue(tx_cap[i])) >= 0) {
			sprintf(tbuf, "(%s)", strnames[j]);
		} else {
			strcpy(tbuf, "(?)");
		}
		sprintf(temp, "%8d  %3d  $<%3d>  %8s %s",
			tx_count[i], tx_affected[i], tx_delay[i],
			tbuf, expand(tx_cap[i]));
		putln(temp);
	}
	generic_done_message(t, state, ch);
}
Beispiel #20
0
void
put_columns(const char *s, int len, int w)
{				/* put out s in column format */
	int l;

	if (char_count + w > columns) {
		put_crlf();
	}
	l = char_count % w;
	if (l) {
		while (l < w) {
			putchp(' ');
			l++;
		}
	}
	if (char_count && char_count + len >= columns) {
		put_crlf();
	}
	l = char_count;
	put_str(s);
	char_count = l + len;
}
Beispiel #21
0
/*
**	sync_test(menu)
**
**	Run at the beginning of the pad tests and function key tests
*/
void
sync_test(
	struct test_menu *menu)
{
	control_init();
	if (tty_can_sync == SYNC_NOT_TESTED) {
		verify_time();
	}
	if (menu->menu_title) {
		put_crlf();
		ptextln(menu->menu_title);
	}
}
Beispiel #22
0
/*
**	subtest_bw(test_list, status, ch)
**
**	test auto left margin (bw)
*/
static void
subtest_bw(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, j;

	if (over_strike) {
		/* test (bw) */
		ptext("\n(bw) should ");
		i = char_count;
		ptextln("not be set.");
		for (j = i; j < columns; j++)
			put_str("\b");
		put_str("@@@");
		put_crlf();
		sprintf(temp, "(bw) Auto-left-margin is %s in the data base",
			auto_left_margin ? "true" : "false");
		ptextln(temp);
	} else {
		/* test (bw) */
		ptextln("(bw) should not be set.");
		for (i = 12; i < columns; i++)
			put_str("\b");
		if (delete_character) {
			for (i = 0; i < 4; i++)
				tc_putp(delete_character);
		} else {
			put_str("   ");
		}
		put_crlf();
		sprintf(temp, "(bw) Auto-left-margin is %s in the data base",
			auto_left_margin ? "true" : "false");
		ptextln(temp);
	}
	generic_done_message(t, state, ch);
}
Beispiel #23
0
static void
fresh_line(void)
{				/* clear the line for a new function key line */
    if (over_strike) {
	put_crlf();
    } else {
	put_cr();
	if (clr_eol) {
	    tc_putp(clr_eol);
	} else {
	    put_str("                    \r");
	}
    }
}
Beispiel #24
0
/*
**	crum_home(test_list, status, ch)
**
**	(home) test Home cursor
*/
static void
crum_home(
	struct test_list *t,
	int *state,
	int *ch)
{
	if (cursor_home) {
		put_clear();
		put_newlines(lines / 2);
		go_home();
		put_crlf();
		ptext("The bottom line should have text.");
		go_home();
		put_newlines(lines - 1);
		ptext("This line is on the bottom.");
		go_home();
		ptextln("This line starts in the home position.");
		put_crlf();
	} else {
		ptextln("(home) Home cursor is not defined.  ");
	}
	generic_done_message(t, state, ch);
}
Beispiel #25
0
/*
**	putchp(character)
**
**	Send one character to the terminal.
**	This function does translation of control characters.
*/
void
putchp(int c)
{
	switch (c) {
	case '\b':
		if (translate_mode && cursor_left) {
			tt_putp(cursor_left);
		} else {
			tt_putp(TM_cursor_left);
		}
		char_count--;
		break;
	case 7:
		if (translate_mode && bell) {
			tt_putp(bell);
		} else {
			tt_putp(TM_bell);
		}
		break;
	case '\f':
		if (translate_mode && form_feed) {
			tt_putp(form_feed);
		} else {
			tt_putp(TM_form_feed);
		}
		char_count = 0;
		line_count++;
		break;
	case '\n':
		put_crlf();
		break;
	case '\r':
		put_cr();
		break;
	case '\t':
		if (translate_mode && tab) {
			tt_putp(tab);
		} else {
			tt_putp(TM_tab);
		}
		char_count = ((char_count / 8) + 1) * 8;
		break;
	default:
		put_this(c);
		char_count++;
		break;
	}
}
Beispiel #26
0
/*
**	sync_summary(test_list, status, ch)
**
**	Print out the test results.
*/
static void
sync_summary(
	struct test_list *t,
	int *state,
	int *ch)
{
	char size[32];

	put_crlf();
	ptextln("Terminal  size    characters/sec linefeeds/sec  clears/sec");
	sprintf(size, "%dx%d", columns, lines);
	sprintf(temp, "%-10s%-11s%11d   %11d %11d", tty_basename, size,
		tty_cps, tty_newline_rate, tty_clear_rate);
	ptextln(temp);
	generic_done_message(t, state, ch);
}
Beispiel #27
0
/*
**	ptext(string)
**
**	Output a string but do not assume the terminal will wrap to a
**	new line.  Break the line at a word boundary then send a CR LF.
**	This is more esthetic on 40 column terminals.
*/
void
ptext(const char *s)
{
	const char *t;

	while (*s) {
		for (t = s + 1; *t > ' '; t++);
		if ((char_count != 0) && ((t - s) + char_count >= columns)) {
			put_crlf();
			while (*s == ' ')
				s++;
		}
		while (s < t) {
			putchp(*s++);
		}
	}
}
Beispiel #28
0
int
tty_sync_error(void)
{
	int ch, trouble, ack;

	trouble = FALSE;
	for (;;) {
		tt_putp(tty_ENQ);	/* send ENQ */
		ch = getnext(STRIP_PARITY);
		event_start(TIME_SYNC);	/* start the timer */

		/*
		   The timer doesn't start until we get the first character.
		   After that I expect to get the remaining characters of
		   the acknowledge string in a short period of time.  If
		   that is not true then these characters are coming from
		   the user and we need to send the ENQ sequence out again.
		*/
		for (ack = 0; ; ) {
			if (ack < TTY_ACK_SIZE - 2) {
				tty_ACK[ack] = ch;
				tty_ACK[ack + 1] = '\0';
			}
			if (ch == ACK_terminator) {
				return trouble;
			}
			if (++ack >= ACK_length) {
				return trouble;
			}
			ch = getnext(STRIP_PARITY);
			if (event_time(TIME_SYNC) > 400000) {
				break;
			}
		}

		set_attr(0);	/* just in case */
		put_crlf();
		if (trouble) {
			/* The terminal won't sync.  Life is not good. */
			return TRUE;
		}
		put_str(" -- sync -- ");
		trouble = TRUE;
	}
}
Beispiel #29
0
/*
**	send_info_string(str)
**
**	Return the terminfo string prefixed by the correct separator
*/
static void
send_info_string(
	const char *str,
	int *ch)
{
	int len;

	if (display_lines == -1) {
		return;
	}
	len = strlen(str);
	if (len + char_count + 3 >= columns) {
		if (start_display == 0) {
			put_str(",");
		}
		put_crlf();
		if (++display_lines > lines) {
			ptext("-- more -- ");
			*ch = wait_here();
			if (*ch == 'q') {
				display_lines = -1;
				return;
			}
			display_lines = 0;
		}
		if (len >= columns) {
			/* if the terminal does not (am) then this loses */
			if (columns) {
				display_lines += ((strlen(str) + 3) / columns) + 1;
			}
			put_str("   ");
			put_str(str);
			start_display = 0;
			return;
		}
		ptext("   ");
	} else
	if (start_display == 0) {
		ptext(", ");
	} else {
		ptext("   ");
	}
	ptext(str);
	start_display = 0;
}
Beispiel #30
0
/*
**	pad_standard(test_list, status, ch)
**
**	Run a single cap pad test.
*/
static void
pad_standard(
	struct test_list *t,
	int *state,
	int *ch)
{
	const char *long_name;
	char *cap;
	int l = 2, i;
	char tbuf[128];

	if ((cap = get_string_cap_byname(t->caps_done, &long_name))) {
		sprintf(tbuf, "(%s) %s, start testing", t->caps_done,
			long_name);
		if (skip_pad_test(t, state, ch, tbuf)) {
			return;
		}
		i = 1;
		pad_test_startup(1);
		do {
			if (i >= columns) {
				page_loop();
				l++;
				i = 1;
			}
			tt_putp(cap);
			putchp(letter);
			i++;
		} while(still_testing());
		pad_test_shutdown(t, 0);
		if (l >= lines) {
			home_down();
		} else {
			put_crlf();
		}
		ptextln(no_visual);
	} else {
		CAP_NOT_FOUND;
		/* Note: get_string_cap_byname() always sets long_name */
		sprintf(temp, "(%s) %s, not present.  ", t->caps_done,
			long_name);
		ptext(temp);
	}
	pad_done_message(t, state, ch);
}