LIRC libraries
LinuxInfraredRemoteControl
irrecord.h File Reference

Library part of irrecord, functions to identify unknown remotes. More...

#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <syslog.h>
#include <unistd.h>
#include "lirc_private.h"

Go to the source code of this file.

Classes

struct  lengths
 
struct  opts
 Parsed run-time options, reflects long_options and the command line, mostly a const object. More...
 
struct  main_state
 Overall state in main. More...
 
struct  gap_state
 Private state in get_gap_length(). More...
 
struct  lengths_state
 State in get_lengths(), private besides commented. More...
 
struct  toggle_state
 Private state in get_togggle_bit_mask(). More...
 
struct  button_state
 State while recording buttons, privates besides commented. More...
 

Macros

#define min(a, b)   (a > b ? b : a)
 
#define max(a, b)   (a > b ? a : b)
 
#define BUTTON   (80 + 1)
 
#define RETRIES   10
 
#define MAX_SIGNALS   200
 
#define TH_SPACE_ENC   80 /* I want less than 20% mismatches */
 
#define TH_HEADER   90
 
#define TH_REPEAT   90
 
#define TH_TRAIL   90
 
#define TH_LEAD   90
 
#define TH_IS_BIT   10
 
#define TH_RC6_SIGNAL   550
 
#define MIN_GAP   20000
 
#define MAX_GAP   100000
 
#define SAMPLES   80
 

Typedefs

typedef void(* remote_func) (struct ir_remote *remotes)
 

Enumerations

enum  analyse_mode { MODE_GET_GAP, MODE_HAVE_GAP }
 
enum  lengths_status {
  STS_LEN_OK, STS_LEN_FAIL, STS_LEN_RAW_OK, STS_LEN_TIMEOUT,
  STS_LEN_AGAIN, STS_LEN_AGAIN_INFO, STS_LEN_NO_GAP_FOUND, STS_LEN_TOO_LONG
}
 Return from one attempt to determine lengths in get_lengths(). More...
 
enum  get_gap_status {
  STS_GAP_INIT, STS_GAP_TIMEOUT, STS_GAP_FOUND, STS_GAP_GOT_ONE_PRESS,
  STS_GAP_AGAIN
}
 Return form one attempt to get gap in get_gap(). More...
 
enum  toggle_status {
  STS_TGL_TIMEOUT, STS_TGL_GOT_ONE_PRESS, STS_TGL_NOT_FOUND, STS_TGL_FOUND,
  STS_TGL_AGAIN
}
 Return from one attempt in get_toggle_bit_mask(). More...
 
enum  button_status {
  STS_BTN_INIT, STS_BTN_GET_NAME, STS_BTN_INIT_DATA, STS_BTN_GET_RAW_DATA,
  STS_BTN_GET_DATA, STS_BTN_GET_TOGGLE_BITS, STS_BTN_RECORD_DONE, STS_BTN_BUTTON_DONE,
  STS_BTN_BUTTONS_DONE, STS_BTN_ALL_DONE, STS_BTN_SOFT_ERROR, STS_BTN_HARD_ERROR,
  STS_BTN_TIMEOUT
}
 Return from one pass in record_buttons(). More...
 

Functions

ssize_t raw_read (void *buffer, size_t size, unsigned int timeout_us)
 Absolute error tolerance (us). More...
 
void for_each_remote (struct ir_remote *remotes, remote_func func)
 Unconditionally apply func(remote) for all items in remotes list. More...
 
void btn_state_set_message (struct button_state *state, const char *fmt,...)
 sprintf-style message formatting into state->message. More...
 
void flushhw (void)
 Clear the driver input buffers. More...
 
void gap_state_init (struct gap_state *state)
 Initiate a pristine gap_state. More...
 
void lengths_state_init (struct lengths_state *state)
 Initiate a pristine lengths_state. More...
 
void toggle_state_init (struct toggle_state *state)
 Initiate a pristine toggle_state. More...
 
void button_state_init (struct button_state *state, int started_as_root)
 Initiate a pristine button_state. More...
 
enum get_gap_status get_gap_length (struct gap_state *state, struct ir_remote *remote)
 Try to find out gap length, returning gap_status. More...
 
enum lengths_status get_lengths (struct lengths_state *state, struct ir_remote *remote, int force, int interactive)
 Try to find out pre/post etc. More...
 
void free_all_lengths (void)
 Free heap data allocated by get_lengths(). More...
 
enum toggle_status get_toggle_bit_mask (struct toggle_state *state, struct ir_remote *remote)
 Try to find out toggle_bit_mask, returning toggle_status. More...
 
int do_analyse (const struct opts *opts, struct main_state *state)
 The –analyse wrapper, returns boolean ok/fail. More...
 
enum button_status record_buttons (struct button_state *btn_state, enum button_status last_status, struct main_state *state, const struct opts *opts)
 Try to record one button, returning button_status. More...
 
void config_file_setup (struct main_state *state, const struct opts *opts)
 Write the provisionary config file. More...
 
int config_file_finish (struct main_state *state, const struct opts *opts)
 Write the final config file. More...
 
void get_pre_data (struct ir_remote *remote)
 Test hook: Extract remote->pre_data from remote->bits. More...
 
void get_post_data (struct ir_remote *remote)
 Test hook: Extract remote->post_data and post_data_bits from bits. More...
 
void remove_pre_data (struct ir_remote *remote)
 Test hook: Move remote->pre_data into remote->bits. More...
 
void remove_post_data (struct ir_remote *remote)
 Test hook: Move remote->post_data into remote->bits. More...
 
