Esempio n. 1
0
/*
**	display_basic()
**
**	display the basic terminal definitions
*/
void
display_basic(void)
{
	put_str("Name: ");
	putln(ttytype);

	report_cap("\\r ^M (cr)", carriage_return);
	report_cap("\\n ^J (ind)", scroll_forward);
	report_cap("\\b ^H (cub1)", cursor_left);
	report_cap("\\t ^I (ht)", tab);
/*      report_cap("\\f ^L (ff)", form_feed);	*/
	if (newline) {
		/* OK if missing */
		report_cap("      (nel)", newline);
	}
	report_cap("      (clear)", clear_screen);
	if (!cursor_home && cursor_address) {
		report_cap("(cup) (home)", tparm(cursor_address, 0, 0));
	} else {
		report_cap("      (home)", cursor_home);
	}
#ifdef user9
	report_cap("ENQ   (u9)", user9);
#endif
#ifdef user8
	report_cap("ACK   (u8)", user8);
#endif

	sprintf(temp, "\nTerminal size: %d x %d.  Baud rate: %u.  Frame size: %d.%d",
		columns, lines,
		tty_baud_rate,
		tty_frame_size >> 1,
		(tty_frame_size & 1) * 5);
	putln(temp);
}
Esempio n. 2
0
/*
**	probe_enq_ok()
**
**	does the terminal do enq/ack handshaking?
*/
static void 
probe_enq_ok(void)
{
	int tc, len, ulen;

	put_str("Testing ENQ/ACK, standby...");
	fflush(stdout);
	can_test("u8 u9", FLAG_TESTED);

	tty_ENQ = user9 ? user9 : "\005";
	tc_putp(tty_ENQ);
	event_start(TIME_SYNC);	/* start the timer */
	read_key(tty_ACK, TTY_ACK_SIZE - 1);

	if (event_time(TIME_SYNC) > 400000 || tty_ACK[0] == '\0') {
		/* These characters came from the user.  Sigh. */
		tty_can_sync = SYNC_FAILED;
		ptext("\nThis program expects the ENQ sequence to be");
		ptext(" answered with the ACK character.  This will help");
		ptext(" the program reestablish synchronization when");
		ptextln(" the terminal is overrun with data.");
		ptext("\nENQ sequence from (u9): ");
		putln(expand(tty_ENQ));
		ptext("ACK received: ");
		putln(expand(tty_ACK));
		len = user8 ? strlen(user8) : 0;
		sprintf(temp, "Length of ACK %d.  Expected length of ACK %d.",
			(int) strlen(tty_ACK), len);
		ptextln(temp);
		if (len) {
			temp[0] = user8[len - 1];
			temp[1] = '\0';
			ptext("Terminating character found in (u8): ");
			putln(expand(temp));
		}
		return;
	}

	tty_can_sync = SYNC_TESTED;
	if ((len = strlen(tty_ACK)) == 1) {
		/* single character acknowledge string */
		ACK_terminator = tty_ACK[0];
		ACK_length = 4096;
		return;
	}
	tc = tty_ACK[len - 1];
	if (user8) {
		ulen = strlen(user8);
		if (tc == user8[ulen - 1]) {
			/* ANSI style acknowledge string */
			ACK_terminator = tc;
			ACK_length = 4096;
			return;
		}
	}
	/* fixed length acknowledge string */
	ACK_length = len;
	ACK_terminator = -2;
}
Esempio n. 3
0
/*
**	subtest_xt(test_list, status, ch)
**
**	(xt) glitch
*/
static void
subtest_xt(
	struct test_list *t,
	int *state,
	int *ch)
{
	int tabat;		/* the tab spacing we end up with */
	int cc;

	tabat = set_tab ? 8 : init_tabs;
	if (!over_strike && (tabat > 0)) {
		ptext("(xt) should not ");
		put_cr();
		ptext("(xt) should");
		cc = char_count;
		while (cc < 16) {
			putchp('\t');
			cc = ((cc / tabat) + 1) * tabat;
		}
		putln("be set.");
		sprintf(temp, "(xt) Destructive-tab is %s in the data base.",
			dest_tabs_magic_smso ? "true" : "false");
		ptextln(temp);
		generic_done_message(t, state, ch);
	}
}
Esempio n. 4
0
static void
report_cap(const char *tag, const char *s)
{				/* expand the cap or print *** missing *** */
	int i;

	ptext(tag);
	for (i = char_count; i < 13; i++) {
		putchp(' ');
	}
	put_str(" = ");
	if (s) {
		putln(expand(s));
	} else {
		putln("*** missing ***");
	}
}
Esempio n. 5
0
/**
 * Verify that the barometric pressure sensor can be initialised and that it is returning
 * data that looks approximately correct.
 */
