Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceBuffer conditional compilation cleanup #474

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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