3 #include <lib/base/eerror.h>
4 #include <lib/dvb_ci/dvbci.h>
5 #include <lib/dvb_ci/dvbci_session.h>
7 eDVBCIInterfaces::eDVBCIInterfaces()
11 eDebug("scanning for common interfaces..");
16 sprintf(filename, "/dev/ci%d", num_ci);
18 if (stat(filename, &s))
21 ePtr<eDVBCISlot> cislot;
23 cislot = new eDVBCISlot(eApp, num_ci);
24 m_slots.push_back(cislot);
29 eDebug("done, found %d common interfaces");
32 int eDVBCISlot::write(const unsigned char *data, size_t len)
34 return ::write(fd, data, len);
37 void eDVBCISlot::data(int)
39 eDebug("ci talks to us");
43 r = ::read(fd, data, 4096);
45 eWarning("ERROR reading from CI - %m\n");
47 if(state != stateInserted) {
48 state = stateInserted;
49 eDebug("ci inserted");
51 /* enable HUP to detect removal or errors */
52 notifier_event->start();
56 eDVBCISession::receiveData(this, data, r);
59 void eDVBCISlot::event(int)
65 /* kill the TransportConnection */
67 /* we know about and disable HUP */
68 notifier_event->stop();
71 eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
75 sprintf(filename, "/dev/ci%d", nr);
77 fd = ::open(filename, O_RDWR | O_NONBLOCK);
79 eDebug("eDVBCISlot has fd %d", fd);
84 notifier_data = new eSocketNotifier(context, fd, eSocketNotifier::Read);
85 CONNECT(notifier_data->activated, eDVBCISlot::data);
87 notifier_event = new eSocketNotifier(context, fd, eSocketNotifier::Hungup);
88 CONNECT(notifier_event->activated, eDVBCISlot::event);