2021-05-29 21:52:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <hex/ui/view.hpp>
|
2021-05-29 21:52:52 +02:00
|
|
|
|
2021-06-05 22:39:47 +02:00
|
|
|
#include <mutex>
|
2021-05-29 21:52:52 +02:00
|
|
|
#include <thread>
|
2023-11-02 20:21:38 +01:00
|
|
|
#include <jthread.hpp>
|
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
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
class ViewTTYConsole : public View::Window {
|
2021-05-29 21:52:52 +02:00
|
|
|
public:
|
|
|
|
ViewTTYConsole();
|
2022-03-04 20:52:39 +01:00
|
|
|
~ViewTTYConsole() override = default;
|
2021-05-29 21:52:52 +02:00
|
|
|
|
|
|
|
void drawContent() override;
|
|
|
|
|
|
|
|
private:
|
2024-06-28 11:12:17 +02:00
|
|
|
std::vector<std::pair<std::wstring, std::wstring>> m_comPorts;
|
2021-05-29 21:52:52 +02:00
|
|
|
|
2024-06-28 11:12:17 +02:00
|
|
|
std::vector<std::pair<std::wstring, std::wstring>> getAvailablePorts() const;
|
2021-05-29 21:52:52 +02:00
|
|
|
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
|
|
|
|
2023-11-30 10:22:15 +01:00
|
|
|
void* m_portHandle = reinterpret_cast<void*>(-1);
|
2021-05-29 21:52:52 +02:00
|
|
|
std::jthread m_receiveThread;
|
|
|
|
|
2022-02-01 22:09:44 +01:00
|
|
|
int m_selectedPort = 0;
|
|
|
|
int m_selectedBaudRate = 11; // 115200
|
|
|
|
int m_selectedNumBits = 3; // 8
|
|
|
|
int m_selectedStopBits = 0; // 1
|
2022-01-24 20:53:17 +01:00
|
|
|
int m_selectedParityBits = 0; // None
|
|
|
|
bool m_hasCTSFlowControl = false; // No
|
2021-05-29 21:52:52 +02:00
|
|
|
|
|
|
|
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 = {
|
2022-01-24 20:53:17 +01:00
|
|
|
"110",
|
|
|
|
"300",
|
|
|
|
"600",
|
|
|
|
"1200",
|
|
|
|
"2400",
|
|
|
|
"4800",
|
|
|
|
"9600",
|
|
|
|
"14400",
|
|
|
|
"19200",
|
|
|
|
"38400",
|
|
|
|
"57600",
|
|
|
|
"115200",
|
|
|
|
"128000",
|
|
|
|
"256000"
|
2021-05-29 21:52:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
constexpr static std::array NumBits = {
|
2022-01-24 20:53:17 +01:00
|
|
|
"5",
|
|
|
|
"6",
|
|
|
|
"7",
|
|
|
|
"8"
|
2021-05-29 21:52:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
constexpr static std::array StopBits = {
|
2022-01-24 20:53:17 +01:00
|
|
|
"1",
|
|
|
|
"1.5",
|
|
|
|
"2.0"
|
2021-05-29 21:52:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
constexpr static std::array ParityBits = {
|
2022-01-24 20:53:17 +01:00
|
|
|
"None",
|
|
|
|
"Odd",
|
|
|
|
"Even",
|
|
|
|
"Mark",
|
|
|
|
"Space"
|
2021-05-29 21:52:52 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|