void invert_data (struct ir_remote *remote)
 Test hook: Invert all data items in remote. More...
 
void remove_trail (struct ir_remote *remote)
 Test hook: Move remote->trail into remote->bits. More...
 

Variables

struct ir_remote remote
 
unsigned int eps
 Shared list of remotes. More...
 
lirc_t aeps
 Error tolerance in per cent. More...
 

Detailed Description

Library part of irrecord, functions to identify unknown remotes.

Definition in file irrecord.h.

Enumeration Type Documentation

◆ button_status

Return from one pass in record_buttons().

Definition at line 124 of file irrecord.h.

◆ get_gap_status

Return form one attempt to get gap in get_gap().

Definition at line 104 of file irrecord.h.

◆ lengths_status

Return from one attempt to determine lengths in get_lengths().

Definition at line 91 of file irrecord.h.

◆ toggle_status

Return from one attempt in get_toggle_bit_mask().

Definition at line 114 of file irrecord.h.

Function Documentation

◆ btn_state_set_message()

void btn_state_set_message ( struct button_state state,
const char *  fmt,
  ... 
)

sprintf-style message formatting into state->message.

sprintf-style message formatting into state->message.

Definition at line 97 of file irrecord.c.

◆ button_state_init()

void button_state_init ( struct button_state state,
int  started_as_root 
)

Initiate a pristine button_state.

Definition at line 219 of file irrecord.c.

◆ config_file_finish()

int config_file_finish ( struct main_state state,
const struct opts opts 
)

Write the final config file.

Definition at line 2106 of file irrecord.c.

◆ config_file_setup()

void config_file_setup ( struct main_state state,
const struct opts opts 
)

Write the provisionary config file.

Definition at line 2089 of file irrecord.c.

◆ do_analyse()

int do_analyse ( const struct opts opts,
struct main_state state 
)

The –analyse wrapper, returns boolean ok/fail.

The –analyse wrapper, returns boolean ok/fail.

Definition at line 1776 of file irrecord.c.

◆ flushhw()

void flushhw ( void  )

Clear the driver input buffers.

Definition at line 139 of file irrecord.c.

◆ for_each_remote()

void for_each_remote ( struct ir_remote remotes,
remote_func  func 
)

Unconditionally apply func(remote) for all items in remotes list.

Definition at line 491 of file irrecord.c.

◆ free_all_lengths()

void free_all_lengths ( void  )

Free heap data allocated by get_lengths().

Definition at line 664 of file irrecord.c.

◆ gap_state_init()

void gap_state_init ( struct gap_state state)

Initiate a pristine gap_state.

Definition at line 189 of file irrecord.c.

◆ get_gap_length()

enum get_gap_status get_gap_length ( struct gap_state state,
struct ir_remote remote 
)

Try to find out gap length, returning gap_status.

Definition at line 1207 of file irrecord.c.

◆ get_lengths()

enum lengths_status get_lengths ( struct lengths_state state,
struct ir_remote remote,
int  force,
int  interactive 
)

Try to find out pre/post etc.

lengths, returning lengths_status.

Definition at line 1387 of file irrecord.c.

◆ get_post_data()

void get_post_data ( struct ir_remote remote)

Test hook: Extract remote->post_data and post_data_bits from bits.

Definition at line 327 of file irrecord.c.

◆ get_pre_data()

void get_pre_data ( struct ir_remote remote)

Test hook: Extract remote->pre_data from remote->bits.

Definition at line 269 of file irrecord.c.

◆ get_toggle_bit_mask()

enum toggle_status get_toggle_bit_mask ( struct toggle_state state,
struct ir_remote remote 
)

Try to find out toggle_bit_mask, returning toggle_status.

Definition at line 1545 of file irrecord.c.

◆ invert_data()

void invert_data ( struct ir_remote remote)

Test hook: Invert all data items in remote.

Definition at line 424 of file irrecord.c.

◆ lengths_state_init()

void lengths_state_init ( struct lengths_state state)

Initiate a pristine lengths_state.

Definition at line 195 of file irrecord.c.

◆ raw_read()

ssize_t raw_read ( void *  buffer,
size_t  size,
unsigned int  timeout_us 
)

Absolute error tolerance (us).

Try to read some bytes from the device, no decoding whatsoever.

Definition at line 1804 of file irrecord.c.

◆ record_buttons()

enum button_status record_buttons ( struct button_state btn_state,
enum button_status  last_status,
struct main_state state,
const struct opts opts 
)

Try to record one button, returning button_status.

Definition at line 1835 of file irrecord.c.

◆ remove_post_data()

void remove_post_data ( struct ir_remote remote)

Test hook: Move remote->post_data into remote->bits.

Definition at line 403 of file irrecord.c.

◆ remove_pre_data()

void remove_pre_data ( struct ir_remote remote)

Test hook: Move remote->pre_data into remote->bits.

Definition at line 383 of file irrecord.c.

◆ remove_trail()

void remove_trail ( struct ir_remote remote)

Test hook: Move remote->trail into remote->bits.

Definition at line 463 of file irrecord.c.

◆ toggle_state_init()

void toggle_state_init ( struct toggle_state state)

Initiate a pristine toggle_state.

Definition at line 211 of file irrecord.c.

Variable Documentation

◆ aeps

lirc_t aeps

Error tolerance in per cent.

Definition at line 63 of file irrecord.c.

◆ eps

unsigned int eps

Shared list of remotes.

Definition at line 62 of file irrecord.c.