2021-05-29 21:52:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex/views/view.hpp>
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
2021-06-05 22:39:47 +02:00
|
|
|
#include <mutex>
|
2021-05-29 21:52:52 +02:00
|
|
|
#include <thread>
|
2021-06-05 22:39:47 +02:00
|
|
|
#include <vector>
|
2021-05-29 21:52:52 +02:00
|
|
|
|
2021-06-06 18:19:17 +02:00
|
|
|
namespace hex::plugin::windows {
|
2021-05-29 21:52:52 +02:00
|
|
|
|
|
|
|
namespace prv { class Provider; }
|
|
|
|
|
|
|
|
class ViewTTYConsole : public View {
|
|
|
|
public:
|
|
|
|
ViewTTYConsole();
|
|
|
|
~ViewTTYConsole() override;
|
|
|
|
|
|
|
|
void drawContent() override;
|
|
|
|
void drawMenu() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::pair<std::string, std::string>> m_comPorts;
|
|
|
|
|
|
|
|
std::vector<std::pair<std::string, std::string>> getAvailablePorts();
|
|
|
|
bool connect();
|
|
|
|
bool disconnect();
|
|
|
|
|
2021-06-05 22:39:47 +02:00
|
|
|
void transmitData(std::vector<char> &data);
|
2021-05-29 21:52:52 +02:00
|
|
|
|
|
|
|
HANDLE m_portHandle = INVALID_HANDLE_VALUE;
|
|
|
|
std::jthread m_receiveThread;
|
|
|
|
|
|
|
|
int m_selectedPort = 0;
|
|
|
|
int m_selectedBaudRate = 11; // 115200
|
|
|
|
int m_selectedNumBits = 3; // 8
|
|
|
|
int m_selectedStopBits = 0; // 1
|
|
|
|
int m_selectedParityBits = 0; // None
|
|
|
|
bool m_hasCTSFlowControl = false; // No
|
|
|
|
|
|
|
|
bool m_shouldAutoScroll = true;
|
|
|
|
|
2021-06-05 22:39:47 +02:00
|
|
|
std::mutex m_receiveBufferMutex;
|
2021-05-29 21:52:52 +02:00
|
|
|
std::vector<char> m_receiveDataBuffer, m_transmitDataBuffer;
|
|
|
|
std::vector<u32> m_wrapPositions;
|
|
|
|
bool m_transmitting = false;
|
|
|
|
|
|
|
|
constexpr static std::array BaudRates = {
|
|
|
|
"110",
|
|
|
|
"300",
|
|
|
|
"600",
|
|
|
|
"1200",
|
|
|
|
"2400",
|
|
|
|
"4800",
|
|
|
|
"9600",
|
|
|
|
"14400",
|
|
|
|
"19200",
|
|
|
|
"38400",
|
|
|
|
"57600",
|
|
|
|
"115200",
|
|
|
|
"128000",
|
|
|
|
"256000"
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr static std::array NumBits = {
|
|
|
|
"5",
|
|
|
|
"6",
|
|
|
|
"7",
|
|
|
|
"8"
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr static std::array StopBits = {
|
|
|
|
"1",
|
|
|
|
"1.5",
|
|
|
|
"2.0"
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr static std::array ParityBits = {
|
|
|
|
"None",
|
|
|
|
"Odd",
|
|
|
|
"Even",
|
|
|
|
"Mark",
|
|
|
|
"Space"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|