summaryrefslogtreecommitdiffstats
path: root/sw-linux/rom-loader/serial.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sw-linux/rom-loader/serial.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/sw-linux/rom-loader/serial.hpp b/sw-linux/rom-loader/serial.hpp
new file mode 100644
index 0000000..35b35be
--- /dev/null
+++ b/sw-linux/rom-loader/serial.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <string>
+
+extern "C" {
+#include <termios.h>
+}
+
+class serial
+{
+public:
+ serial(const std::string& port, speed_t baud);
+ ~serial();
+
+ int write(const std::string& data) const;
+ int write(const char * const data, size_t len) const;
+
+ char read() const;
+ std::string read(size_t howmany) const;
+
+private:
+ int m_fd;
+ struct termios m_settings;
+};