10 static const int IOCTL_OK = 0;
11 static const int IOCTL_ERROR = -1;
14 :
LircDevice(path, beginTimeout),endTimeout(endTimeout_),captureSize(captureSize_) {
23 std::cerr <<
"This is not a mode2 device!" << std::endl;
31 if (status != IOCTL_OK) {
32 std::cerr <<
"Error: " << status << std::endl;
46 stream <<
"Filename \"" <<
fileName <<
"\"" << std::endl;
50 stream <<
"recording mode: mode2" << std::endl;
52 stream <<
"resolution = " << resolution << std::endl;
54 stream <<
"resolution: not available" << std::endl;
78 int rc = poll(&pfd, 1, timeout ? timeout : -1);
82 return LircT::LircTType::TIMEOUT;
86 return actualLength ==
sizeof(lirc_t) ? data : 0;
104 if (index > 0 || lircT.
isPulse())
111 for (
unsigned j = 0; j < index; j++)
112 newData[j] = data[j];
120 std::cerr <<
"0 received" << std::endl;
135 bool Mode2LircDevice::sendOdd(
const lirc_t *data,
unsigned length) {
139 size_t toSend = length *
sizeof(lirc_t);
142 while (sent < toSend) {
153 return sendOdd(data, length);
155 lirc_t newData[length + 1];
156 memcpy(newData, data, length*
sizeof(lirc_t));
158 return sendOdd(newData, length+1);
168 if (status == IOCTL_ERROR) {
169 std::cerr <<
"Could not set sending frequency" << std::endl;
173 std::cerr <<
"Device does not support setting sending frequency" << std::endl;
176 return send(data, length);
bool canSendPulse() const
uint32_t frequency_t
Largest milliseconds_t number possible.
void dump(std::ostream &stream=std::cout) const
lirc_t read(int timeout)
Reads exactly one duration.
int ioctl(uint32_t cmd, uint32_t arg)
const microseconds_t * getDurations() const
int setRecTimeoutReports(bool enable)
Enable or disable timeout packages.
bool reportValidity(std::ostream &stream=std::cout) const
bool send(const lirc_t *data, unsigned length)
Mid-level sending routine.
uint32_t milliseconds_t
Type for durations in milli seconds.
static const uint32_t INVALID
size_t getLength() const
Returns the length of the data.
This is the class version of lirc_t, defined in lirc.h.
microseconds_t getDuration() const
bool canGetRecResolution() const
void report(std::ostream &stream=std::cout) const
Prints a listing of the properties implemented on the stream supplied.
void report(const char *name, bool value, std::ostream &stream) const
static const bool longReport
Flag indicating how to format reports.
void mode2dump(std::ostream &stream=std::cout)
Reads and dumps readings in mode2 format.
milliseconds_t endTimeout
static const microseconds_t replacementEndingSilence
milliseconds_t beginTimeout
This abstract class contains the common functionality of the derived classes.
uint32_t microseconds_t
Type for durations in micro seconds.
int setSendCarrier(int frequency=defaultFrequency)
Set the modulation frequency.
IrSequence * receive()
Reads a sequence.
This class consists of a vector of durations.
int write(const uint32_t *data, size_t length)
A low-level interface to the write(2) call on the file descriptor.
int setRecTimeout(int arg)
Set the integer value for IR inactivity timeout (microseconds).
bool canSetSendCarrier() const
Mode2LircDevice(const char *path=defaultFilename=defaultFilename, milliseconds_t beginTimeout=defaultBeginTimeout, size_t captureSize=defaultCaptureSize, milliseconds_t endTimeout=defaultEndTimeout)