From: tho Date: Fri, 20 Jul 2007 13:49:38 +0000 (+0000) Subject: added first (prototype) handle for the DVB frontend device X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=65066c0e037d1de437d6121903e1dd511b41e940;p=senf.git added first (prototype) handle for the DVB frontend device git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@330 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/DVBdec/MPEdec.cc b/Examples/DVBAdapter/MPEdec.cc similarity index 100% rename from Examples/DVBdec/MPEdec.cc rename to Examples/DVBAdapter/MPEdec.cc diff --git a/Examples/DVBdec/SConscript b/Examples/DVBAdapter/SConscript similarity index 52% rename from Examples/DVBdec/SConscript rename to Examples/DVBAdapter/SConscript index f18f7dd..c1618e3 100644 --- a/Examples/DVBdec/SConscript +++ b/Examples/DVBAdapter/SConscript @@ -1,12 +1,14 @@ Import('env') import SENFSCons -########################################################################### +import glob +import os.path -SENFSCons.Binary(env, 'uledec', 'ULEdec.cc', - LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ], - OBJECTS = [ '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o' ]); +########################################################################### -SENFSCons.Binary(env, 'mpedec', 'MPEdec.cc', +for f in glob.glob('*.cc'): + bin = os.path.splitext(f)[0] + + SENFSCons.Binary(env, bin, f, LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ], OBJECTS = [ '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o' ]); diff --git a/Examples/DVBdec/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc similarity index 100% rename from Examples/DVBdec/ULEdec.cc rename to Examples/DVBAdapter/ULEdec.cc diff --git a/Examples/DVBAdapter/frontend.cc b/Examples/DVBAdapter/frontend.cc new file mode 100644 index 0000000..f291905 --- /dev/null +++ b/Examples/DVBAdapter/frontend.cc @@ -0,0 +1,73 @@ +// $Id: ULEdec.cc 327 2007-07-20 10:03:44Z tho $ +// +// Copyright (C) 2006 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund +// +// 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 +#include +#include +#include +#include +#include + +#include "Scheduler/Scheduler.hh" +#include "Packets/DefaultBundle/EthernetPacket.hh" +#include "Packets/MPEGDVBBundle/DatagramSection.hh" +#include "Utils/membind.hh" +#include "Socket/DVBFrontendHandle.hh" +#include "Packets/ParseInt.hh" +#include "Packets/Packet.hh" +#include "Packets/PacketData.hh" + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +int main(int argc, char const * argv[]) +{ + try { + senf::DVBFrontendHandle handle; + int16_t strength; + + while (true) { + handle.protocol().signalStrength(&strength); + std::cout << "signal strength: " << strength << "\n"; + sleep(1); + } + } + catch (std::exception const & ex) { + std::cerr << senf::prettyName(typeid(ex)) << ": " << ex.what() << "\n"; + } + return 0; +} + + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 +// End: diff --git a/Packets/Mainpage.dox b/Packets/Mainpage.dox index 0855250..f412bfa 100644 --- a/Packets/Mainpage.dox +++ b/Packets/Mainpage.dox @@ -135,7 +135,7 @@ \li DefaultBundle: Some basic default protocols: Ethernet, Ip, TCP, UDP - \li MPEG_DVBBundle: MPEG and DVB + \li MPEGDVBBundle: MPEG and DVB protocols */ diff --git a/Socket/DVBDemuxHandles.hh b/Socket/DVBDemuxHandles.hh index 6823577..574757d 100644 --- a/Socket/DVBDemuxHandles.hh +++ b/Socket/DVBDemuxHandles.hh @@ -28,11 +28,9 @@ #define HH_DVBDemuxHandles_ 1 // Custom includes -#include "BSDSocketProtocol.hh" #include "FramingPolicy.hh" #include "CommunicationPolicy.hh" #include "ReadWritePolicy.hh" -#include "BufferingPolicy.hh" #include "ProtocolClientSocketHandle.hh" #include "DVBDemuxProtocol.hh" diff --git a/Socket/DVBDemuxProtocol.cc b/Socket/DVBDemuxProtocol.cc index 00c07c5..dcc3a62 100644 --- a/Socket/DVBDemuxProtocol.cc +++ b/Socket/DVBDemuxProtocol.cc @@ -39,8 +39,6 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// - - prefix_ void senf::DVBDemuxProtocol::setBufferSize(unsigned long size) const { diff --git a/Socket/DVBDemuxProtocol.hh b/Socket/DVBDemuxProtocol.hh index ab9e571..9e2f4d0 100644 --- a/Socket/DVBDemuxProtocol.hh +++ b/Socket/DVBDemuxProtocol.hh @@ -31,7 +31,6 @@ // Custom includes #include "SocketProtocol.hh" -#include "INetAddressing.hh" //#include "DVBProtocol.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -54,15 +53,11 @@ namespace senf { ///\name Abstract Interface Implementation ///@{ - - //unsigned available() const; + bool eof() const; ///@} - - }; - } ///////////////////////////////hh.e//////////////////////////////////////// diff --git a/Socket/DVBFrontendHandle.cc b/Socket/DVBFrontendHandle.cc new file mode 100644 index 0000000..651565d --- /dev/null +++ b/Socket/DVBFrontendHandle.cc @@ -0,0 +1,98 @@ +// $Id: DVBDemuxHandles.cc 329 2007-07-20 12:29:34Z tho $ +// +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund +// +// 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. + +/** \file + \brief xxx + */ + +#include "DVBFrontendHandle.hh" +//#include "DVBFrontendHandle.ih" + +// Custom includes +#include +#include +#include +#include +#include +#include +#include +#include +#include "SocketHandle.hh" + +#include "Utils/Exception.hh" + +//#include "DVBFrontendHandle.mpp" +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// senf::DVBFrontendHandle + +prefix_ void senf::DVBFrontendProtocol::init_client() + const +{ + int fd = open("/dev/dvb/adapter0/frontend0", O_RDONLY | O_NONBLOCK); + if (fd < 0) + throw SystemException(errno); + body().fd(fd); +} + +prefix_ unsigned senf::DVBFrontendProtocol::available() + const +{ + return 0; +} + +prefix_ bool senf::DVBFrontendProtocol::eof() + const +{ + return false; +} + +prefix_ std::auto_ptr senf::DVBFrontendProtocol::clone() + const +{ + return std::auto_ptr(new DVBFrontendProtocol()); +} + + +prefix_ void senf::DVBFrontendProtocol::signalStrength(int16_t *strength) + const +{ + if (::ioctl(body().fd(), FE_READ_SIGNAL_STRENGTH, strength) < 0) + throw SystemException(errno); +} + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ +//#include "DVBFrontendHandle.mpp" + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 +// End: diff --git a/Socket/DVBFrontendHandle.hh b/Socket/DVBFrontendHandle.hh new file mode 100644 index 0000000..e8381b1 --- /dev/null +++ b/Socket/DVBFrontendHandle.hh @@ -0,0 +1,105 @@ +// $Id: DVBDemuxSectionHandle.hh 321 2007-07-19 09:00:23Z tho $ +// +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund +// +// 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. + +/** \file + \brief DVBHandles + */ + +#ifndef HH_DVBFrontendHandle_ +#define HH_DVBFrontendHandle_ 1 + +// Custom includes +#include "FramingPolicy.hh" +#include "CommunicationPolicy.hh" +#include "ReadWritePolicy.hh" +#include "ProtocolClientSocketHandle.hh" +#include "SocketProtocol.hh" + +#include + +//#include "DVBFrontendHandle.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { + + /// \addtogroup concrete_protocol_group + /// @{ + + typedef MakeSocketPolicy< + NoAddressingPolicy, + DatagramFramingPolicy, + UnconnectedCommunicationPolicy, + NotReadablePolicy, + NotWriteablePolicy + >::policy DVBFrontend_Policy; ///< Socket Policy for xxxx + + /** \brief xxx + */ + class DVBFrontendProtocol + : public ConcreteSocketProtocol + { + public: + /////////////////////////////////////////////////////////////////////////// + // internal interface + + ///\name Constructors + ///@{ + + void init_client() const; ///< xxx + /**< \note This member is implicitly called from the + ProtocolClientSocketHandle::ProtocolClientSocketHandle() + constructor */ + + ///@} + ///\name Abstract Interface Implementation + + unsigned available() const; + bool eof() const; + + std::auto_ptr clone() const; + + ///@} + + void signalStrength(int16_t *strength) const; + }; + + typedef ProtocolClientSocketHandle DVBFrontendHandle; + +} + + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "DVBFrontendHandle.cci" +//#include "DVBFrontendHandle.ct" +//#include "DVBFrontendHandle.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 +// End: