Exemplo n.º 1
0
int s_video_helper_irman_init (char *port)
{
	int ret;
	ret = ir_open_port(port);
	if (ret == -1)
		return -1;
	ret = ir_init(port);
	if (ret == -1)
		return -1;
	return ir_get_portfd();
}
Exemplo n.º 2
0
static void irconf_ok_cb(GtkWidget * w, gpointer data)
{
	ircfg.device = g_strdup(gtk_entry_get_text(GTK_ENTRY(dev_entry)));
	ircfg.codelen = atoi(gtk_entry_get_text(GTK_ENTRY(codelen_entry)));
	if(ircfg.codelen > IR_MAX_CODE_LEN)
	    ircfg.codelen = IR_MAX_CODE_LEN;
	if(ircfg.codelen < 0)
	    ircfg.codelen = 0;
	/* Re-initialize remote using new settings */
	ir_close_port();
	ir_open_port(ircfg.device);
	irapp_save_config();
	gtk_widget_destroy(irconf_mainwin);
}
Exemplo n.º 3
0
Arquivo: ir.c Projeto: sedwards/xmms3
/* A modified port initialization - seems to work everytime */
void irapp_init_port(gchar * ir_port)
{
	gint i;

	for (i = 0; i < 2; i++)
	{
		if (ir_open_port(ir_port) < 0)
			fprintf(stderr, _("unable to open port `%s' (%s)\n"), ir_port, strerror(errno));
		else
		{
			ir_write_char('I');
			ir_usleep(IR_HANDSHAKE_GAP);
			ir_write_char('R');
			ir_set_enabled(1);
			ir_clear_buffer(); /* Take the 'OK' */
		}
	}
}
Exemplo n.º 4
0
static int ir_init (char *filename)
{
	int rdchar;
	if (ir_enabled) {
		errno = EBUSY;	/* we already have a high level ir setup */
		return -1;
	}
	if (ir_open_port(filename) < 0) {
		return -1;
	}
	ir_clear_buffer();
	if (ir_write_char('I') < 0) {
		return -1;
	}
	ir_usleep(IR_HANDSHAKE_GAP);
	if (ir_write_char('R') < 0) {
		return -1;
	}
	/* we'll be nice and give the box a good chance to send an 'O' */
	while ((rdchar = ir_read_char(IR_HANDSHAKE_TIMEOUT)) != 'O') {
		if (rdchar < 0) {	/* error or timeout */
			return -1;
		}
	}
	/* as regards the 'K', however, that really must be the next character */
	rdchar = ir_read_char(IR_HANDSHAKE_TIMEOUT);
	if (rdchar < 0) {
		return -1;
	}
	/* ENOEXEC is the closest error I could find, that would also not be
	 * generated by ir_read_char().  Anyway, ENOEXEC does more or less mean
	 * "I don't understand this data I've been given"
	 */
	if (rdchar != 'K') {
		errno = ENOEXEC;
		return -1;
	}
	/* we are now ready to roll */
	ir_enabled = 1;
	return 0;
}