Skip to content

Commit ee5d27f

Browse files
Jari PoyhonenJari Poyhonen
authored andcommitted
Pull request feedback fix: add poll support to multiplexer
1 parent 1d03bfb commit ee5d27f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

features/cellular/framework/mux/cellular_mux.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,4 +1238,16 @@ ssize_t Mux::user_data_rx(void* buffer, size_t size)
12381238
}
12391239

12401240

1241+
short Mux::poll()
1242+
{
1243+
_mutex.lock();
1244+
1245+
const bool writable = (_tx_context.tx_state == TX_IDLE);
1246+
const bool readable = (_rx_context.rx_state == RX_SUSPEND);
1247+
1248+
_mutex.unlock();
1249+
1250+
return ((readable ? POLLIN : 0) | (writable ? POLLOUT : 0));
1251+
}
1252+
12411253
} // namespace mbed

features/cellular/framework/mux/cellular_mux.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ class MuxDataService : public FileHandle
7272
*/
7373
virtual ssize_t read(void *buffer, size_t size);
7474

75+
/** Check for poll event flags
76+
*
77+
* The input parameter can be used or ignored - could always return all events, or could check just the events
78+
* listed in events.
79+
*
80+
* Call is non-blocking - returns instantaneous state of events.
81+
*
82+
* @param events Bitmask of poll events we're interested in - POLLIN/POLLOUT etc.
83+
* @return Bitmask of poll events that have occurred.
84+
*/
85+
virtual short poll(short events) const;
86+
7587
/** Not supported by the implementation. */
7688
virtual off_t seek(off_t offset, int whence = SEEK_SET);
7789

@@ -434,6 +446,12 @@ class Mux
434446
*/
435447
static ssize_t user_data_rx(void* buffer, size_t size);
436448

449+
/** Check for poll event flags
450+
*
451+
* @return Bitmask of poll events that have occurred - POLLIN/POLLOUT.
452+
*/
453+
static short poll();
454+
437455
/** Clear TX callback pending bit.
438456
*
439457
* @param bit Bit to clear.

features/cellular/framework/mux/cellular_mux_data_service.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ ssize_t MuxDataService::read(void *buffer, size_t size)
3131
}
3232

3333

34+
short MuxDataService::poll(short events) const
35+
{
36+
return Mux::poll();
37+
}
38+
39+
3440
off_t MuxDataService::seek(off_t offset, int whence)
3541
{
3642
MBED_ASSERT(false);

0 commit comments

Comments
 (0)