Ejemplo n.º 1
0
inline int get_header(struct ir_remote *remote)
{
	if (is_rcmm(remote)) {
		lirc_t deltap, deltas, sum;

		deltap = get_next_pulse(remote->phead);
		if (deltap == 0) {
			unget_rec_buffer(1);
			return (0);
		}
		deltas = get_next_space(remote->shead);
		if (deltas == 0) {
			unget_rec_buffer(2);
			return (0);
		}
		sum = deltap + deltas;
		if (expect(remote, sum, remote->phead + remote->shead)) {
			return (1);
		}
		unget_rec_buffer(2);
		return (0);
	} else if (is_bo(remote)) {
		if (expectpulse(remote, remote->pone) && expectspace(remote, remote->sone)
		    && expectpulse(remote, remote->pone) && expectspace(remote, remote->sone)
		    && expectpulse(remote, remote->phead) && expectspace(remote, remote->shead)) {
			return 1;
		}
		return 0;
	}
	if (remote->shead == 0) {
		if (!sync_pending_space(remote))
			return 0;
		set_pending_pulse(remote->phead);
		return 1;
	}
	if (!expectpulse(remote, remote->phead)) {
		unget_rec_buffer(1);
		return (0);
	}
	/* if this flag is set I need a decision now if this is really
	   a header */
	if (remote->flags & NO_HEAD_REP) {
		lirc_t deltas;

		deltas = get_next_space(remote->shead);
		if (deltas != 0) {
			if (expect(remote, remote->shead, deltas)) {
				return (1);
			}
			unget_rec_buffer(2);
			return (0);
		}
	}

	set_pending_space(remote->shead);
	return (1);
}
Ejemplo n.º 2
0
inline int expectone(struct ir_remote *remote,int bit)
{
	if(is_biphase(remote))
	{
		if(is_rc6(remote) &&
		   remote->toggle_bit>0 &&
		   bit==remote->toggle_bit-1)
		{
			if(remote->sone>0 &&
			   !expectspace(remote,2*remote->sone))
			{
				unget_rec_buffer(1);
				return(0);
			}
			rec_buffer.pendingp=2*remote->pone;
		}
		else
		{
			if(remote->sone>0 && !expectspace(remote,remote->sone))
			{
				unget_rec_buffer(1);
				return(0);
			}
			rec_buffer.pendingp=remote->pone;
		}
	}
	else
	{
		if(remote->pone>0 && !expectpulse(remote,remote->pone))
		{
			unget_rec_buffer(1);
			return(0);
		}
		if(remote->ptrail>0)
		{
			if(remote->sone>0 &&
			   !expectspace(remote,remote->sone))
			{
				unget_rec_buffer(2);
				return(0);
			}
		}
		else
		{
			rec_buffer.pendings=remote->sone;
		}
	}
	return(1);
}
Ejemplo n.º 3
0
inline int get_gap(struct ir_remote *remote, lirc_t gap)
{
	lirc_t data;

	logprintf(2, "sum: %d", rec_buffer.sum);
	data = get_next_rec_buffer(gap - gap * remote->eps / 100);
	if (data == 0)
		return (1);
	if (!is_space(data)) {
		logprintf(2, "space expected");
		return (0);
	}
	unget_rec_buffer(1);
	if (!expect_at_least(remote, data, gap)) {
		logprintf(1, "end of signal not found");
		return (0);
	}
	return (1);
}
Ejemplo n.º 4
0
inline int get_gap(struct ir_remote *remote,lirc_t gap)
{
	lirc_t data;
	
	LOGPRINTF(2,"sum: %ld",rec_buffer.sum);
	data=get_next_rec_buffer(gap*(100-remote->eps)/100);
	if(data==0) return(1);
	if(!is_space(data))
	{
		LOGPRINTF(2,"space expected");
		return(0);
	}
	unget_rec_buffer(1);
	if(data<gap*(100-remote->eps)/100 &&
	   data<gap-remote->aeps)
	{
		LOGPRINTF(1,"end of signal not found");
		return(0);
	}
	return(1);	
}
Ejemplo n.º 5
0
inline int expectzero(struct ir_remote *remote, int bit)
{
	if (is_biphase(remote)) {
		int all_bits = bit_count(remote);
		ir_code mask;

		mask = ((ir_code) 1) << (all_bits - 1 - bit);
		if (mask & remote->rc6_mask) {
			if (!expectpulse(remote, 2 * remote->pzero)) {
				unget_rec_buffer(1);
				return (0);
			}
			set_pending_space(2 * remote->szero);
		} else {
			if (!expectpulse(remote, remote->pzero)) {
				unget_rec_buffer(1);
				return (0);
			}
			set_pending_space(remote->szero);
		}
	} else if (is_space_first(remote)) {
		if (remote->szero > 0 && !expectspace(remote, remote->szero)) {
			unget_rec_buffer(1);
			return (0);
		}
		if (remote->pzero > 0 && !expectpulse(remote, remote->pzero)) {
			unget_rec_buffer(2);
			return (0);
		}
	} else {
		if (!expectpulse(remote, remote->pzero)) {
			unget_rec_buffer(1);
			return (0);
		}
		if (remote->ptrail > 0) {
			if (!expectspace(remote, remote->szero)) {
				unget_rec_buffer(2);
				return (0);
			}
		} else {
			set_pending_space(remote->szero);
		}
	}
	return (1);
}