A few more style fixes.
Got rid of some trailing whitespace.
Removed one (1) instance of "not universally accepted language."
Disabled copy and assign ctors in Pin class.
diff --git a/bbb_cape/src/bbb/byte_reader.h b/bbb_cape/src/bbb/byte_reader.h
index 16e364c..952433d 100644
--- a/bbb_cape/src/bbb/byte_reader.h
+++ b/bbb_cape/src/bbb/byte_reader.h
@@ -8,11 +8,11 @@
namespace bbb {
class ByteReader {
- public:
+public:
// We have 64-bit ints in some of our data.
typedef char __attribute__((aligned(8))) AlignedChar;
- // Implemented by subclasses to provide a data source
+ // Implemented by subclasses to provide a data source
// for these algorithms.
// Returns the number of bytes read, -1 if there is an error in errno, or -2
// if reading takes longer than timeout.
@@ -20,6 +20,6 @@
const ::aos::time::Time &timeout_time) = 0;
};
-} // namespace bbb
+} // namespace bbb
-#endif // BBB_BYTE_READER_H_
+#endif // BBB_BYTE_READER_H_
diff --git a/bbb_cape/src/bbb/gpios.cc b/bbb_cape/src/bbb/gpios.cc
index 4f9dce3..8594ba4 100644
--- a/bbb_cape/src/bbb/gpios.cc
+++ b/bbb_cape/src/bbb/gpios.cc
@@ -7,6 +7,8 @@
namespace bbb {
+Pin::Pin() {}
+
Pin::~Pin() {
// Unexport the pin.
if ((handle_ = fopen("/sys/class/gpio/unexport", "ab")) == NULL) {
diff --git a/bbb_cape/src/bbb/gpios.h b/bbb_cape/src/bbb/gpios.h
index ba5da00..4925f1b 100644
--- a/bbb_cape/src/bbb/gpios.h
+++ b/bbb_cape/src/bbb/gpios.h
@@ -3,6 +3,8 @@
#include <stdio.h>
+#include "aos/common/macros.h"
+
// As it turns out, controlling the BBB's GPIO pins
// from C++ is kind of a pain. The purpose of this
// code is to provide a simple wrapper that masks
@@ -20,6 +22,10 @@
// Not strictly necessary for this to be virtual,
// but it's a good idea.
virtual ~Pin();
+ // When you don't define this and use the
+ // DISALLOW_COPY_AND_ASSIGN macro, the compiler
+ // doesn't seem to create a default one.
+ Pin();
protected:
// Set the pin direction.
@@ -33,6 +39,8 @@
FILE *handle_ = NULL;
int kernel_pin_ = -1;
+
+ DISALLOW_COPY_AND_ASSIGN(Pin);
};
} // namespace bbb
diff --git a/bbb_cape/src/bbb/gpo.cc b/bbb_cape/src/bbb/gpo.cc
index 29c5ee6..959b132 100644
--- a/bbb_cape/src/bbb/gpo.cc
+++ b/bbb_cape/src/bbb/gpo.cc
@@ -8,8 +8,8 @@
Gpo::Gpo(int bank, int pin) {
// All the failures here are fatal, seeing as
- // if we can't initialize the pin, we're probably
- // screwed anyway.
+ // failure to initialize the pin would at best
+ // severely cripple the calling process.
if (!InitPin(bank, pin)) {
LOG(FATAL, "Failed to export the pin.\n");
}
diff --git a/bbb_cape/src/bbb/gpo.h b/bbb_cape/src/bbb/gpo.h
index 701e214..596daf5 100644
--- a/bbb_cape/src/bbb/gpo.h
+++ b/bbb_cape/src/bbb/gpo.h
@@ -14,6 +14,7 @@
// If the argument is true, is sets it high.
// Otherwise, it sets it low.
bool Set(const bool high);
+
};
} // namespace bbb
diff --git a/bbb_cape/src/bbb/uart_reader_main.cc b/bbb_cape/src/bbb/uart_reader_main.cc
index 1c9ed31..f8aefbd 100644
--- a/bbb_cape/src/bbb/uart_reader_main.cc
+++ b/bbb_cape/src/bbb/uart_reader_main.cc
@@ -12,8 +12,8 @@
int main() {
::aos::Init();
- ::bbb::Gpo reset_pin = bbb::Gpo(1, 6);
-
+ ::bbb::Gpo reset_pin(1, 6);
+
::bbb::UartReader reader(750000);
::bbb::PacketFinder receiver(&reader, DATA_STRUCT_SEND_SIZE - 4);