Exemplo n.º 1
0
/*! \brief User I/O
 *
 * @param ptr  pointer to Usertalk type
 */
void *user_io_thread (void* ptr) {
	Usertalk*                 user_info;
	user_info                 = (Usertalk*) ptr;

	int                       result;
	char                      str[MAX_USER_STRBUF];
	char                      keypress;

	sleep(2);
	fprintf(stderr, "\n");

	while(!user_exit_requested) {
		user_query_msg("(q)uit, (r)eset, (g)o, (s)top, (h)elp: ");
		fgets(str, sizeof(str), stdin);
		result = sscanf(str, "%c", &keypress );
		if(result < 1) {
			fprintf(stderr, "ERROR: Invalid entry\n");
			continue;
		}
		switch(keypress) {
			case 'q':
				log_msg("You typed q-quit\n");
				pthread_mutex_lock(&exit_request_mutex);
				user_exit_requested = true;
				pthread_mutex_unlock(&exit_request_mutex);
				break;
			case 'r':
				log_msg("You typed r-reset\n");
				send_reset_sensors_message(user_info);
				break;
			case 'g':
				log_msg("Log enabled by user.\n");
				pthread_mutex_lock(&log_enable_mutex);
				enable_logging = true;
				pthread_mutex_unlock(&log_enable_mutex);
				break;
			case 's':
				log_msg("Log disabled by user.\n\n");
				pthread_mutex_lock(&log_enable_mutex);
				enable_logging = false;
				pthread_mutex_unlock(&log_enable_mutex);
				break;
			case '\n':
				break;
			case 'h':
			case '?':
				user_help();
				break;
			default:
				fprintf(stderr, "ERROR: Unrecognized entry: '%c'\n",keypress);
				user_help();
				break;
		}
	}
}
Exemplo n.º 2
0
/// @param[in] str: User supplied command line 
/// 
/// @return 1 The ruturn code indicates a command matched.
/// @return 0 if no rules matched
MEMSPACE
int user_tests(char *str)
{

    int res;
    int len;
    char *ptr;
    long p1, p2;
	time_t t;

    ptr = skipspaces(str);

    if ((len = token(ptr,"help")) )
    {
        ptr += len;
        user_help();
        return(1);
    }
    if ((len = token(ptr,"setdate")) )
    {
        ptr += len;
		ptr = skipspaces(str);
        setdate_r(ptr);
        return(1);
    }
    if ((len = token(ptr,"time")) )
    {
		t = time(0);	
		DEBUG_PRINTF("TIME:%s\n", ctime(&t));
        return(1);
	}
	return(0);
}
Exemplo n.º 3
0
/*********************************************************************
 * print_help() - print help message and user help message
 *********************************************************************/
void print_help(void (*user_help) ())
{
	STD_opts_help();

	if (user_help)
		user_help();
}
Exemplo n.º 4
0
static void print_help(void (*user_help)(void))
{
	int i;

	for (i = 0; std_options[i].optstr; ++i) {
		if (std_options[i].help)
			printf("%s", std_options[i].help);
	}

	if (user_help)
		user_help();
}
Exemplo n.º 5
0
/// @param[in] str: User supplied command line 
/// 
/// @return 1 The return code indicates a command matched.
/// @return 0 if no rules matched
MEMSPACE
int user_tests(int argc, char *argv[])
{

    char *ptr;
	time_t t;
	double freq;
	extern int connections;
	int ind;

	if(argc < 2)
		return(0);

	ind = 1;
    ptr = argv[ind++];


    if (MATCHARGS(ptr,"help", (ind+0),argc ))
    {
        user_help();
        return(1);
    }
#ifdef POSIX_TESTS
	if(posix_tests(argc,argv))
		return(1);
#endif
#ifdef FATFS_TESTS
	if(fatfs_tests(argc,argv))
		return(1);
#endif
#ifdef ADF4351
    if (MATCHARGS(ptr,"adf4351", (ind + 1) ,argc))
    {
		adf4351_cmd(argc,argv);
		return(1);
	}
#endif
    if (MATCHARGS(ptr,"setdate", (ind + 1) ,argc))
    {
        setdate_r(argv[ind++]);
        return(1);
    }
    if (MATCHARGS(ptr,"display_clock", (ind + 0) ,argc))
    {
        display_clock();
        return(1);
    }
    if (MATCHARGS(ptr,"time", (ind + 0) ,argc))
    {
		t = time(0);	
		printf("TIME:%s\n", ctime(&t));
        return(1);
	}
    if (MATCHARGS(ptr,"connection", (ind + 0) ,argc))
    {
		printf("connections:%d\n", connections);
        return(1);
	}
    if (MATCHARGS(ptr,"mem", (ind + 0) ,argc))
    {
		PrintRam();
        return(1);
	}
    if (MATCHARGS(ptr,"timetest", (ind + 1) ,argc))
    {
		timetests(argv[ind++],0);
        return(1);
	}
#ifdef DISPLAY
    if (MATCHARGS(ptr,"calibrate", (ind + 1) ,argc))
    {
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		tft_touch_calibrate(master);
		MatWrite("/tft_calX",tft_calX);
		MatWrite("/tft_calY",tft_calY);
		setup_windows(ret & 3,0);
        return(1);
    }
    if (MATCHARGS(ptr,"calibrate_test", (ind + 1) ,argc))
    {
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		tft_touch_calibrate(master);
		MatWrite("/tft_calX",tft_calX);
		MatWrite("/tft_calY",tft_calY);
		tft_map_test(master, 10);
		setup_windows(ret & 3,0);
        return(1);
    }
    if (MATCHARGS(ptr,"rotate", (ind + 1) ,argc))
    {
// FIXME rotate calibration data ???
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		setup_windows(ret & 3,0);
		return(1);
    }
#ifdef VFONTS
    if (MATCHARGS(ptr,"draw", (ind + 1) ,argc))
    {
		char *ptr = argv[ind++];
		int c = *ptr++;
		int n = *ptr++;
		if( n == '1')

			drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 1);
		else
			drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 0);
		return(1);
    }
#endif
    if (MATCHARGS(ptr,"pixel", (ind + 0) ,argc))
    {
		int c;
		int x,y;

		tft_drawPixel(winmsg, 8, 24, ILI9341_WHITE);
		for(y=24;y<26;++y)
		{
			for(x=8;x<10;++x)
			{
				c = tft_readPixel(winmsg, x, y);
				printf("pixel(%d,%d): %04x\n", x,y,c);
			}
		}
		return(1);
    }
#endif	//DISPLAY
	return(0);
}