static void
testBaro(void)
{
	int16_t	temperature;
	int32_t	pressure;

	puts("BMP085...");
	PIOS_BMP085_Init();
	puts(" init OK");

	PIOS_BMP085_StartADC(TemperatureConv);
	PIOS_BMP085_ReadADC();
	temperature = PIOS_BMP085_GetTemperature();
	puts(" temperature");
	if (temperature < 50) {
		print(" FAIL: undertemp(%d)", temperature);
	} else if (temperature > 500) {
		print(" FAIL: overtemp(%d)", temperature);
	} else {
		puts(" OK");
	}

	PIOS_BMP085_StartADC(PressureConv);
	PIOS_BMP085_ReadADC();
	pressure = PIOS_BMP085_GetPressure();
	puts(" pressure");
	if (pressure < 80000) {
		println(" FAIL: underpressure(%d)", pressure);
	} else if (pressure > 12000) {
		println(" FAIL: overpressure(%d)", pressure);
	} else {
		putln(" OK");
	}
}
Esempio n. 6
0
/**
 * Verify that the magnetometer can be initialised and that it is returning samples
 * at approximately the expected rate.
 */
static void
testMag(void)
{
	struct pios_hmc5883_data sample;
	int				samples;

	puts("HMC5883...");
	PIOS_HMC5883_Init();
	puts(" init OK");
#if 0
	/* don't do this for now - it makes the I2C bus sad */
	if (!PIOS_HMC5883_Test()) {
		putln(" FAIL: selftest");
		return;
	}
	puts(" selftest OK");
#endif

	samples = 0;
	for (int i = 0; i < 100; i++) {
		if (PIOS_HMC5883_NewDataAvailable()) {
			PIOS_HMC5883_ReadMag(&sample);
			samples++;
		}
		PIOS_DELAY_WaitmS(10);
	}
	puts(" sampling");
	if (samples < 10) {
		println(" FAIL: undersample(%d)", samples);
	} else if (samples > 20) {
		println(" FAIL: oversample(%d)", samples);
	} else {
		println(" OK", samples);
	}
}
Esempio n. 7
0
int putchar(const char c) {
    if (c == '\n') {
        putln();
    } else if (c == '\t') {
        x += TAB_WIDTH;
    } else {
        char attrib = (backcolor << 4) | (forecolor & 0x0f);
        volatile short *pos;
        pos = (short *) VGA_TEXT_BUFFER + (y * MAX_COLS + x);
        *pos = c | (attrib << 8);
        x++;
    }
    if (x >= MAX_COLS) {
        putln();
    }
    return c;
}
Esempio n. 8
0
/**
 * Module thread, should not return.
 */
