-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from janekbaraniewski/make-binary-as-minimal-as…
…-possible minify the binary
- Loading branch information
Showing
29 changed files
with
561 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef LOGGER_H | ||
#define LOGGER_H | ||
|
||
#include <sstream> | ||
#include <mutex> | ||
#include <string> | ||
|
||
class Logger { | ||
public: | ||
enum class Level { | ||
Info, | ||
Warning, | ||
Error | ||
}; | ||
|
||
private: | ||
std::ostringstream stream; | ||
Level logLevel; | ||
static std::mutex mtx; | ||
|
||
public: | ||
Logger(Level level = Level::Info); | ||
~Logger(); | ||
|
||
// Delete copy constructor and assignment operator | ||
Logger(const Logger&) = delete; | ||
Logger& operator=(const Logger&) = delete; | ||
Logger& operator<<(std::ostream& (*pf)(std::ostream&)); | ||
static std::string levelToString(Level level); | ||
|
||
template <typename T> | ||
Logger& operator<<(const T& msg); | ||
}; | ||
|
||
#include "Logger.inl" // Include template implementation | ||
|
||
#endif // LOGGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
template <typename T> | ||
inline Logger& Logger::operator<<(const T& msg) { | ||
stream << msg; | ||
return *this; | ||
} | ||
|
||
// Handle ostream manipulators like std::endl | ||
inline Logger& Logger::operator<<(std::ostream& (*pf)(std::ostream&)) { | ||
stream << pf; | ||
return *this; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef SERIALPORT_H | ||
#define SERIALPORT_H | ||
|
||
#include <thread> | ||
#include <atomic> | ||
#include <queue> | ||
#include <mutex> | ||
#include <condition_variable> | ||
|
||
#include "Logger.h" | ||
|
||
class SerialPort { | ||
private: | ||
int serial_fd; | ||
std::thread read_thread; | ||
std::atomic<bool> keep_reading; | ||
std::queue<std::string> read_buffer; | ||
std::mutex mtx; | ||
std::condition_variable cv; | ||
|
||
void readLoop(); | ||
void configurePort(int baud_rate); | ||
|
||
public: | ||
SerialPort(const std::string& device, int baud_rate); | ||
~SerialPort(); | ||
void startReading(); | ||
void stopReading(); | ||
void writeData(const std::string& data); | ||
std::string readData(); | ||
}; | ||
|
||
#endif // SERIALPORT_H |
Oops, something went wrong.