ir_code get_data(struct ir_remote *remote,int bits,int done) { ir_code code; int i; code=0; if(is_rcmm(remote)) { lirc_t deltap,deltas,sum; if(bits%2 || done%2) { logprintf(LOG_ERR,"invalid bit number."); return((ir_code) -1); } for(i=0;i<bits;i+=2) { code<<=2; deltap=get_next_pulse(remote->pzero+remote->pone+ remote->ptwo+remote->pthree); deltas=get_next_space(remote->szero+remote->sone+ remote->stwo+remote->sthree); if(deltap==0 || deltas==0) { logprintf(LOG_ERR,"failed on bit %d", done+i+1); } sum=deltap+deltas; LOGPRINTF(3,"rcmm: sum %ld",(unsigned long) sum); if(expect(remote,sum,remote->pzero+remote->szero)) { code|=0; LOGPRINTF(2,"00"); } else if(expect(remote,sum,remote->pone+remote->sone)) { code|=1; LOGPRINTF(2,"01"); } else if(expect(remote,sum,remote->ptwo+remote->stwo)) { code|=2; LOGPRINTF(2,"10"); } else if(expect(remote,sum,remote->pthree+remote->sthree)) { code|=3; LOGPRINTF(2,"11"); } else { LOGPRINTF(2,"no match for %ld+%ld=%ld", deltap,deltas,sum); return((ir_code) -1); } } return(code); } for(i=0;i<bits;i++) { code=code<<1; if(is_goldstar(remote)) { if((done+i)%2) { LOGPRINTF(2,"$1"); remote->pone=remote->ptwo; remote->sone=remote->stwo; } else { LOGPRINTF(2,"$2"); remote->pone=remote->pthree; remote->sone=remote->sthree; } } if(expectone(remote,done+i)) { LOGPRINTF(2,"1"); code|=1; } else if(expectzero(remote,done+i)) { LOGPRINTF(2,"0"); code|=0; } else { LOGPRINTF(1,"failed on bit %d",done+i+1); return((ir_code) -1); } } return(code); }
ir_code get_data(struct ir_remote * remote, int bits, int done) { ir_code code; int i; code = 0; if (is_rcmm(remote)) { lirc_t deltap, deltas, sum; if (bits % 2 || done % 2) { logprintf(LOG_ERR, "invalid bit number."); return ((ir_code) - 1); } if (!sync_pending_space(remote)) return 0; for (i = 0; i < bits; i += 2) { code <<= 2; deltap = get_next_pulse(remote->pzero + remote->pone + remote->ptwo + remote->pthree); deltas = get_next_space(remote->szero + remote->sone + remote->stwo + remote->sthree); if (deltap == 0 || deltas == 0) { logprintf(LOG_ERR, "failed on bit %d", done + i + 1); return ((ir_code) - 1); } sum = deltap + deltas; logprintf(3, "rcmm: sum %ld", (__u32) sum); if (expect(remote, sum, remote->pzero + remote->szero)) { code |= 0; logprintf(2, "00"); } else if (expect(remote, sum, remote->pone + remote->sone)) { code |= 1; logprintf(2, "01"); } else if (expect(remote, sum, remote->ptwo + remote->stwo)) { code |= 2; logprintf(2, "10"); } else if (expect(remote, sum, remote->pthree + remote->sthree)) { code |= 3; logprintf(2, "11"); } else { logprintf(2, "no match for %d+%d=%d", deltap, deltas, sum); return ((ir_code) - 1); } } return (code); } else if (is_grundig(remote)) { lirc_t deltap, deltas, sum; int state, laststate; if (bits % 2 || done % 2) { logprintf(LOG_ERR, "invalid bit number."); return ((ir_code) - 1); } if (!sync_pending_pulse(remote)) return ((ir_code) - 1); for (laststate = state = -1, i = 0; i < bits;) { deltas = get_next_space(remote->szero + remote->sone + remote->stwo + remote->sthree); deltap = get_next_pulse(remote->pzero + remote->pone + remote->ptwo + remote->pthree); if (deltas == 0 || deltap == 0) { logprintf(LOG_ERR, "failed on bit %d", done + i + 1); return ((ir_code) - 1); } sum = deltas + deltap; logprintf(3, "grundig: sum %ld", (__u32) sum); if (expect(remote, sum, remote->szero + remote->pzero)) { state = 0; logprintf(2, "2T"); } else if (expect(remote, sum, remote->sone + remote->pone)) { state = 1; logprintf(2, "3T"); } else if (expect(remote, sum, remote->stwo + remote->ptwo)) { state = 2; logprintf(2, "4T"); } else if (expect(remote, sum, remote->sthree + remote->pthree)) { state = 3; logprintf(2, "6T"); } else { logprintf(2, "no match for %d+%d=%d", deltas, deltap, sum); return ((ir_code) - 1); } if (state == 3) { /* 6T */ i += 2; code <<= 2; state = -1; code |= 0; } else if (laststate == 2 && state == 0) { /* 4T2T */ i += 2; code <<= 2; state = -1; code |= 1; } else if (laststate == 1 && state == 1) { /* 3T3T */ i += 2; code <<= 2; state = -1; code |= 2; } else if (laststate == 0 && state == 2) { /* 2T4T */ i += 2; code <<= 2; state = -1; code |= 3; } else if (laststate == -1) { /* 1st bit */ } else { logprintf(LOG_ERR, "invalid state %d:%d", laststate, state); return ((ir_code) - 1); } laststate = state; } return (code); } for (i = 0; i < bits; i++) { code = code << 1; if (is_goldstar(remote)) { if ((done + i) % 2) { logprintf(2, "$1"); remote->pone = remote->ptwo; remote->sone = remote->stwo; } else { logprintf(2, "$2"); remote->pone = remote->pthree; remote->sone = remote->sthree; } } if (expectone(remote, done + i)) { logprintf(2, "1"); code |= 1; } else if (expectzero(remote, done + i)) { logprintf(2, "0"); code |= 0; } else { logprintf(1, "failed on bit %d", done + i + 1); return ((ir_code) - 1); } } return (code); }