static void testTask(void *parameters)
{
	// give the system 5s to stabilise
	vTaskDelay(5000 * portTICK_RATE_MS);

	putln("PX2 HARDWARE TEST");
	testPX2IO();

	testAccel();
	testGyro();
	testMag();
	testBaro();
	testEEPROM();

	for (;;) {

	}
}
Esempio n. 9
0
/*
**	funkey_prog(test_list, status, ch)
**
**	Test program function keys (pfx)
*/
static void
funkey_prog(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (pkey_xmit) {
	int i;
	int fk = 1;
	char mm[256];

	/* test program function key */
	sprintf(temp,
		"(pfx) Set function key %d to transmit abc\\n", fk);
	ptextln(temp);
	tc_putp(TPARM_2(pkey_xmit, fk, "abc\n"));
	sprintf(temp, "Hit function key %d\n", fk);
	ptextln(temp);

	memset(mm, 0, (size_t) 4);
	for (i = 0; i < 4; ++i) {
	    int cc = getchp(STRIP_PARITY);
	    if (cc == EOF)
		break;
	    mm[i] = (char) cc;
	}
	mm[i] = '\0';

	put_crlf();
	if (mm[0] != 'a' || mm[1] != 'b' || mm[2] != 'c') {
	    sprintf(temp, "Error string received was: %s", expand(mm));
	    ptextln(temp);
	} else {
	    putln("Thank you\n");
	}
	flush_input();
	if (key_f1) {
	    tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
	}
    } else {
	ptextln("Function key transmit (pfx), not present.");
    }
    generic_done_message(t, state, ch);
}
Esempio n. 10
0
/*
**	crum_clear(test_list, status, ch)
**
**	(clear) test Clear screen
*/
static void
crum_clear(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i;

	if (clear_screen) {
		for (i = lines; i > 1; i--) {
			putln("garbage");
		}
		put_clear();
		ptextln("This line should start in the home position.");
		ptext("The rest of the screen should be clear.  ");
	} else {
		ptextln("(clear) Clear screen is not defined.  ");
	}
	generic_done_message(t, state, ch);
}
Esempio n. 11
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);
}
Esempio n. 12
0
/*
**	subtest_in(test_list, status, ch)
**
**	(in) insert null glitch
*/
static void
subtest_in(
	struct test_list *t,
	int *state,
	int *ch)
{
	if (enter_insert_mode && exit_insert_mode) {
		ptextln("\nTesting (in) with (smir) and (rmir)");
		putln("\tIf these two lines line up ...");
		put_str("\tIf these two lines line up ...");
		put_cr();
		tc_putp(enter_insert_mode);
		putchp(' ');
		tc_putp(exit_insert_mode);
		ptext("\nthen (in) should be set.  ");
		sprintf(temp,
			"(in) Insert-null-glitch is %s in the data base.",
			insert_null_glitch ? "true" : "false");
		ptextln(temp);
		generic_done_message(t, state, ch);
	}
}
Esempio n. 13
0
/*
**	funkey_prog(test_list, status, ch)
**
**	Test program function keys (pfx)
*/
static void
funkey_prog(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, fk;
	char mm[256];

	fk = 1;	/* use function key 1 for now */
	if (pkey_xmit) {
		/* test program function key */
		sprintf(temp,
			"(pfx) Set function key %d to transmit abc\\n", fk);
		ptextln(temp);
		tc_putp(TPARM_2(pkey_xmit, fk, "abc\n"));
		sprintf(temp, "Hit function key %d\n", fk);
		ptextln(temp);
		for (i = 0; i < 4; ++i)
			mm[i] = (char) getchp(STRIP_PARITY);
		mm[i] = '\0';
		put_crlf();
		if (mm[0] != 'a' || mm[1] != 'b' || mm[2] != 'c') {
			sprintf(temp, "Error string received was: %s", expand(mm));
			ptextln(temp);
		} else {
			putln("Thank you\n");
		}
		flush_input();
		if (key_f1) {
			tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
		}
	} else {
		ptextln("Function key transmit (pfx), not present.");
	}
	generic_done_message(t, state, ch);
}
Esempio n. 14
0
/*
**	keys_tested(first-time, show-help, hex-output)
**
**	Display a list of the keys not tested.
*/
static void
keys_tested(
	       int first_time,
	       int show_help,
	       int hex_output)
{
    int i, l;
    char outbuf[256];

    alloc_strings();
    put_clear();
    tty_set();
    flush_input();
    if (got_labels) {
	putln("Function key labels:");
	for (i = 0; i < key_count; ++i) {
	    if (fk_label[i]) {
		sprintf(outbuf, "%s %s",
			fk_name[i] ? fk_name[i] : "??", fk_label[i]);
		put_columns(outbuf, (int) strlen(outbuf), 16);
	    }
	}
	put_newlines(2);
    }
    if (funk) {
	putln("The following keys are not defined:");
	for (i = 0; i < funk; ++i) {
	    put_columns(fk_unknown[i], fk_length[i], 16);
	}
	put_mode(exit_attribute_mode);
	put_newlines(2);
    }
    if (first_time) {
	putln("The following keys are defined:");
    } else {
	putln("The following keys have not been tested:");
    }
    if (scan_mode) {
	for (i = 0; scan_down[i]; i++) {
	    if (!scan_tested[i]) {
		if (hex_output) {
		    strcpy(outbuf, hex_expand_to(scan_down[i], 3));
		} else {
		    strcpy(outbuf, expand(scan_down[i]));
		}
		l = expand_chars;
		if (hex_output) {
		    strcat(outbuf, hex_expand_to(scan_up[i], 3));
		} else {
		    strcat(outbuf, expand(scan_up[i]));
		}
		expand_chars += l;
		l = (int) strlen(scan_name[i]);
		if (((char_count + 16) & ~15) +
		    ((expand_chars + 7) & ~7) + l >= columns) {
		    put_crlf();
		} else if (char_count + 24 > columns) {
		    put_crlf();
		} else if (char_count) {
		    putchp(' ');
		}
		put_columns(outbuf, expand_chars, 16);
		put_columns(scan_name[i], l, 8);
	    }
	}
    } else {
	for (i = 0; i < key_count; i++) {
	    if (!fk_tested[i] && fk_name[i] != 0) {
		if (hex_output) {
		    strcpy(outbuf, hex_expand_to(fkval[i], 3));
		} else {
		    strcpy(outbuf, expand(fkval[i]));
		}
		l = (int) strlen(fk_name[i]);
		if (((char_count + 16) & ~15) +
		    ((expand_chars + 7) & ~7) + l >= columns) {
		    put_crlf();
		} else if (char_count + 24 > columns) {
		    put_crlf();
		} else if (char_count) {
		    putchp(' ');
		}
		put_columns(outbuf, expand_chars, 16);
		put_columns(fk_name[i], l, 8);
	    }
	}
    }
    put_newlines(2);
    if (show_help) {
	ptextln("Hit any function key.  Type 'end' to quit.  Type ? to update the display.");
	put_crlf();
    }
}
Esempio n. 15
0
/**
 * Verify that the EEPROM can be read and written.
 */
