added first (prototype) handle for the DVB frontend device
tho [Fri, 20 Jul 2007 13:49:38 +0000 (13:49 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@330 270642c3-0616-0410-b53a-bc976706d245

Examples/DVBAdapter/MPEdec.cc [moved from Examples/DVBdec/MPEdec.cc with 100% similarity]
Examples/DVBAdapter/SConscript [moved from Examples/DVBdec/SConscript with 52% similarity]
Examples/DVBAdapter/ULEdec.cc [moved from Examples/DVBdec/ULEdec.cc with 100% similarity]
Examples/DVBAdapter/frontend.cc [new file with mode: 0644]
Packets/Mainpage.dox
Socket/DVBDemuxHandles.hh
Socket/DVBDemuxProtocol.cc
Socket/DVBDemuxProtocol.hh
Socket/DVBFrontendHandle.cc [new file with mode: 0644]
Socket/DVBFrontendHandle.hh [new file with mode: 0644]

similarity index 52%
rename from Examples/DVBdec/SConscript
rename to Examples/DVBAdapter/SConscript
index f18f7dd..c1618e3 100644 (file)
@@ -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/DVBAdapter/frontend.cc b/Examples/DVBAdapter/frontend.cc
new file mode 100644 (file)
index 0000000..f291905
--- /dev/null
@@ -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 <stefan.bund@fokus.fraunhofer.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 <string>
+#include <iostream>
+#include <iomanip>
+#include <sys/ioctl.h>
+#include <linux/sockios.h>
+#include <linux/dvb/dmx.h> 
+
+#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_
+
+\f
+// 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:
index 0855250..f412bfa 100644 (file)
 
     \li <a href="../../DefaultBundle/doc/html/index.html">DefaultBundle</a>: Some basic
         default protocols: Ethernet, Ip, TCP, UDP
-    \li <a href="../../MPEG_DVBBundle/doc/html/index.html">MPEG_DVBBundle</a>: MPEG and DVB
+    \li <a href="../../MPEGDVBBundle/doc/html/index.html">MPEGDVBBundle</a>: MPEG and DVB
         protocols
  */
 
index 6823577..574757d 100644 (file)
 #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"
 
index 00c07c5..dcc3a62 100644 (file)
@@ -39,8 +39,6 @@
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
-
-
 prefix_ void senf::DVBDemuxProtocol::setBufferSize(unsigned long size)
     const
 {
index ab9e571..9e2f4d0 100644 (file)
@@ -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 (file)
index 0000000..651565d
--- /dev/null
@@ -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 <stefan.bund@fokus.fraunhofer.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.
+
+/** \file
+    \brief xxx
+ */
+
+#include "DVBFrontendHandle.hh"
+//#include "DVBFrontendHandle.ih"
+
+// Custom includes
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <iostream>
+#include <string>
+#include <sys/ioctl.h>
+#include <linux/sockios.h>
+#include <stdio.h>
+#include <fcntl.h>
+#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::SocketProtocol> senf::DVBFrontendProtocol::clone()
+    const
+{
+    return std::auto_ptr<SocketProtocol>(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"
+
+\f
+// 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 (file)
index 0000000..e8381b1
--- /dev/null
@@ -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 <stefan.bund@fokus.fraunhofer.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.
+
+/** \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 <linux/dvb/frontend.h> 
+
+//#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<DVBFrontend_Policy>
+    {
+    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<SocketProtocol> clone() const;
+
+        ///@}
+        
+        void signalStrength(int16_t *strength) const;
+    };
+
+    typedef ProtocolClientSocketHandle<DVBFrontendProtocol> DVBFrontendHandle;
+
+}
+
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "DVBFrontendHandle.cci"
+//#include "DVBFrontendHandle.ct"
+//#include "DVBFrontendHandle.cti"
+#endif
+
+\f
+// 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: