|
RDK Documentation (Open Sourced RDK Components)
|
38 #include <sys/types.h>
40 #include "ccec/CECFrame.hpp"
41 #include "ccec/FrameListener.hpp"
42 #include "ccec/Driver.hpp"
43 #include "ccec/Exception.hpp"
44 #include "ccec/Util.hpp"
72 CCEC_LOG( LOG_DEBUG,
"Bus Instance Created\r\n");
75 CCEC_LOG( LOG_DEBUG,
"Bus Instance DONE\r\n");
84 {
AutoLock rlock_(rMutex), wlock_(wMutex);
87 if(reader.isStopped())
91 if(writer.isStopped())
96 Driver::getInstance().open();
107 {
AutoLock rlock_(rMutex), wlock_(wMutex);
115 Driver::getInstance().close();
116 CCEC_LOG(
LOG_INFO,
"Bus::stop is called reader isstop :%d writer isstop :%d \r\n",reader.isStopped(),writer.isStopped());
132 CCEC_LOG( LOG_DEBUG,
"Bus::Destroyed\r\n");
152 while (isRunning()) {
154 Driver::getInstance().read(frame);
156 if (bus.listeners.size() == 0)
CCEC_LOG( LOG_DEBUG,
"Bus::Reader discarding msgs for lack of listener\r\n");
157 std::list<FrameListener *>::iterator list_it;
158 for(list_it = bus.listeners.begin(); list_it!= bus.listeners.end(); list_it++) {
159 CCEC_LOG( LOG_DEBUG,
"Bus::Reader::run() notify Listener\r\n");
160 (*list_it)->notify(frame);
166 CCEC_LOG( LOG_DEBUG,
"EOF for reader [%d]\r\n", isRunning());
188 Driver::getInstance().close();
191 while (!isStopped()) {
195 CCEC_LOG( LOG_DEBUG,
"Bus::Reader::stop::stop completed\r\n");
211 listeners.push_back(listener);
226 listeners.remove(listener);
250 CCEC_LOG( LOG_DEBUG,
"Bus::Writer::run Looping [%d]\r\n", isRunning());
253 outFrame = bus.wQueue.poll();
255 Driver::getInstance().write(*outFrame);
258 CCEC_LOG( LOG_DEBUG,
"Bus::Writer::run EOF [%d]\r\n", isRunning());
264 CCEC_LOG( LOG_EXP,
"Driver closed writer[%d]\r\n", isRunning());
267 CCEC_LOG( LOG_EXP,
"Driver write failed\r\n");
277 while(bus.wQueue.size() > 0) {
278 outFrame = bus.wQueue.poll();
302 CCEC_LOG( LOG_DEBUG,
"Bus::Writer::stop::stop offer completed [%d]\r\n", isRunning());
307 while (!isStopped()) {
311 CCEC_LOG( LOG_DEBUG,
"Bus::Writer::stop::stop completed\r\n");
327 {
AutoLock rlock_(rMutex), wlock_(wMutex);
333 Driver::getInstance().write(frame);
334 CCEC_LOG( LOG_DEBUG,
"Bus::send write done\r\n");
337 if( frame.length() > 1)
CCEC_LOG( LOG_EXP,
"Bus::send exp caught [%s] \r\n", e.what());
343 {
AutoLock rlock_(rMutex), wlock_(wMutex);
346 int retry = (timeout / 250);
354 if( frame.length() > 1)
CCEC_LOG( LOG_EXP,
"Bus::send exp caught [%s], retry [%d]\r\n", e.what(), retry);
382 wQueue.
offer((copyFrame));
398 {
AutoLock rlock_(rMutex), wlock_(wMutex);
403 Driver::getInstance().poll(from, to);
404 CCEC_LOG( LOG_DEBUG,
"Bus::poll done\r\n");
407 CCEC_LOG( LOG_DEBUG,
"Bus::poll exp caught [%s] \r\n", e.what());
425 {
AutoLock rlock_(rMutex), wlock_(wMutex);
430 Driver::getInstance().poll(from, to);
431 CCEC_LOG( LOG_DEBUG,
"Bus::ping done\r\n");
434 CCEC_LOG( LOG_DEBUG,
"Bus::ping exp caught [%s] \r\n", e.what());
void stop(void)
This function stops the reader & writer threads and removes the instance for Bus.
void removeFrameListener(FrameListener *listener)
This function is used to remove the listener.
static Bus & getInstance(void)
This function is used to create the instance of Bus class.
void stop(bool block=true)
This function is used to stop the reader to read frames from the bus.
void poll(const LogicalAddress &from, const LogicalAddress &to)
This function is used to poll the logical address and returns the ACK or NACK received from other dev...
void stop(bool block=true)
This function is used to stop the writer for polling the bus and writing to the driver.
void sendAsync(const CECFrame &frame)
This function is used to keep asynchronously sending the frame by keeping copy of cec frame in the qu...
void run(void)
This function is used to poll the bus for frame availability and it writes the CEC frame to the drive...
Bus(void)
This function is a constructor for the class Bus. It is used to starts the read and write thread whic...
void run(void)
This function is used to read CECFrame from the driver. This gets notified to the frameListener which...
void start(void)
This function starts the threads and gets the instance for Bus.
void offer(E element)
send an event to the queue.
void start(void)
Starts excecution of the thread.
~Bus(void)
This is a destructor for class BUS. This function initiates the closing of threads and the instance f...
#define LOG_INFO(AAMP_JS_OBJECT, FORMAT,...)
void addFrameListener(FrameListener *listener)
This function is used to add new listener for reading frames.
void send(const CECFrame &frame, int timeout=0)
This function is used to write the frame to the driver. If it fails, as it is a synchronous function,...
void ping(const LogicalAddress &from, const LogicalAddress &to)
This function is used to ping devices, to know whether it present and returns the ACK or NACK receive...
void CCEC_LOG(int level, const char *format ...)
This function is used to gets the logs depending on the level of log and print these to standard outp...