Skip to content

Commit

Permalink
Adjust DeviceBuffer to use OPENMRN_FEATURE_DEVTAB instead of ARDUINO …
Browse files Browse the repository at this point in the history
…define. (#474)
  • Loading branch information
atanisoft authored Nov 24, 2020
1 parent a22e3cb commit 2e5358e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/freertos_drivers/common/DeviceBuffer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@

#include "DeviceBuffer.hxx"

#ifndef ARDUINO
#include "openmrn_features.h"

#ifdef OPENMRN_FEATURE_DEVTAB

#include <sys/select.h>

Expand All @@ -61,4 +63,4 @@ void DeviceBufferBase::block_until_condition(File *file, bool read)
::select(fd + 1, read ? &fds : NULL, read ? NULL : &fds, NULL, NULL);
}

#endif
#endif // OPENMRN_FEATURE_DEVTAB
26 changes: 14 additions & 12 deletions src/freertos_drivers/common/DeviceBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,45 @@
#include <cstdint>
#include <unistd.h>
#include <stdlib.h>

#include "openmrn_features.h"
#include "utils/macros.h"

#ifndef ARDUINO
#ifdef OPENMRN_FEATURE_DEVTAB
#include "Devtab.hxx"
#endif
#endif // OPENMRN_FEATURE_DEVTAB

/** Helper for DeviceBuffer which allows for methods to not be inlined.
*/
class DeviceBufferBase
{
public:
#ifndef ARDUINO
#ifdef OPENMRN_FEATURE_DEVTAB
/** Wait for blocking condition to become true.
* @param file file to wait on
* @param read true if this is a read operation, false for write operation
*/
static void block_until_condition(File *file, bool read);
#endif
#endif // OPENMRN_FEATURE_DEVTAB

/** Signal the wakeup condition. This will also wakeup select.
*/
void signal_condition()
{
#ifndef ARDUINO
#ifdef OPENMRN_FEATURE_DEVTAB
Device::select_wakeup(&selectInfo);
#endif
#endif // OPENMRN_FEATURE_DEVTAB
}

/** Signal the wakeup condition from an ISR context. This will also
* wakeup select.
*/
void signal_condition_from_isr()
{
#ifndef ARDUINO
#ifdef OPENMRN_FEATURE_DEVTAB
int woken = 0;
Device::select_wakeup_from_isr(&selectInfo, &woken);
#endif
#endif // OPENMRN_FEATURE_DEVTAB
}

/** flush all the data out of the buffer and reset the buffer. It is
Expand Down Expand Up @@ -110,9 +112,9 @@ public:
*/
void select_insert()
{
#ifndef ARDUINO
#ifdef OPENMRN_FEATURE_DEVTAB
return Device::select_insert(&selectInfo);
#endif
#endif // OPENMRN_FEATURE_DEVTAB
}

/** Remove a number of items from the buffer by advancing the readIndex.
Expand Down Expand Up @@ -180,10 +182,10 @@ protected:
{
}

#ifndef ARDUINO
#ifdef OPENMRN_FEATURE_DEVTAB
/** Metadata for select() logic */
Device::SelectInfo selectInfo;
#endif
#endif // OPENMRN_FEATURE_DEVTAB

/** level of space required in buffer in order to wakeup, 0 if unused */
uint16_t level;
Expand Down

0 comments on commit 2e5358e

Please sign in to comment.