char *irman_rec(struct ir_remote *remotes) { static char *text=NULL; int i; last=end; gettimeofday(&start,NULL); codestring=ir_get_code(); gettimeofday(&end,NULL); if(codestring==NULL) { # ifdef DEBUG if(errno==IR_EDUPCODE) { LOGPRINTF(1,"received \"%s\" (dup)", text ? text:"(null - bug)"); } else if(errno==IR_EDISABLED) { LOGPRINTF(1,"irman not initialised (this is a bug)"); } else { LOGPRINTF(1,"error reading code: \"%s\"", ir_strerror(errno)); } # endif if(errno==IR_EDUPCODE) { return decode_all(remotes); } return NULL; } text=ir_code_to_text(codestring); LOGPRINTF(1,"received \"%s\"",text); /* this is only historical but it's necessary for compatibility to older versions and it's handy to recognize Irman config files */ code=0xffff; for(i=0;i<IR_CODE_LEN;i++) { code=code<<8; code=code|(ir_code) (unsigned char) codestring[i]; } return decode_all(remotes); }
static char *uirt2_raw_rec(struct ir_remote *remotes) { LOGPRINTF(1, "uirt2_raw_rec"); LOGPRINTF(1, "uirt2_raw_rec: %p", remotes); if (!clear_rec_buffer()) return (NULL); if (remotes) { char *res; res = decode_all(remotes); return res; } else { lirc_t data; queue_clear(); data = uirt2_read_raw(dev, 1); if (data) { queue_put(data); } return NULL; } }
static char *iguana_rec(struct ir_remote *remotes) { char *retval = NULL; if (clear_rec_buffer()) retval = decode_all(remotes); return retval; }
void decode_all(int* array, header h, int level) { if(!level) { return finish(array); } int* new_array = malloc(sizeof(int)*headers[level-1].size); int index = 0; mpz_t number, spill; mpz_init(number); mpz_init(spill); for(int i = 0; i < h.size; i++) { mpz_ui_pow_ui(spill, 2, M); mpz_set(number, remainders[level-1][i]); mpz_addmul_ui(number, spill, array[i]); int min = headers[level-1].chunksize > (headers[level-1].size - index)?(headers[level-1].size - index):headers[level-1].chunksize; for(int j = 0; j < min; j++) { new_array[index + min - j - 1] = mpz_fdiv_q_ui(number, number, headers[level-1].K); } index += min; } return decode_all(new_array, headers[level - 1], level - 1); }
static char *ati_rec(struct ir_remote *remotes) { if (!clear_rec_buffer()) { ati_deinit(); return NULL; } return decode_all(remotes); }
char *default_rec(struct ir_remote *remotes) { if (!clear_rec_buffer()) { default_deinit(); return NULL; } return (decode_all(remotes)); }
char *bte_rec(struct ir_remote *remotes) { LOGPRINTF(4, "bte_rec called"); if (bte_automaton()) return decode_all(remotes); else return NULL; }
char *creative_rec(struct ir_remote *remotes) { char *m; int i; b[0]=0x4d; b[1]=0x05; b[4]=0xac; b[5]=0x21; last=end; gettimeofday(&start,NULL); for(i=0;i<NUMBYTES;i++) { if(i>0) { if(!waitfordata(TIMEOUT)) { logprintf(LOG_ERR,"timeout reading byte %d",i); return(NULL); } } if(read(hw.fd,&b[i],1)!=1) { logprintf(LOG_ERR,"reading of byte %d failed",i); logperror(LOG_ERR,NULL); return(NULL); } if(b[0]!=0x4d || b[1]!=0x05 /* || b[4]!=0xac || b[5]!=0x21 */) { logprintf(LOG_ERR,"bad envelope"); return(NULL); } if(i==5) { if(b[2]!=((~b[3])&0xff)) { logprintf(LOG_ERR,"bad checksum"); return(NULL); } } LOGPRINTF(1,"byte %d: %02x",i,b[i]); } gettimeofday(&end,NULL); /* pre=0x8435; */ pre=reverse((((ir_code) b[4])<<8) | ((ir_code) b[5]),16); code = reverse((((ir_code) b[2]) << 8) | ((ir_code) b[3]), 16); m=decode_all(remotes); return(m); }
char *mp3anywhere_rec(struct ir_remote *remotes) { char *m; int i=0; b[0]=0x00; b[1]=0xd5; b[2]=0xaa; b[3]=0xee; b[5]=0xad; last=end; gettimeofday(&start,NULL); while(b[i] != 0xAD) { i++; if(i>=NUMBYTES) { LOGPRINTF(0,"buffer overflow at byte %d",i); break; } if(i>0) { if(!waitfordata(TIMEOUT)) { LOGPRINTF(0,"timeout reading byte %d",i); return(NULL); } } if(read(hw.fd,&b[i],1)!=1) { logprintf(LOG_ERR,"reading of byte %d failed",i); logperror(LOG_ERR,NULL); return(NULL); } if(b[1]!= 0xd5 || b[2]!= 0xaa || b[3]!= 0xee || b[5]!= 0xad ) { logprintf(LOG_ERR,"bad envelope"); return(NULL); } LOGPRINTF(1,"byte %d: %02x",i,b[i]); } gettimeofday(&end,NULL); pre=0xD5AAEE; code=(ir_code) b[4]; m=decode_all(remotes); return(m); }
char *logitech_rec(struct ir_remote *remotes) { char *m; int i=0; int repeat, mouse_event; b[i]=0x00; last=end; gettimeofday(&start,NULL); while(b[i] != 0xAA) { i++; if(i>=NUMBYTES) { LOGPRINTF(0,"buffer overflow at byte %d",i); break; } if(i>0) { if(!waitfordata(TIMEOUT)) { LOGPRINTF(0,"timeout reading byte %d",i); return(NULL); } } if(read(hw.fd,&b[i],1)!=1) { logprintf(LOG_ERR,"reading of byte %d failed",i); logperror(LOG_ERR,NULL); return(NULL); } LOGPRINTF(1,"byte %d: %02x",i,b[i]); if(b[i] >= 0x40 && b[i] <= 0x6F) { mouse_event=b[i]; b[1]=0xA0; b[2]=mouse_event; LOGPRINTF(1,"mouse event: %02x",mouse_event); break; } } gettimeofday(&end,NULL); if(b[1] == 0xA0) repeat=0; else repeat=1; if(!repeat) pre=(ir_code) b[1]; else pre=0xA0; code=(ir_code) b[2]; m=decode_all(remotes); return(m); }
char *creative_infracd_rec(struct ir_remote *remotes) { int cmd; while ( (cmd = test_device_command(int_fd)) == 0 ) { usleep(40); }; if ( cmd == -1 ) { return 0; } code = (reverse(cmd,8) << 8) | (~reverse(cmd,8) & 0xff); return decode_all(remotes); }
/************************************************************************** * Receive a code (1 byte) from the remote. * This function is called by the LIRC daemon when I/O is pending * from a registered client, e.g. irw. * * return NULL if nothing have been received or a lirc code **************************************************************************/ char *mplay_rec(struct ir_remote *remotes) { unsigned char rc_code; signed int len; struct timeval current_time; LOGPRINTF(1, "Entering mplay_rec()"); len = read(hw.fd, &rc_code, 1); gettimeofday(¤t_time, NULL); if (len != 1) { /* Something go wrong during the read, we close the device for prevent endless looping when the device is disconnected */ LOGPRINTF(1, "Reading error in mplay_rec()"); mplay_deinit(); return NULL; } else { /* We have received a code */ if (rc_code == MPLAY_REPEAT_CODE) { if (mplay_local_data.timeout_repetition_flag == 1) { /* We ignore the repetition */ return NULL; } else { if (time_elapsed(&mplay_local_data.last_reception_time, ¤t_time) <= MAX_TIME_BETWEEN_TWO_REPETITION_CODE) { /* This reception is a repeat */ mplay_local_data.repeat_flag = 1; /* We save the reception time */ mplay_local_data.last_reception_time = current_time; } else { /* To much time between repetition, the receiver have probably miss a valide key code. We ignore the repetition */ mplay_local_data.timeout_repetition_flag = 1; mplay_local_data.repeat_flag = 0; return NULL; } } } else { /* This is a new code */ mplay_local_data.rc_code = rc_code; mplay_local_data.repeat_flag = 0; mplay_local_data.timeout_repetition_flag = 0; mplay_local_data.last_reception_time = current_time; } LOGPRINTF(1, "code: %u", (unsigned int)mplay_local_data.rc_code); LOGPRINTF(1, "repeat_flag: %d", mplay_local_data.repeat_flag); return decode_all(remotes); } }
char *ea65_receive(struct ir_remote *remote) { uint8_t data[5]; int r; last = end; gettimeofday(&start, NULL); if (!waitfordata(TIMEOUT)) { logprintf(LOG_ERR, "EA65: timeout reading code data"); return NULL; } r = read(hw.fd, data, sizeof(data)); if (r < 4) { logprintf(LOG_ERR, "EA65: read failed. %s(%d)", strerror(r), r); return NULL; } LOGPRINTF(1, "EA65: data(%d): %02x %02x %02x %02x %02x", r, data[0], data[1], data[2], data[3], data[4]); if (data[0] != 0xa0) return NULL; switch (data[1]) { case 0x01: if (r < 5) return NULL; code = (data[2] << 16) | (data[3] << 8) | data[4]; break; case 0x04: code = (0xff << 16) | (data[2] << 8) | data[3]; break; } logprintf(LOG_INFO, "EA65: receive code: %llx", (unsigned long long) code); gettimeofday(&end, NULL); return decode_all(remote); }
char *pinsys_rec(struct ir_remote *remotes) { char *m; int i; last=end; gettimeofday(&start,NULL); for(i=0;i<3;i++) { if (i>0) { if(!waitfordata(10000)) { logprintf(LOG_WARNING, "timeout reading byte %d",i); /* likely to be !=3 bytes, so flush. */ tcflush(hw.fd, TCIFLUSH); return(NULL); } } if(read(hw.fd,&b[i],1)!=1) { logprintf(LOG_ERR,"reading of byte %d failed",i); logperror(LOG_ERR,NULL); return(NULL); } LOGPRINTF(1,"byte %d: %02x",i,b[i]); } gettimeofday(&end,NULL); #ifdef PINSYS_THREEBYTE code = (b[2]) | (b[1]<<8) | (b[0]<<16); #else code = b[2]; #endif LOGPRINTF(1," -> %016lx",(unsigned long) code); m=decode_all(remotes); return(m); }
char *tira_rec (struct ir_remote *remotes) { char *m; int i, x; last = end; x = 0; gettimeofday (&start, NULL); for (i = 0 ; i < 6; i++) { if (i > 0) { if (!waitfordata(20000)) { LOGPRINTF(0,"timeout reading byte %d",i); /* likely to be !=6 bytes, so flush. */ tcflush(hw.fd, TCIFLUSH); return NULL; } } if (read(hw.fd, &b[i], 1) != 1) { logprintf(LOG_ERR, "reading of byte %d failed.", i); logperror(LOG_ERR,NULL); return NULL; } LOGPRINTF(1, "byte %d: %02x", i, b[i]); x++; } gettimeofday(&end,NULL); code = 0; for ( i = 0 ; i < x ; i++ ) { code |= ((ir_code) b[i]); code = code << 8; } LOGPRINTF(1," -> %0llx",(unsigned long long) code); m = decode_all(remotes); return m; }
static char* rec(struct ir_remote* remotes) { unsigned char rc_code; ssize_t size; struct timeval current; size = snd_hwdep_read(hwdep, &rc_code, 1); if (size < 1) return NULL; gettimeofday(¤t, NULL); last_code = code; code = (ir_code)rc_code; /* delay for repeating buttons is up to 320 ms */ repeat_flag = code == last_code && current.tv_sec - last_time.tv_sec <= 2 && time_elapsed(&last_time, ¤t) <= 350000; last_time = current; LOGPRINTF(1, "code: %llx", (__u64)code); LOGPRINTF(1, "repeat_flag: %d", repeat_flag); return decode_all(remotes); }
char *default_rec(struct ir_remote *remotes) { char c; int n; static char message[PACKET_SIZE+1]; if(hw.rec_mode==LIRC_MODE_STRING) { int failed=0; /* inefficient but simple, fix this if you want */ n=0; do { if(read(hw.fd,&c,1)!=1) { logprintf(LOG_ERR,"reading in mode " "LIRC_MODE_STRING failed"); return(NULL); } if(n>=PACKET_SIZE-1) { failed=1; n=0; } message[n++]=c; } while(c!='\n'); message[n]=0; if(failed) return(NULL); return(message); } else { if(!clear_rec_buffer()) return(NULL); return(decode_all(remotes)); } }
static char* uirt2_raw_rec(struct ir_remote* remotes) { log_trace("uirt2_raw_rec"); log_trace("uirt2_raw_rec: %p", remotes); if (!rec_buffer_clear()) return NULL; if (remotes) { char* res; res = decode_all(remotes); return res; } lirc_t data; queue_clear(); data = uirt2_read_raw(dev, 1); if (data) queue_put(data); return NULL; }
char *caraca_rec(struct ir_remote *remotes) { char *m; int i = 0, node, ir, t; int repeat, mouse_event; last = end; gettimeofday(&start, NULL); i = read(hw.fd, msg, NUMBYTES); gettimeofday(&end, NULL); LOGPRINTF(1, "caraca_rec: %s", msg); sscanf(msg, "%d.%d:%d", &node, &t, &ir); /* transmit the node address as first byte, so we have * different codes for every transmitting node (for every room * of the house) */ code = (ir_code) (node << 8) + ir; m = decode_all(remotes); return (m); }
/* * Aureal Technology ATWF@83 cheap remote * specific code. */ static char* atwf83_rec(struct ir_remote* remotes) { unsigned ev; int rd; last = end; gettimeofday(&start, NULL); rd = read(drv.fd, &ev, sizeof(ev)); if (rd == -1) { // Error logprintf(LIRC_ERROR, "(%s) could not read pipe", __func__); atwf83_deinit(); return 0; } if (ev == release_code) { // Release code main_code = 0; return 0; } else if (ev == remove_code) { // Device has been removed atwf83_deinit(); return 0; } LOGPRINTF(1, "atwf83 : %x", ev); // Record the code and check for repetition if (main_code == ev) { repeat_state = RPT_YES; } else { main_code = ev; repeat_state = RPT_NO; } gettimeofday(&end, NULL); return decode_all(remotes); }
char *pixelview_rec(struct ir_remote *remotes) { char *m; int i; last=end; gettimeofday(&start,NULL); for(i=0;i<3;i++) { if(i>0) { if(!waitfordata(50000)) { logprintf(LOG_ERR,"timeout reading " "byte %d",i); return(NULL); } } if(read(hw.fd,&b[i],1)!=1) { logprintf(LOG_ERR,"reading of byte %d failed",i); logperror(LOG_ERR,NULL); return(NULL); } LOGPRINTF(1,"byte %d: %02x",i,b[i]); } gettimeofday(&end,NULL); pre=(reverse((ir_code) b[0],8)<<1)|1; code=(reverse((ir_code) b[1],8)<<1)|1; code=code<<10; code|=(reverse((ir_code) b[2],8)<<1)|1; m=decode_all(remotes); return(m); }
char *hiddev_rec(struct ir_remote *remotes) { struct hiddev_event event; struct hiddev_event asus_events[8]; int rd; /* Remotec Mediamaster specific */ static int wheel_count = 0; static int x_movement = 0; static struct timeval time_of_last_code; int y_movement = 0; int x_direction = 0; int y_direction = 0; int i; LOGPRINTF(1, "hiddev_rec"); last = end; gettimeofday(&start, NULL); rd = read(hw.fd, &event, sizeof event); if (rd != sizeof event) { logprintf(LOG_ERR, "error reading '%s'", hw.device); logperror(LOG_ERR, NULL); hiddev_deinit(); return 0; } LOGPRINTF(1, "hid 0x%X value 0x%X", event.hid, event.value); pre_code = event.hid; main_code = event.value; /* * This stuff is probably dvico specific. * I don't have any other hid devices to test... * * See further for the Asus DH specific code * */ if (event.hid == 0x90001) { /* This is the DVICO Remote. It actually sends two hid * events, the first of which has 0 as the hid.value and * is of no use in decoding the remote code. If we * receive this type of event, read the next event * (which should be immediately available) and * use it to obtain the remote code. */ LOGPRINTF(1, "This is another type Dvico - sends two codes"); if (!waitfordata(TIMEOUT)) { logprintf(LOG_ERR, "timeout reading next event"); return (NULL); } rd = read(hw.fd, &event, sizeof event); if (rd != sizeof event) { logprintf(LOG_ERR, "error reading '%s'", hw.device); return 0; } pre_code = event.hid; main_code = event.value; } gettimeofday(&end, NULL); if (event.hid == 0x10046) { struct timeval now; repeat_state = (main_code & dvico_repeat_mask) ? RPT_YES : RPT_NO; main_code = (main_code & ~dvico_repeat_mask); gettimeofday(&now, NULL); /* The hardware dongle for the dvico remote sends spurious */ /* repeats of the last code received it it gets a false */ /* trigger from some other IR source, or if it misses */ /* receiving the first code of a new button press. To */ /* minimise the impact of this hardware bug, ignore any */ /* repeats that occur more than half a second after the */ /* previous valid code because it is likely that they are */ /* spurious. */ if (repeat_state == RPT_YES) { if (time_elapsed(&time_of_last_code, &now) > 500000) { return NULL; } } time_of_last_code = now; LOGPRINTF(1, "main 0x%X repeat state 0x%X", main_code, repeat_state); return decode_all(remotes); #if 0 /* the following code could be used to recreate the real codes of the remote control (currently verified for the MCE remote only) */ ir_code pre, main; pre_code_length = 16; main_code_length = 16; pre = event.value & 0xff; pre_code = reverse(~pre, 8) << 8 | reverse(pre, 8); repeat_state = (event.value & dvico_repeat_mask) ? RPT_YES : RPT_NO; main = (event.value & 0x7f00) >> 8; main_code = reverse(main, 8) << 8 | reverse(~main, 8); return decode_all(remotes); #endif } /* Asus DH remote specific code */ else if (event.hid == 0xFF000000) {
char *audio_rec(struct ir_remote *remotes) { if (!clear_rec_buffer()) return (NULL); return (decode_all(remotes)); }
static char* hwftdi_rec(struct ir_remote* remotes) { if (!rec_buffer_clear()) return NULL; return decode_all(remotes); }
char *tira_rec_mode2 (struct ir_remote *remotes) { if(!clear_rec_buffer()) return(NULL); return(decode_all(remotes)); }
char* silitek_rec(struct ir_remote* remotes) { char* m; int mouse_x; int mouse_y; char sign = 0x00; /* store sign of mouse direction. */ char pos = 0x00; /* store mouse direction. */ do_repeat = 1; if (!silitek_read(drv.fd, &b[0], TIMEOUT)) { logprintf(LIRC_ERROR, "reading of byte 0 failed"); logperror(LIRC_ERROR, NULL); return NULL; } if ((b[0] != 0x3f) && /* button down */ (b[0] != 0x31) && /* button still down */ (b[0] != 0x2a) && /* button up */ (b[0] != 0x7c) && /* mouse event */ (b[0] != 0x7f) && /* mouse event, l+r-mouse button down */ (b[0] != 0xfd) && /* mouse event, r-mouse button down */ (b[0] != 0xfe)) /* mouse event, l-mouse button down */ return NULL; last = current; if (!silitek_read(drv.fd, &b[1], TIMEOUT)) { logprintf(LIRC_ERROR, "reading of byte 1 failed"); logperror(LIRC_ERROR, NULL); return NULL; } if (!silitek_read(drv.fd, &b[2], TIMEOUT)) { logprintf(LIRC_ERROR, "reading of byte 2 failed"); logperror(LIRC_ERROR, NULL); return NULL; } /* mouse event ? */ if ((b[0] == 0x7c) || (b[0] == 0x7f) || (b[0] == 0xfd) || (b[0] == 0xfe)) { /* if mouse was not moved check mouse-button state. */ if ((b[1] == 0x80) && (b[2] == 0x80)) { switch (b[0]) { case 0xfd: b[1] = 0xa0; /* r-mouse button */ b[2] = 0xbb; break; case 0xfe: b[1] = 0x0a; /* l-mouse button */ b[2] = 0xbb; break; case 0x7f: b[1] = 0xaa; /* l+r-mouse button */ b[2] = 0xbb; break; } } else { /* calc mouse x movement */ mouse_x = b[1] & 0x1f; /* calc mouse y movement */ mouse_y = b[2] & 0x1f; /* if the joystick is pulled to the left */ if ((b[1] & 0x20) == 0x20) { mouse_x = 32 - mouse_x; sign |= 0x10; } /* if the joystick is pulled up */ if ((b[2] & 0x20) == 0x20) { mouse_y = 32 - mouse_y; sign |= 0x01; } /* calc mouse direction */ if ((mouse_x > 0) && (mouse_y == 0)) pos = 0x01; if ((mouse_x > mouse_y) && (mouse_y > 0)) pos = 0x02; if ((mouse_x == mouse_y) && (mouse_x > 0)) pos = 0x03; if ((mouse_y > mouse_x) && (mouse_x > 0)) pos = 0x04; if ((mouse_y > 0) && (mouse_x == 0)) pos = 0x05; b[1] = sign; b[2] = pos; /* if only a small mouse movement don't set * repeat flag gets better control in lircmd * this way */ if ((mouse_x < 4) && (mouse_y < 4)) do_repeat = 0; } b[0] = 0xaa; /* set to indicate mouse event */ } else { if (b[0] != 0x2a) b[0] = 0xbb; /* set to indicate button down event */ else b[0] = 0xcc; /* set to indicate button up event */ } code = ((ir_code)b[0] << 16) + ((ir_code)b[1] << 8) + (ir_code)b[2]; gettimeofday(¤t, NULL); m = decode_all(remotes); return m; }
//------------------------------------------------------------------------- // Receive a code (bytes sequence) from the remote. // This function is called by the LIRC daemon when I/O is pending // from a registered client, e.g. irw. //------------------------------------------------------------------------- char *accent_rec(struct ir_remote *remotes) { char *m; int i, j; LOGPRINTF(LOG_DEBUG, "Entering accent_rec()"); // Timestamp of the last pressed key. last = end; // Timestamp of key press start. gettimeofday(&start, NULL); // Loop untill read ACCENT_MAX_READ_BYTES or sequence timeout. for (i = 0; i < ACCENT_MAX_READ_BYTES; i++) { // The function accent_rec() is called when some data // is already available to read, so we don't wait on // the first byte. if (i > 0) { // Each of the following bytes must be // received within some timeout. 7500 us is // the standard time for receiving a byte // (wait at least this time) 56000 us is the // min time gap between two code sequences // (don't wait so much) if (waitfordata(45000) == 0) { // waitfordata() timed out: the // sequence is complete. LOGPRINTF(LOG_INFO, "waitfordata() timeout " "waiting for byte %d", i); break; } } // Some data available to read. if (read(hw.fd, &b[i], 1) == -1) { logprintf(LOG_ERR, "read() failed at byte %d", i); logperror(LOG_ERR, "read() failed"); return(NULL); } else { LOGPRINTF(LOG_INFO, "read() byte %d: %02x", i, b[i]); } } // End for // Timestamp of key press end. gettimeofday(&end, NULL); // The bytes sequence is complete, check its validity. LOGPRINTF(LOG_INFO, "Received a sequence of %d bytes", i); // Just one byte with zero value: repeated keypress? if (i == 1 && b[0] == 0) { if (last_code && (start.tv_sec - last.tv_sec < 2)) { // A previous code exists and the time gap is // lower than 2 seconds. logprintf(LOG_INFO, "Received repeated key"); code = last_code; tcflush(hw.fd, TCIFLUSH); m = decode_all(remotes); return(m); } else { LOGPRINTF(LOG_INFO, "Previos code not set, " "invalid repeat key"); last_code = 0; return(NULL); } } // Sequence too short? if (i < ACCENT_MEANING_BYTES) { logprintf(LOG_NOTICE, "Invalid sequence: too short"); last_code = 0; return(NULL); } // A valid code begins with bytes 0x90 0x46 0x42 // and it is long not more than ACCENT_MEANING_BYTES. if (b[0] == 0x90 && b[1] == 0x46 && b[2] == 0x42) { code = 0; if (sizeof(code) >= ACCENT_MEANING_BYTES) { // We have plenty of space to store the full sequence. code |= b[0]; code <<= 8; code |= b[1]; code <<= 8; code |= b[2]; code <<= 8; code |= b[3]; code <<= 8; code |= b[4]; code <<= 8; code |= b[5]; code <<= 8; code |= b[6]; code <<= 8; code |= b[7]; } else { // No much space, keep only the differentiating part. code |= b[3]; code <<= 8; code |= b[4]; code <<= 8; code |= b[5]; code <<= 8; code |= b[6]; } LOGPRINTF(LOG_INFO, "sizeof(code) = %d", sizeof(code)); logprintf(LOG_INFO, "Received code -> 0x%016llx", code); last_code = code; tcflush(hw.fd, TCIFLUSH); m = decode_all(remotes); return(m); } // Sometimes the receiver goes crazy, it starts to send to the // serial line a sequence of zeroes with no pauses at all. // This jam terminates only if the user press a new button on // the remote or if we close and re-open the serial port. if (i == ACCENT_MAX_READ_BYTES) { for (j = 0; j < ACCENT_MAX_READ_BYTES; j++) { if (b[j] != 0) break; } if (j == ACCENT_MAX_READ_BYTES) { // All the received bytes are zeroes, without gaps. logprintf(LOG_WARNING, "Receiver jam! " "Reopening the serial port"); close(hw.fd); if ((hw.fd = accent_open_serial_port(hw.device)) < 0) { logprintf(LOG_ERR, "Could not reopen the " "serial port"); raise(SIGTERM); } last_code = 0; return(NULL); } } // Should never reach this point. logprintf(LOG_NOTICE, "Received an invalid sequence"); for (j = 0; j < i; j++) { LOGPRINTF(LOG_NOTICE, " b[%d] = %02x", j, b[j]); } last_code = 0; return(NULL); }
static char *awlibusb_rec(struct ir_remote *remotes) { if (!clear_rec_buffer()) return NULL; return decode_all(remotes); }
char *creative_rec(struct ir_remote *remotes) { char *m; int i; b[0]=0x4d; b[1]=0x05; b[4]=0xac; b[5]=0x21; last=end; gettimeofday(&start,NULL); for(i=0;i<NUMBYTES;i++) { if(i>0) { if(!waitfordata(TIMEOUT)) { logprintf(LOG_ERR,"timeout reading byte %d",i); return(NULL); } } if(read(hw.fd,&b[i],1)!=1) { logprintf(LOG_ERR,"reading of byte %d failed",i); logperror(LOG_ERR,NULL); return(NULL); } if(b[0]!=0x4d || b[1]!=0x05 || b[4]!=0xac || b[5]!=0x21) { logprintf(LOG_ERR,"bad envelope"); return(NULL); } if(i==5) { if(b[2]!=((~b[3])&0xff)) { logprintf(LOG_ERR,"bad checksum"); return(NULL); } } LOGPRINTF(1,"byte %d: %02x",i,b[i]); } gettimeofday(&end,NULL); pre=0x8435; for(i=0;mapping[i]!=0x00;i++) { if(mapping[i]==b[3]) { code=(ir_code) (i<<8)|((~i)&0xff); break; } } if(mapping[i]==0x00) { logprintf(LOG_ERR,"unknown code"); return(NULL); } m=decode_all(remotes); return(m); }