summaryrefslogtreecommitdiff
path: root/include/serial/SerialPort.hpp
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2023-04-08 13:36:34 -0400
committerGitHub <noreply@github.com>2023-04-08 13:36:34 -0400
commitc3946e1a73aec0eb75ff4301dc42e1a2a71aab60 (patch)
tree9bfd6b6df4666491295b30088a6bf7bec6f61757 /include/serial/SerialPort.hpp
parent0fd63dfa5dfcac42a45f0b247e8461b4b969d6f7 (diff)
parent3180cb7584c037463ee5c2047aea3e3ed0f0b364 (diff)
Merge pull request #1 from ChausseBenjamin/console-uiHEADmaster
Diffstat (limited to 'include/serial/SerialPort.hpp')
-rw-r--r--include/serial/SerialPort.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/serial/SerialPort.hpp b/include/serial/SerialPort.hpp
new file mode 100644
index 0000000..a207d0c
--- /dev/null
+++ b/include/serial/SerialPort.hpp
@@ -0,0 +1,31 @@
+/*
+* Author: Manash Kumar Mandal
+* Modified Library introduced in Arduino Playground which does not work
+* This works perfectly
+* LICENSE: MIT
+*/
+
+#pragma once
+
+#define ARDUINO_WAIT_TIME 2000
+#define MAX_DATA_LENGTH 255
+
+#include <windows.h>
+#include <iostream>
+
+class SerialPort
+{
+private:
+ HANDLE handler;
+ bool connected;
+ COMSTAT status;
+ DWORD errors;
+public:
+ explicit SerialPort(const char *portName, int BAUD);
+ ~SerialPort();
+
+ int readSerialPort(const char *buffer, unsigned int buf_size);
+ bool writeSerialPort(const char *buffer, unsigned int buf_size);
+ bool isConnected();
+ void closeSerial();
+}; \ No newline at end of file