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);
75 r = ::read(fd, data, 4096);
77 if(state != stateInserted) {
78 state = stateInserted;
79 eDebug("ci inserted");
82 eDVBCI_UI::getInstance()->setState(0,1);
84 /* enable PRI to detect removal or errors */
85 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
92 // printf("%02x ",data[i]);
94 eDVBCISession::receiveData(this, data, r);
95 notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write);
99 if(what == eSocketNotifier::Write) {
100 if(eDVBCISession::pollAll() == 0) {
101 notifier->setRequested(eSocketNotifier::Read | eSocketNotifier::Priority);
106 DEFINE_REF(eDVBCISlot);
108 eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
112 sprintf(filename, "/dev/ci%d", nr);
114 fd = ::open(filename, O_RDWR | O_NONBLOCK);
116 eDebug("eDVBCISlot has fd %d", fd);
118 state = stateInserted;
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");