static int write_send_buffer(int lirc) { if (send_buffer_length() == 0) { LOGPRINTF(1, "nothing to send"); return (0); } return (write(lirc, send_buffer_data(), send_buffer_length() * sizeof(lirc_t))); }
static int write_send_buffer(int lirc) { if (send_buffer_length() == 0) { log_trace("nothing to send"); return 0; } return write(lirc, send_buffer_data(), send_buffer_length() * sizeof(lirc_t)); }
static int write_send_buffer(int lirc) { if (send_buffer_length() == 0) { logprintf(LIRC_TRACE, "nothing to send"); return (0); } return (write(lirc, send_buffer_data(), send_buffer_length() * sizeof(lirc_t))); }
static int uirt2_send(struct ir_remote *remote, struct ir_ncode *code) { int i, length; unsigned long delay; const lirc_t *signals; int res = 0; if (!init_send(remote, code)) { return 0; } length = send_buffer_length(); signals = send_buffer_data(); if (length <= 0 || signals == NULL) { LOGPRINTF(1, "nothing to send"); return 0; } LOGPRINTF(1, "Trying REMSTRUC1 transmission"); res = uirt2_send_mode2_struct1(dev, remote, signals, length); if (!res && (length < 48)) { LOGPRINTF(1, "Using RAW transission"); res = uirt2_send_mode2_raw(dev, remote, signals, length); } if (!res) { logprintf(LIRC_ERROR, "uirt2_send: remote not supported"); } else { LOGPRINTF(1, "uirt2_send: succeeded"); } /* * Some devices send the sequence in the background. Wait for * the sequence to complete before returning in order to avoid * disturbing DTR which is used by certain hardware revisions * to enable the builtin emitter. We wait 1.1 times the expected * time in order to handle any differences between the device and * our clock. */ delay = remote->min_remaining_gap; for (i = 0; i < length; i++) { delay += signals[i]; } delay = (delay * 11) / 10; usleep (delay); return res; }
void calculate_signal_lengths(struct ir_remote *remote) { if (is_const(remote)) { remote->min_total_signal_length = min_gap(remote); remote->max_total_signal_length = max_gap(remote); } else { remote->min_gap_length = min_gap(remote); remote->max_gap_length = max_gap(remote); } lirc_t min_signal_length = 0, max_signal_length = 0; lirc_t max_pulse = 0, max_space = 0; int first_sum = 1; struct ir_ncode *c = remote->codes; int i; while (c->name) { struct ir_ncode code = *c; struct ir_code_node *next = code.next; int first = 1; int repeat = 0; do { if (first) { first = 0; } else { code.code = next->code; next = next->next; } for (repeat = 0; repeat < 2; repeat++) { if (init_sim(remote, &code, repeat)) { lirc_t sum = send_buffer_sum(); if (sum) { if (first_sum || sum < min_signal_length) { min_signal_length = sum; } if (first_sum || sum > max_signal_length) { max_signal_length = sum; } first_sum = 0; } for (i = 0; i < send_buffer_length(); i++) { if (i & 1) { /* space */ if (send_buffer_data()[i] > max_space) { max_space = send_buffer_data()[i]; } } else { /* pulse */ if (send_buffer_data()[i] > max_pulse) { max_pulse = send_buffer_data()[i]; } } } } } } while (next); c++; } if (first_sum) { /* no timing data, so assume gap is the actual total length */ remote->min_total_signal_length = min_gap(remote); remote->max_total_signal_length = max_gap(remote); remote->min_gap_length = min_gap(remote); remote->max_gap_length = max_gap(remote); } else if (is_const(remote)) { if (remote->min_total_signal_length > max_signal_length) { remote->min_gap_length = remote->min_total_signal_length - max_signal_length; } else { logprintf(LIRC_WARNING, "min_gap_length is 0 for '%s' remote", remote->name); remote->min_gap_length = 0; } if (remote->max_total_signal_length > min_signal_length) { remote->max_gap_length = remote->max_total_signal_length - min_signal_length; } else { logprintf(LIRC_WARNING, "max_gap_length is 0 for '%s' remote", remote->name); remote->max_gap_length = 0; } } else { remote->min_total_signal_length = min_signal_length + remote->min_gap_length; remote->max_total_signal_length = max_signal_length + remote->max_gap_length; } LOGPRINTF(1, "lengths: %lu %lu %lu %lu", remote->min_total_signal_length, remote->max_total_signal_length, remote->min_gap_length, remote->max_gap_length); }
static int hwftdi_send(struct ir_remote* remote, struct ir_ncode* code) { __u32 f_sample = tx_baud_rate * 8; __u32 f_carrier = remote->freq == 0 ? DEFAULT_FREQ : remote->freq; __u32 div_carrier; int val_carrier; const lirc_t* pulseptr; lirc_t pulse; int n_pulses; int pulsewidth; int bufidx; int sendpulse; unsigned char buf[TXBUFSZ]; logprintf(LIRC_DEBUG, "hwftdi_send() carrier=%dHz f_sample=%dHz ", f_carrier, f_sample); /* initialize decoded buffer: */ if (!send_buffer_put(remote, code)) return 0; /* init vars: */ n_pulses = send_buffer_length(); pulseptr = send_buffer_data(); bufidx = 0; div_carrier = 0; val_carrier = 0; sendpulse = 0; while (n_pulses--) { /* take pulse from buffer */ pulse = *pulseptr++; /* compute the pulsewidth (in # samples) */ pulsewidth = ((__u64)f_sample) * ((__u32)(pulse & PULSE_MASK)) / 1000000ul; /* toggle pulse / space */ sendpulse = sendpulse ? 0 : 1; while (pulsewidth--) { /* carrier generator (generates a carrier * continously, will be modulated by the * requested signal): */ div_carrier += f_carrier * 2; if (div_carrier >= f_sample) { div_carrier -= f_sample; val_carrier = val_carrier ? 0 : 255; } /* send carrier or send space ? */ if (sendpulse) buf[bufidx++] = val_carrier; else buf[bufidx++] = 0; /* flush txbuffer? */ /* note: be sure to have room for last '0' */ if (bufidx >= (TXBUFSZ - 1)) { logprintf(LIRC_ERROR, "buffer overflow while generating IR pattern"); return 0; } } } /* always end with 0 to turn off transmitter: */ buf[bufidx++] = 0; /* let the child process transmit the pattern */ chk_write(pipe_main2tx[1], buf, bufidx); /* wait for child process to be ready with it */ chk_read(pipe_tx2main[0], buf, 1); return 1; }