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 #include <lib/dvb_ci/dvbci_ui.h>
12 eDVBCIInterfaces::eDVBCIInterfaces()
16 eDebug("scanning for common interfaces..");
22 sprintf(filename, "/dev/ci%d", num_ci);
24 if (stat(filename, &s))
27 ePtr<eDVBCISlot> cislot;
29 cislot = new eDVBCISlot(eApp, num_ci);
30 m_slots.push_back(cislot);
35 eDebug("done, found %d common interface slots", num_ci);
38 eDVBCIInterfaces::~eDVBCIInterfaces()
42 int eDVBCISlot::send(const unsigned char *data, size_t len)
48 // printf("%02x ",data[i]);
51 res = ::write(fd, data, len);
53 //printf("write() %d\n",res);
55 notifier->setRequested(eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
60 void eDVBCISlot::data(int what)
62 if(what == eSocketNotifier::Priority) {
63 if(state != stateRemoved) {
65 printf("ci removed\n");
66 notifier->setRequested(eSocketNotifier::Read);
68 eDVBCI_UI::getInstance()->setState(0,0);
76 r = ::read(fd, data, 4096);
78 if(state != stateInserted) {
79 state = stateInserted;
80 eDebug("ci inserted");
83 eDVBCI_UI::getInstance()->setState(0,1);
85 /* enable PRI to detect removal or errors */
86 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
93 // printf("%02x ",data[i]);
95 eDVBCISession::receiveData(this, data, r);
96 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
100 if(what == eSocketNotifier::Write) {
101 if(eDVBCISession::pollAll() == 0) {
102 notifier->setRequested(eSocketNotifier::Read | eSocketNotifier::Priority);
107 DEFINE_REF(eDVBCISlot);
109 eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
113 sprintf(filename, "/dev/ci%d", nr);
115 fd = ::open(filename, O_RDWR | O_NONBLOCK);
117 eDebug("eDVBCISlot has fd %d", fd);
121 notifier = new eSocketNotifier(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority);
122 CONNECT(notifier->activated, eDVBCISlot::data);
129 eDVBCISlot::~eDVBCISlot()
133 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");