-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArduinoReader.h
More file actions
36 lines (34 loc) · 995 Bytes
/
ArduinoReader.h
File metadata and controls
36 lines (34 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <thread>
#include "mainWindow.h"
#include "threadSafeScreen.h"
class ArduinoReader {
public:
ArduinoReader(mainWindow* window, threadSafeScreen* tss, bool resetFlag, bool debug, std::string comPort, long baud);
~ArduinoReader();
ArduinoReader(ArduinoReader const&) = delete; //can't move or copy, as neither atomic types nor threads can be copied or moved
ArduinoReader& operator =(ArduinoReader const&) = delete;
private:
void onFatalError(std::string function, unsigned long error);
void onFatalError();
unsigned int parseInt(unsigned char* buffer);
bool waitForArduinoStart();
bool readHeader();
bool mainLoop();
void startReal();
bool initializeSerial();
//pointers (owned)
HANDLE serialHandle;
DCB dcb;
//pointers (not owned)
mainWindow* window;
threadSafeScreen* tss;
//threads (owned)
std::thread readerThread;
//instance vars
std::atomic_bool shouldStop;
std::string comPort;
bool resetFlag, debugDisabled;
int xRes, yRes;
long baud;
};