Exemplo n.º 1
0
Arquivo: test.c Projeto: axlrose/cells
int write_input_info(void) 
{
	int ret; 
	int i; 
	unsigned char cmd[8]; 
	unsigned char sendbuf[64]; 
	unsigned char retbuf[64]; 

	memset(sendbuf, 0x00, 64); 
	memset(retbuf, 0x00, 64); 
	memset(cmd, 0x00, 8); 
	cmd[6] = 0x01; 
	cmd[7] = 0xbd; 
	sendbuf[0] = 0x12; 

	ret = send_device_command(cmd);
	ret = put_device_package(sendbuf);
	ret = get_device_package(retbuf);
	if (ret) {
		fprintf(stderr, "read_a_packet error\n");
		return 1;
	}

	printf(" ==  ==  == input info status==  ==  ==\n"); 
	for (i = 0;  i < 64;  i++) {
		printf("0x%02x ", retbuf[i]); 
	}
	printf("\n==  == end  ==  == \n"); 
	return 0; 
}
Exemplo n.º 2
0
Arquivo: test.c Projeto: axlrose/cells
int read_input_info()
{
	int ret; 
	int i; 
	unsigned char cmd[8]; 
	unsigned char retbuf[64]; 

	memset(retbuf, 0x00, 64); 
	memset(cmd, 0x00, 8); 
	cmd[6] = 0x03; 
	cmd[7] = 0xbb; 

	ret = send_device_command(cmd);
	ret = get_device_package(retbuf);
	if (ret) {
		fprintf(stderr, "read_a_packet error\n");
		return 1;
	}

	printf(" ==  ==  == read input info==  ==  ==\n"); 
	for (i = 0;  i < 64;  i++) {
		printf("0x%02x ", retbuf[i]); 
	}
	printf("\n==  == end  ==  == \n"); 
	return 0; 
}
Exemplo n.º 3
0
int main(int argc, char **argv) {
	struct videohub_data *data = &maindata;

	parse_options(data, argc, argv);
	set_log_io_errors(0);

	if (!test_data) {
		data->dev_fd = connect_client(SOCK_STREAM, data->dev_host, data->dev_port);
		if (data->dev_fd < 0)
			exit(EXIT_FAILURE);
	}

	reset_routed_to(&data->inputs);
	reset_routed_to(&data->outputs);
	reset_routed_to(&data->serial);
	reset_routed_to(&data->proc_units);
	reset_routed_to(&data->frames);
	read_device_command_stream(data);

	if (test_data)
		parse_text_buffer(data, test_data);

	if (!strlen(data->device.protocol_ver) || !strlen(data->device.model_name))
		die("The device does not respond correctly. Is it Videohub?");

	if (strstr(data->device.protocol_ver, "2.") != data->device.protocol_ver)
		q("WARNING: Device protocol is %s but this program is tested with 2.x only.\n",
			data->device.protocol_ver);

	if (!data->device.dev_present) {
		if (data->device.needs_fw_update) {
			die("Device reports that it needs firmware update.");
		}
		die("Device reports that it is not present.");
	}

	check_number_of_ports(&data->inputs);
	check_number_of_ports(&data->outputs);
	check_number_of_ports(&data->mon_outputs);
	check_number_of_ports(&data->serial);
	check_number_of_ports(&data->proc_units);
	check_number_of_ports(&data->frames);

	if (num_parsed_cmds) {
		unsigned int i;
		for (i = 0; i < ARRAY_SIZE(parsed_cmds.entry); i++) {
			struct vcmd_entry *ve = &parsed_cmds.entry[i];
			if (!ve->p1.param)
				continue;
			prepare_cmd_entry(data, &parsed_cmds.entry[i]);
		}

		for (i = 0; i < ARRAY_SIZE(parsed_cmds.entry); i++) {
			char cmd_buffer[1024];
			struct vcmd_entry *ve = &parsed_cmds.entry[i];
			if (!ve->p1.param)
				continue;
			format_cmd_text(ve, cmd_buffer, sizeof(cmd_buffer));
			if (strlen(cmd_buffer)) {
				show_cmd(data, ve);
				send_device_command(data, cmd_buffer);
				read_device_command_stream(data);
			}
		}
		// Show the result after commands
		if (test_data)
			print_device_full(data);
	} else if (show_monitor) {
		while (1) {
			int sleeps = 0;
			printf("\e[2J\e[H"); // Clear screen
			time_t now = time(NULL);
			struct tm *tm = localtime(&now);
			printf("Last update: %s\n", asctime(tm));
			print_device_info(data);
			print_device_video_inputs(data);
			print_device_video_outputs(data);
			fflush(stdout);
			do {
				usleep(500000);
				if (++sleeps >= 20)
					send_device_command(data, "PING:\n\n");
			} while (read_device_command_stream(data) == 0);
		}
	} else if (show_list) {