3 #include <lib/base/init.h>
4 #include <lib/base/init_num.h>
6 #include <lib/base/eerror.h>
7 #include <lib/dvb_ci/dvbci.h>
8 #include <lib/dvb_ci/dvbci_session.h>
10 eDVBCIInterfaces::eDVBCIInterfaces()
14 eDebug("scanning for common interfaces..");
20 sprintf(filename, "/dev/ci%d", num_ci);
22 if (stat(filename, &s))
25 ePtr<eDVBCISlot> cislot;
27 cislot = new eDVBCISlot(eApp, num_ci);
28 m_slots.push_back(cislot);
33 eDebug("done, found %d common interfaces");
36 eDVBCIInterfaces::~eDVBCIInterfaces()
40 int eDVBCISlot::send(const unsigned char *data, size_t len)
47 printf("%02x ",data[i]);
50 res = ::write(fd, data, len);
52 printf("write() %d\n",res);
54 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
59 void eDVBCISlot::data(int what)
61 if(what == eSocketNotifier::Priority) {
62 if(state != stateRemoved) {
64 printf("ci removed\n");
65 notifier->setRequested(eSocketNotifier::Read);
73 r = ::read(fd, data, 4096);
75 // eWarning("ERROR reading from CI - %m\n");
77 if(state != stateInserted) {
78 state = stateInserted;
79 eDebug("ci inserted");
81 /* enable HUP to detect removal or errors */
82 //notifier_event->start();
83 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
90 printf("%02x ",data[i]);
92 //eDebug("ci talks to us");
93 eDVBCISession::receiveData(this, data, r);
94 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
98 if(what == eSocketNotifier::Write) {
100 if(eDVBCISession::pollAll() == 0) {
101 printf("disable pollout\n");
102 notifier->setRequested(eSocketNotifier::Read | eSocketNotifier::Priority);
108 DEFINE_REF(eDVBCISlot);
110 eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
114 sprintf(filename, "/dev/ci%d", nr);
116 fd = ::open(filename, O_RDWR | O_NONBLOCK);
118 eDebug("eDVBCISlot has fd %d", fd);
122 notifier = new eSocketNotifier(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority);
123 CONNECT(notifier->activated, eDVBCISlot::data);
130 eDVBCISlot::~eDVBCISlot()
134 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");