int main (int argc, char *argv[])
{        
	int val;


	printf("  ______________________________________  \n");
	printf(" |                                      | \n");
	printf(" |       VMOD-TTL Testing program       | \n");
	printf(" |______________________________________| \n");
	printf(" |                                      | \n");
	printf(" | Created by: Samuel I. Gonsalvez      | \n");
	printf(" | Email: [email protected]              | \n");
	printf(" |______________________________________| \n");
	printf("\n");
	printf("%s\n", git_version);
	printf("%s\n", libvmod_version_s);

	if (argc == 2)
	{
		device = atoi(argv[1]);
	}
	else
	{
		printf("\n Please use: test_read_write <lun_of_the_device>.\n");
		exit(-1);
	}

	if(vmodttl_open (device) < 0) {
		perror("open failed");	
		return -1;
	}

	val = 0;
	while(1){
		
		if(val) {
			vmodttl_write(device, 1, 0x43);
			val = 0;
		}else{
			vmodttl_write(device, 1, 0xe1);
			val = 1;
		}
		usleep(250);
		//sleep(1);
	}

	vmodttl_close(device); 

	return 0;
}
Example #2
0
int main (int argc, char *argv[])
{        
        char tmp;
	struct vmodttl_config conf;
	int val;
	int i;


	printf("  ______________________________________  \n");
	printf(" |                                      | \n");
	printf(" |       VMOD-TTL Testing program       | \n");
	printf(" |______________________________________| \n");
	printf(" |                                      | \n");
	printf(" | Created by: Samuel I. Gonsalvez      | \n");
	printf(" | Email: [email protected]              | \n");
	printf(" |______________________________________| \n");

	if (argc == 2)
	{
		device = atoi(argv[1]);
	}
	else
	{
		printf("\n Please use: tstlibttl <lun_of_the_device>.\n");
		exit(-1);
	}

	if(vmodttl_open (device) < 0) {
		perror("open failed");	
		return -1;
	}

	printf("\n Port configuration \n");
	printf("\n Channel A [ (0) Input - (1) Output]: \n");
	scanf("%d", &val);
	conf.dir_a = val;
	conf.mode_a = 0; 	/* It's not open collector */

	printf("\n Channel B [ (0) Input - (1) Output]: \n");
	scanf("%d", &val);
	conf.dir_b = val;
	conf.mode_b = 0;	/* It's not open collector */

	conf.mode_c = 0; 	/* It's not open collector */

	printf("\n Up time of the pulse in the data strobe (useg): \n");
	scanf("%d", &val);
	conf.us_pulse = val;

	printf("\n In all the channels: [ (0) Non-inverting Logic - (1) Inverting logic]: \n");
	scanf("%d", &val);
	conf.inverting_logic = val;

	conf.pattern_mode_a = AND;
	conf.pattern_mode_b = OR;
	
	for(i = 0; i< NUM_BITS; i++) {
			conf.conf_pattern_a[i] = OFF;
			conf.conf_pattern_b[i] = OFF;
	}

	if (vmodttl_io_config(device, conf) < 0)
		exit(-1);


	do{
		if(tmp != '\n'){	
			printf("\n **** OPTIONS ****\n\n");
			printf(" a) Write channel.\n");
			printf(" b) Read channel.\n");
			printf(" Press \'q\' to exit...\n");
		}

		scanf("%c", &tmp);

		switch(tmp){
		case 'a':
			write_channel(device);
			break;
		case 'b':
			read_channel(device);
			break;
		case 'q':
			printf(" Exiting...\n");
			break;
		default:
			break;	
		}

	}while(tmp != 'q');

	conf.pattern_mode_a = 1;
	conf.mode_a = 1;
	conf.dir_a = 1;

	if(vmodttl_io_chan_config(device, 0, conf))
		exit(-1);

	if(vmodttl_read_config(device, &conf))
		exit(-1);
	printf("\n\n ------------------------------- \n");
	printf("\n\n 	I/O Config used!             \n");
	printf(" ------------------------------- \n");
	printf(" dir a: %d mode a: %d \n", conf.dir_a, conf.mode_a);	
	printf(" dir b: %d mode b: %d \n", conf.dir_b, conf.mode_b);	
	printf(" mode c: %d \n", conf.mode_c);	
	printf(" us_pulse: %d  inverting_logic: %d\n", conf.us_pulse, conf.inverting_logic);	
	printf(" pattern mode A: %d  pattern mode B: %d\n", conf.pattern_mode_a, conf.pattern_mode_b);	
	printf(" port A: %d/%d/%d/%d/%d/%d/%d/%d  port B: %d/%d/%d/%d/%d/%d/%d/%d \n", 
			conf.conf_pattern_a[0],
			conf.conf_pattern_a[1],
			conf.conf_pattern_a[2],
			conf.conf_pattern_a[3],
			conf.conf_pattern_a[4],
			conf.conf_pattern_a[5],
			conf.conf_pattern_a[6],
			conf.conf_pattern_a[7],
			conf.conf_pattern_b[0],
			conf.conf_pattern_b[1],
			conf.conf_pattern_b[2],
			conf.conf_pattern_b[3],
			conf.conf_pattern_b[4],
			conf.conf_pattern_b[5],
			conf.conf_pattern_b[6],
			conf.conf_pattern_b[7]
			);	
	printf("\n\n ------------------------------- \n");
	vmodttl_close(device); 

	return 0;
}
Example #3
0
int main (int argc, char *argv[])
{        
	struct vmodttl_config conf;
	int val;


	printf("  ______________________________________  \n");
	printf(" |                                      | \n");
	printf(" |       VMOD-TTL Testing program       | \n");
	printf(" |______________________________________| \n");
	printf(" |                                      | \n");
	printf(" | Created by: Samuel I. Gonsalvez      | \n");
	printf(" | Email: [email protected]              | \n");
	printf(" |______________________________________| \n");

	if (argc == 2)
	{
		device = atoi(argv[1]);
	}
	else
	{
		printf("\n Please use: test_read_write <lun_of_the_device>.\n");
		exit(-1);
	}

	if(vmodttl_open (device) < 0) {
		perror("open failed");	
		return -1;
	}

	printf("\n Port configuration \n");
	printf("\n Channel A [ (0) Input - (1) Output]: \n");
	scanf("%d", &val);
	conf.dir_a = val;
	if (!conf.dir_a){
		conf.mode_a = 0;
	}else{
		printf("\n Channel A [ (0) Open Drain - (1) Open Collector ]\n");
		scanf("%d", &val);
		conf.mode_a = val;
	}

	printf("\n Channel B [ (0) Input - (1) Output]: \n");
	scanf("%d", &val);
	conf.dir_b = val;

	if (!conf.dir_b){
		conf.mode_b = 0;

	}else{
		printf("\n Channel B [ (0) Open Drain - (1) Open Collector ]\n");
		scanf("%d", &val);
		conf.mode_b = val;
	}

	printf("\n Channel C [ (0) Open Drain - (1) Open Collector ]\n");
	scanf("%d", &val);
	conf.mode_c = val;

	printf("\n Up time of the pulse in the data strobe (useg): \n");
	scanf("%d", &val);
	conf.us_pulse = val;

	printf("\n In all the channels: [ (0) Non-inverting Logic - (1) Inverting logic]: \n");
	scanf("%d", &val);
	conf.inverting_logic = val;

	if (vmodttl_io_config(device, conf) < 0)
		exit(-1);

	while(1){
		vmodttl_read(device, 0, &val);
		printf("Value: 0x%x\n", val);

	}

	vmodttl_close(device); 

	return 0;
}