-#include "../../../Utils/Exception.hh"
-#include "../../../Utils/Logger/Logger.hh"
-#include <../../../Utils/membind.hh>
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Anton Gillert <atx@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#include "senf/Utils/Exception.hh"
+#include "senf/Utils/Logger/Logger.hh"
+#include "senf/Utils/membind.hh"
#include "DVBSocketController.hh"
#include <sstream>
prefix_ senf::DVBSocketController::~DVBSocketController()
{
}
-prefix_ string senf::DVBSocketController::tuneToCMD(const string & configLine, const string & mode){
+prefix_ void senf::DVBSocketController::tuneToCMD(const string & input, const string & mode){
struct dvb_frontend_parameters frontend;
// no valid configline, so it will be treaten like a channel name
- if (configLine.find(":")==string::npos){
- if (mode.c_str()[0]=='a'){
- tuneTo(configLine);
- return "async readConfFile";
- }
- else{
- tuneTo_sync(configLine);
- return "sync readConfFile";
- }
-
+ if (input.find(":")==string::npos){
+ if (mode.c_str()[0]=='a')
+ tuneTo(input);
+ else
+ tuneTo_sync(input);
+ return;
}
- // add psydo name to complete configline syntax
- frontend = parser.getFrontendParam("foo:"+configLine);
+ // add psydo name "foo" to complete configline syntax
+ frontend = parser.getFrontendParam("foo:"+input);
if (mode.c_str()[0]=='a'){
switch (type) {
default:
SENF_THROW_SYSTEM_EXCEPTION("Could not determine type of card.");
}
- return "async get directly";
}
else {
switch (type) {
default:
SENF_THROW_SYSTEM_EXCEPTION("Could not determine type of card.");
}
- return "sync get directly";
}
}
{
if(type != FE_OFDM)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-T Card!";
+
event.enable();
+
frontendHandle.protocol().setNonBlock();
frontendHandle.protocol().tuneDVB_T(frequency,
inversion,
prefix_ void senf::DVBSocketController::tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate){
if(type != FE_QPSK)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-S Card!";
+
event.enable();
+
frontendHandle.protocol().setNonBlock();
frontendHandle.protocol().tuneDVB_S(frequency, inversion, symbole_rate, code_rate);
}
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-C Card!";
event.enable();
+
frontendHandle.protocol().setNonBlock();
frontendHandle.protocol().tuneDVB_C(frequency, inversion, symbol_rate, fec_inner, modulation);
{
if(type != FE_OFDM)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-T Card!";
+
event.disable();
+
frontendHandle.protocol().setNonBlock(false);
frontendHandle.protocol().tuneDVB_T(frequency,
prefix_ dvb_frontend_event senf::DVBSocketController::tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate){
if(type != FE_QPSK)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-S Card!";
+
event.disable();
+
frontendHandle.protocol().setNonBlock(false);
+
frontendHandle.protocol().tuneDVB_S(frequency, inversion, symbole_rate, code_rate);
if(!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-C Card!";
event.disable();
+
frontendHandle.protocol().setNonBlock(false);
+
frontendHandle.protocol().tuneDVB_C(frequency, inversion, symbol_rate, fec_inner, modulation);
if(!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
SENF_THROW_SYSTEM_EXCEPTION("Could not tune to channel!");
stringstream info;
fe_status_t status;
+ frontendHandle.protocol().setNonBlock(false);
uint16_t snr, signal;
uint32_t ber, uncorrected_blocks;
status = frontendHandle.protocol().status();
info << hex;
for(unsigned int i = 0; i < conf.size(); ++i){
+ if(i>0)
+ info << " | ";
switch(cConf[i]){
case 'S' :
- info << " | signal " << signal;
+ info << "signal " << signal;
break;
case 's' :
- info << " | snr " << snr;
+ info << "snr " << snr;
break;
case 'b' :
- info << " | ber " << ber;
+ info << "ber " << ber;
break;
case 'u' :
- info << " | unc " << uncorrected_blocks;
+ info << "unc " << uncorrected_blocks;
break;
case 'f' :
- info << " | status: " << status2String(status);
+ info << "status: " << status2String(status);
break;
default:
break;
prefix_ string senf::DVBSocketController::status2String(fe_status_t status){
string s("");
if (status & FE_HAS_LOCK)
- return s += "|HAS LOCK";
+ return s += "HAS LOCK";
if (status & FE_HAS_CARRIER)
- s += "|HAS CARRIER";
+ s += "HAS CARRIER";
if (status & FE_HAS_VITERBI)
- s += "|HAS VITERBI";
+ s += "HAS VITERBI";
if (status & FE_HAS_SYNC)
- s += "|HAS SYNC";
+ s += "HAS SYNC";
if (status & FE_HAS_SIGNAL)
- s += "|HAS SIGNAL";
+ s += "HAS SIGNAL";
if (status & FE_TIMEDOUT)
- s += "|TIMED OUT";
+ s += "TIMED OUT";
if (status & FE_REINIT)
- s += "|REINIT";
+ s += "REINIT";
return s;
}
prefix_ void senf::DVBSocketController::setSectionFilter(unsigned short int pid,
- unsigned char filter,
+ u_int8_t filter,
unsigned int flags,
- unsigned char mask,
- unsigned char mode,
+ u_int8_t mask,
+ u_int8_t mode,
unsigned int timeout)
{
sectionHandle.protocol().setSectionFilter(pid, timeout, flags, filter, mask, mode);
sectionHandle.protocol().stopFiltering();
}
-
prefix_ fe_type_t senf::DVBSocketController::getType(){
return type;
}
prefix_ void senf::DVBSocketController::readEvent(int event){
- cb(frontendHandle.protocol().getEvent());
+ if(cb)
+ cb(frontendHandle.protocol().getEvent());
}
prefix_ void senf::DVBSocketController::initConsole(){
and could end in throwing an exception!")
.arg("conf", "Ssbuf", kw::default_value = "Ssbuf");
- dir.add("tuneTo", &DVBSocketController::tuneToCMD)
+ dir.add("tune", &DVBSocketController::tuneToCMD)
.doc("tunes to channel listet in the configfile.")
.arg("channel", "channel to tune")
.arg("mode", "mode \"sync\" or \"async\"", kw::default_value = "async");