static void
testEEPROM(void)
{
	puts("EEPROM...");
	PIOS_EEPROM_Init();
	putln(" init done");

//	UAVObjHandle handle = ActuatorSettingsHandle();
//	  ObjectList *objEntry = (ObjectList *) obj;
//
//	  if (objEntry == NULL)
//		    return -1;
//
//	  ObjectInstList *instEntry = getInstance(objEntry, instId);
//
//	  if (instEntry == NULL)
//		    return -1;
//
//	  if (instEntry->data == NULL)
//		    return -1;
//
//	  if (PIOS_FLASHFS_ObjSave(obj, instId, instEntry->data) != 0)
//		    return -1;
//
//	uint8_t	saved[4];
//	uint8_t	buf[4];
//	uint32_t addr;
//
//	addr = PIOS_I2C_EEPROM_SIZE - 4;
//
//	if (!PIOS_EEPROM_Read(addr, saved, 4)) {
//		putln("FAIL: backup");
//		return;
//	}
//	puts(" backup OK");
//	buf[0] = ~saved[0];
//	buf[1] = ~saved[1];
//	buf[2] = ~saved[2];
//	buf[3] = ~saved[3];
//	if (!PIOS_EEPROM_Write(addr, buf, 4)) {
//		putln(" FAIL: write");
//		return;
//	}
//	puts(" write OK");
//	buf[0] = buf[1] = buf[2] = buf[3] = 0x5a;
//	if (!PIOS_EEPROM_Read(addr, buf, 4)) {
//		putln("FAIL: readback");
//		return;
//	}
//	if ((buf[0] != (uint8_t)~saved[0]) ||
//		(buf[1] != (uint8_t)~saved[1]) ||
//		(buf[2] != (uint8_t)~saved[2]) ||
//		(buf[3] != (uint8_t)~saved[3])) {
//		println(" FAIL: miscompare (read:expect) %02x:%02x %02x:%02x %02x:%02x %02x:%02x",
//				buf[0], (uint8_t)~saved[0],
//				buf[1], (uint8_t)~saved[1],
//				buf[2], (uint8_t)~saved[2],
//				buf[3], (uint8_t)~saved[3]);
//		return;
//	}
//	puts(" compare OK");
//	if (!PIOS_EEPROM_Write(addr, saved, 4)) {
//		putln(" FAIL: restore");
//		return;
//	}
//	putln(" restore OK");
}