21 #include <boost/format.hpp> 22 #include <sys/socket.h> 24 #include <sys/ioctl.h> 38 string devFrontend =
str( boost::format(
"/dev/dvb/adapter%d/frontend%d") % adapter % device);
39 int f = open(devFrontend.c_str(), flags);
57 prefix_ void senf::DVBFrontendSocketProtocol::tune(
const struct dvb_frontend_parameters & frontend)
61 if (::ioctl(fd(), FE_SET_FRONTEND, &frontend) )
66 fe_spectral_inversion_t inversion,
67 fe_bandwidth_t bandwidth,
68 fe_code_rate_t code_rate_HP,
69 fe_code_rate_t code_rate_LP,
70 fe_modulation_t constellation,
71 fe_transmit_mode_t transmission_mode,
72 fe_guard_interval_t guard_interval,
73 fe_hierarchy_t hierarchy_information
77 struct dvb_ofdm_parameters ofdm;
78 struct dvb_frontend_parameters frontend;
80 ::memset(&frontend, 0,
sizeof(
struct dvb_frontend_parameters));
81 ::memset(&ofdm, 0,
sizeof(
struct dvb_ofdm_parameters));
83 ofdm.bandwidth = bandwidth;
84 ofdm.code_rate_HP = code_rate_HP;
85 ofdm.code_rate_LP = code_rate_LP;
86 ofdm.constellation = constellation;
87 ofdm.guard_interval = guard_interval;
88 ofdm.hierarchy_information = hierarchy_information;
90 frontend.frequency = frequency;
91 frontend.inversion = inversion;
92 frontend.u.ofdm = ofdm;
98 fe_spectral_inversion_t inversion,
99 unsigned int symbole_rate,
100 fe_code_rate_t fec_inner
104 struct dvb_qpsk_parameters qpsk;
105 struct dvb_frontend_parameters frontend;
107 ::memset(&frontend, 0,
sizeof(
struct dvb_frontend_parameters));
108 ::memset(&qpsk, 0,
sizeof(
struct dvb_qpsk_parameters));
110 qpsk.symbol_rate = symbole_rate;
111 qpsk.fec_inner = fec_inner;
113 frontend.frequency = frequency;
114 frontend.inversion = inversion;
115 frontend.u.qpsk = qpsk;
121 fe_spectral_inversion_t inversion,
122 unsigned int symbol_rate,
123 fe_code_rate_t fec_inner,
124 fe_modulation_t modulation
128 struct dvb_qam_parameters qam;
129 struct dvb_frontend_parameters frontend;
131 ::memset(&frontend, 0,
sizeof(
struct dvb_frontend_parameters));
132 ::memset(&qam, 0,
sizeof(
struct dvb_qam_parameters));
134 qam.symbol_rate = symbol_rate;
135 qam.fec_inner = fec_inner;
136 qam.modulation = modulation;
139 frontend.frequency = frequency;
140 frontend.inversion = inversion;
141 frontend.u.qam = qam;
149 ::fcntl(fd(), F_SETFL, ::fcntl(fd(), F_GETFL) | O_NONBLOCK);
151 ::fcntl(fd(), F_SETFL, ::fcntl(fd(), F_GETFL) & ~O_NONBLOCK);
157 struct dvb_frontend_info info;
158 ::memset(&info, 0,
sizeof(
struct dvb_frontend_info));
160 if (::ioctl(fd(), FE_GET_INFO, &info)) {
167 struct dvb_frontend_parameters frontend_;
169 ::memset(&frontend_, 0,
sizeof(
struct dvb_frontend_parameters));
171 if (::ioctl(fd(), FE_GET_FRONTEND, &frontend_)) {
190 struct dvb_frontend_event ev ;
192 ::memset(&ev, 0,
sizeof(
struct dvb_frontend_event));
193 if (::ioctl(fd(), FE_GET_EVENT, &ev)) {
215 if (::ioctl(fd(), FE_READ_SIGNAL_STRENGTH, &strength) < 0)
224 if (::ioctl(fd(), FE_READ_SNR, &snr) < 0)
233 if (::ioctl(fd(), FE_READ_BER, &ber) < 0)
241 uint32_t uncorrected_blocks;
242 if (::ioctl(fd(), FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks) < 0)
244 return uncorrected_blocks;
252 if (::ioctl(fd(), FE_READ_STATUS, &status) < 0)
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
uint32_t bitErrorRate() const
Returns the current bit error rate for the signal.
struct dvb_frontend_parameters getFrontendParam() const
Returns dvb_frontend_parameters struct.
std::string str(T const &t)
dvb_frontend_event getEvent() const
DVBFrontendHandle public header.
fe_status_t status() const
This ioctl call returns status information about the front-end.
unsigned available() const
Returns always 0
void tuneDVB_T(unsigned int frequency, fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth, fe_code_rate_t code_rate_HP, fe_code_rate_t code_rate_LP, fe_modulation_t constellation, fe_transmit_mode_t transmission_mode, fe_guard_interval_t guard_interval, fe_hierarchy_t hierarchy_information) const
Tunes a DVB-T device.
void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate) const
Tunes a DVB-S device.
void tuneDVB_C(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbol_rate, fe_code_rate_t fec_inner, fe_modulation_t modulation) const
Tunes a DVB-C device.
bool eof() const
Returns always false
void setNonBlock(bool on=true) const
int16_t signalNoiseRatio() const
Returns current signal-to-noise ratio.
void init_client(unsigned short adapter=0, unsigned short device=0, int flags=(O_RDWR|O_NONBLOCK)) const
Opens the specified frontend device in read-only mode.
dvb_frontend_info getInfo() const
Returns information struct.
uint32_t uncorrectedBlocks() const
Returns the number of uncorrected blocks.
int16_t signalStrength() const
Returns current signal strength.