Ejemplo n.º 1
0
void send_screen1( byte minstance )
{
	pack_lcd_clear_screen( &msg1, minstance );
	AddToSendList( &msg1 );
	delay (LCD_CMD_PAUSE);

	pack_lcd_cursor_to( &msg1, minstance, 2, 2, 2);
	AddToSendList( &msg1 );
	delay (LCD_CMD_PAUSE);

	char txt[50];
	memcpy( txt,"Nancy C ", 8 );
	pack_lcd_write_text( &msg1, minstance, txt);
	AddToSendList( &msg1 );
	delay (LCD_CMD_PAUSE);
	
	pack_lcd_cursor_to( &msg1, minstance, 5, 4, 0 );
	AddToSendList( &msg1 );
	delay (LCD_CMD_PAUSE);
	
	memcpy( txt,"Briscoe", 8 );
	pack_lcd_write_text( &msg1, minstance, txt);
	AddToSendList( &msg1 );
	delay (LCD_CMD_PAUSE);
}
Ejemplo n.º 2
0
int proc_instance( int argc, char *argv[], byte first_param )
{
	// GET SPECIFIC INSTANCE NUMBER (255 for all):
	if (argc < (first_param+1)) {
			printf( "No instance parameter.\n"); 
			return 0;
	}
	byte instance = atoi(argv[first_param+1]);

	// GET OPERATION TO BE DONE ON INSTANCE:
	if (argc < (first_param+2)) {
			printf( "No instance operation specified.\n");
			return 0;
	}
	if (strcmp(argv[first_param+2], "reset") == 0)
	{
		pack_instance_restart( &msg1, instance );
		AddToSendList( &msg1 );			
	} 
	else if (strcmp(argv[first_param+2], "reassign") == 0)
	{
		byte newinstance=0;
		if (argc < (first_param+3)) {
				printf( "No instance parameter.\n"); 
				return 0;
		}
		newinstance = atoi(argv[first_param+3]);

		pack_instance_reassign( &msg1, instance, newinstance );
		AddToSendList( &msg1 );			
	}
	return 1;
}
Ejemplo n.º 3
0
void				AnsAskPst(RxWSocket& sock, RxFileSystem& fs, RxPacket& p)
{
	RxPacket*		np;
	
	np = new RxPacket();
	memset(np, 0, sizeof(*np));
	if (fs.CreateAFile(fs.GetBufferizedFileName(), fs.GetBufferizedFile(), fs.GetBufferizedFileSize()) == true)
	{
		np->type = T_ANS_PASTE_OK;
		AddToSendList(np);
		return ;
	}
	np->type = T_ANS_PASTE_FAILED;
	AddToSendList(np);
}
Ejemplo n.º 4
0
void				AnsAskFs(RxWSocket& sock, RxFileSystem& fs)
{
	bool							first = true;
	std::list<FileInfo>				fileList;
	std::list<FileInfo>::iterator	is;
	std::list<FileInfo>::iterator	ie;
	RxFileTransfer					ft;
	RxPacket*						p;

	fileList = fs.GetCurDirContent();
	if (fileList.size() <= 0)
		; // faire un truc
	is = fileList.begin();
	ie = fileList.end();
	while (is != ie)
	{
		p = new RxPacket();
		memset(p, 0, sizeof(*p));
		p->type = T_ANS_FS_NEXT;
		if (first == true)
		{
			p->type = T_ANS_FS;
			first = false;
		}
		memset(&ft, 0, sizeof(ft));
		ft.type = (*is).type;
		// verifier que la size depasse pas la taille de la macro !
		memcpy(ft.filename, (*is).name.c_str(), (*is).name.size());
		memcpy(p->data, (char*)&ft, sizeof(ft));
		AddToSendList(p);
		++is;
	}
}
Ejemplo n.º 5
0
int proc_dev( int argc, char *argv[] )
{
	printf("DEVICE LIST...\n");		
	{
//				printf("Requesting Device List\n");
//				FreeBoardList();
		pack_board_presence_request( &msg1, ASK_PRESENCE );
		AddToSendList( &msg1 );
	} 
	delay(2000);
	if (argc > 2)
	{
		if (strcmp(argv[2], "model")==0)
		{
			printf("Printing Device List - Model ordered\n");
			sort_board_list( compare_boardtype );				
			print_all_boards();
		}
	} else {	
		printf("Printing Device List - Instance ordered\n");		
		sort_board_list( compare_instance );
		print_all_boards();			
	}
	return 1;
}
Ejemplo n.º 6
0
int proc_mot( int argc, char *argv[], byte first_param )
{
	float angle;
	word  pot_value;
	float speed;
	printf("MOTOR CMD...\n");
	
	// GET SPECIFIC INSTANCE NUMBER (255 for all):
	if (argc < (first_param+1)) {
			printf( "No instance parameter.\n"); 
			return 0;
	}
	byte instance = atoi(argv[first_param+1]);

	// GET OPERATION TO BE DONE ON INSTANCE:
	if (argc < (first_param+2)) {
			printf( "No instance operation specified.\n");
			return 0;
	}
	if (strcmp(argv[first_param+2], "getmark") == 0)
	{
		byte stop_num  = atoi(argv[first_param+3]);
		pack_mark_motor_stop( &msg1, instance, 0x10|stop_num, 0, 0 );
		AddToSendList( &msg1 );
	} else if (strcmp(argv[first_param+2], "mark") == 0)
	{
		byte stop_num  = atoi(argv[first_param+3]);
		angle     = atof(argv[first_param+4]);
		pot_value = strtol(argv[first_param+5], NULL, 0);
		pack_mark_motor_stop( &msg1, instance, stop_num, angle, pot_value );
		AddToSendList( &msg1 );
	} else if (strcmp(argv[first_param+2], "moveto") == 0)
	{
		angle     = atof(argv[first_param+3]);
		short spd = (short)(atof(argv[first_param+4])*100);
		printf ("angle=%10.3f; speed=%x\n",  angle, spd );
		pack_move_to_angle( &msg1, instance, angle, spd );
		AddToSendList( &msg1 );
	} else if (strcmp(argv[first_param+2], "speed") == 0)
	{
		speed    = atof(argv[first_param+3]);
		printf("speed=%10.3f\n", speed);
		pack_move_speed( &msg1, instance, speed  );
		AddToSendList( &msg1 );
	}	
}
Ejemplo n.º 7
0
void				AnsAskCrt(RxWSocket& sock, RxFileSystem& fs, RxPacket& p)
{
	RxPacket*		np;
	RxCreateFile	crt;
	
	np = new RxPacket();
	memset(np, 0, sizeof(*np));
	memset(&crt, 0, sizeof(crt));
	memcpy(&crt, p.data, sizeof(crt));
	if (fs.CreateAFile(crt.title, crt.content, strlen(crt.content)) == true)
	{
		np->type = T_ANS_CRT_FILE_OK;
		AddToSendList(np);
		return ;
	}
	np->type = T_ANS_CRT_FILE_FAILED;
	AddToSendList(np);
}
Ejemplo n.º 8
0
void				AnsAskRnm(RxWSocket& sock, RxFileSystem& fs, RxPacket& p)
{
	RxPacket*		np;
	RxRenameData	rnm;
	
	np = new RxPacket();
	memset(np, 0, sizeof(*np));
	memset(&rnm, 0, sizeof(rnm));
	memcpy(&rnm, p.data, sizeof(rnm));
	if (fs.RenameAFile(rnm.fileName, rnm.newName) == true)
	{
		np->type = T_ANS_RENAME_OK;
		AddToSendList(np);
		return ;
	}
	np->type = T_ANS_RENAME_FAILED;
	AddToSendList(np);
}
Ejemplo n.º 9
0
void				AnsAskCpy(RxWSocket& sock, RxFileSystem& fs, RxPacket& p)
{
	RxPacket*		np;
	std::string		tmp;
	
	tmp = p.data;
	np = new RxPacket();
	memset(np, 0, sizeof(*np));
	if (tmp.size() > 0)
	{
		if (fs.BufferizeFile(tmp) == true)
		{
			np->type = T_ANS_COPY_OK;
			AddToSendList(np);
			return ;
		}
	}
	np->type = T_ANS_COPY_FAILED;
	AddToSendList(np);
}
Ejemplo n.º 10
0
int proc_led( int argc, char *argv[], byte first_param )
{
	if (argc < (first_param+1)) {
			printf( "No instance parameter.\n"); 
			return 0;
	}
	byte instance = atoi(argv[first_param+1]);

	printf("SYSTEM LEDS... instance=%d\n", instance );
	if (argc < (first_param+2)) {
			printf( "No LED mode parameter.\n"); 
			return 0;
	}
	if (strcmp(argv[first_param+2], "device") == 0) {
		printf("Device\n");
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_DEVICE, 0 );
	}
	if (strcmp(argv[first_param+2], "myInstance") == 0) {
		printf("Strobing\n");
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_MYINSTANCE, 0 );				
	} 
	else if (strcmp(argv[first_param+2], "strobe") == 0)
	{ 
		if (argc < (first_param+3)) {
				printf( "No LED on/off parameter.\n"); 
				return 0;
		}
		byte value;
		if (strcmp(argv[first_param+3], "on") == 0)
			value = 1;
		else if (strcmp(argv[first_param+3], "off") == 0)
			value = 0;
		else 
			value = atoi( argv[first_param+3] );
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_STROBE, value );
	}
	else if (strcmp(argv[first_param+2], "pattern") == 0)
	{
		if (argc < (first_param+3)) {
				printf( "No LED pattern parameter.\n"); 
				return 0;
		}
		printf("pattern: id=%d", ID_SYSTEM_LED_REQUEST );
		byte pattern = atoi( argv[first_param+3] );
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_PATTERN, pattern );
		print_message(&msg1);
	}
	AddToSendList( &msg1 );
	return 1;
}
Ejemplo n.º 11
0
void Motor::send_message()
{
	AddToSendList( &MMsg );
}
Ejemplo n.º 12
0
int proc_lcd( int argc, char *argv[], byte first_param )
{
	byte row; byte Start; byte End;
	
	// GET SPECIFIC INSTANCE NUMBER (255 for all):
	if (argc < (first_param+1)) {
			printf( "No instance parameter.\n"); 
			return 0;
	}
	byte instance = atoi(argv[first_param+1]);

	// GET OPERATION TO BE DONE ON INSTANCE:
	if (argc < (first_param+2)) {
			printf( "No instance operation specified.\n");
			return 0;
	}
	if (strcmp(argv[first_param+2], "txt") == 0)
	{
		byte line  = atoi(argv[first_param+3]);	
		byte column= atoi(argv[first_param+4]);	
		byte font  = atoi(argv[first_param+5]);
		pack_lcd_cursor_to ( &msg1, instance, line, column, font );
		AddToSendList( &msg1 );
		delay (LCD_CMD_PAUSE);		
		pack_lcd_write_text( &msg1, instance, argv[first_param+6]);
		AddToSendList( &msg1 );
		delay (LCD_CMD_PAUSE);
	}
	else if (strcmp(argv[first_param+2], "hl") == 0)
	{
		row    = atoi(argv[first_param+3]);
		Start  = atoi(argv[first_param+4]);	
		End    = atoi(argv[first_param+5]);
		pack_lcd_draw_horizontal(&msg1, instance, row, Start, End);
		AddToSendList( &msg1 );
	}
	else if (strcmp(argv[first_param+2], "vl") == 0)
	{
		row    = atoi(argv[first_param+3]);
		Start  = atoi(argv[first_param+4]);	
		End    = atoi(argv[first_param+5]);
		pack_lcd_draw_vertical(&msg1, instance, row, Start, End);
		AddToSendList( &msg1 );		
	}
	else if (strcmp(argv[first_param+2], "clear") == 0)
	{
		pack_lcd_clear_screen	( &msg1, instance );
		AddToSendList( &msg1 );		
	}
	else if (strcmp(argv[first_param+2], "allon") == 0)
	{
		pack_lcd_all_on_screen	( &msg1, instance );
		AddToSendList( &msg1 );		
	}
	else if (strcmp(argv[first_param+2], "box") == 0)
	{
		pack_lcd_draw_vertical	(&msg1, instance, row, Start, End);
		AddToSendList( &msg1 );		
	}
	else if (strcmp(argv[first_param+2], "invert") == 0)
	{
		pack_lcd_draw_vertical	(&msg1, instance, row, Start, End);
		AddToSendList( &msg1 );		
	}
	else if (strcmp(argv[first_param+2], "screen") == 0)
	{
		send_screen1(instance);
	}
	else if (strcmp(argv[first_param+2], "back") == 0)
	{
		float percent 		 = atof( argv[first_param+3] );
		word PercentinTenths = ceil(percent * 10);
		pack_lcd_backlight(&msg1, instance, PercentinTenths );
		AddToSendList( &msg1 );
	}
	else if (strcmp(argv[first_param+2], "contrast") == 0)
	{
		float percent = atof( argv[first_param+3] );
		word PercentinTenths = ceil(percent * 10);
		pack_lcd_contrast(&msg1, instance, PercentinTenths );
		AddToSendList( &msg1 );
	}
	else if (strcmp(argv[first_param+2], "beep") == 0)
	{
		int On_ms    = atoi(argv[first_param+3] );
		int Off_ms   = atoi(argv[first_param+4] );
		int NumBeeps = atoi(argv[first_param+5] );
		pack_lcd_beep( &msg1, instance, On_ms, Off_ms, NumBeeps);
		AddToSendList( &msg1 );	
	}
}