style refactor
This commit is contained in:
+12
-12
@@ -8,15 +8,15 @@
|
||||
#include <vector>
|
||||
|
||||
PayloadWindow::PayloadWindow() {
|
||||
std::snprintf(hex_input_buffer, sizeof(hex_input_buffer), "AA BB 01 02 03 FF");
|
||||
std::snprintf(hexInputBuffer, sizeof(hexInputBuffer), "AA BB 01 02 03 FF");
|
||||
}
|
||||
|
||||
void PayloadWindow::SendHexPayload(const std::string& hex_str, ConnectionWindow& conn_win) {
|
||||
struct sp_port* port = conn_win.GetActivePort();
|
||||
if (!conn_win.IsConnected() || !port) return;
|
||||
void PayloadWindow::sendHexPayload(const std::string& hexString, ConnectionWindow& connectionWindow) {
|
||||
struct sp_port* port = connectionWindow.getActivePort();
|
||||
if (!connectionWindow.isConnected() || !port) return;
|
||||
|
||||
std::vector<std::uint8_t> bytes;
|
||||
std::stringstream ss(hex_str);
|
||||
std::stringstream ss(hexString);
|
||||
std::string byte_string;
|
||||
|
||||
while (ss >> byte_string) {
|
||||
@@ -29,7 +29,7 @@ void PayloadWindow::SendHexPayload(const std::string& hex_str, ConnectionWindow&
|
||||
}
|
||||
|
||||
if (bytes.empty()) {
|
||||
conn_win.ForceLogMessage("[ERROR] No valid bytes found to send.");
|
||||
connectionWindow.forceLogMessage("[ERROR] No valid bytes found to send.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,25 +41,25 @@ void PayloadWindow::SendHexPayload(const std::string& hex_str, ConnectionWindow&
|
||||
for (size_t i = 0; i < bytes.size(); ++i) {
|
||||
log_ss << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (int)bytes[i] << " ";
|
||||
}
|
||||
conn_win.ForceLogMessage(log_ss.str());
|
||||
connectionWindow.forceLogMessage(log_ss.str());
|
||||
} else {
|
||||
conn_win.ForceLogMessage("[ERROR] Failed to write data to serial port.");
|
||||
connectionWindow.forceLogMessage("[ERROR] Failed to write data to serial port.");
|
||||
}
|
||||
}
|
||||
|
||||
void PayloadWindow::Render(bool* p_open, ConnectionWindow& conn_win) {
|
||||
void PayloadWindow::render(bool* p_open, ConnectionWindow& connectionWindow) {
|
||||
if (!ImGui::Begin("Raw Payload Terminal", p_open)) {
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::InputText("HEX Bytes", hex_input_buffer, IM_ARRAYSIZE(hex_input_buffer));
|
||||
ImGui::InputText("HEX Bytes", hexInputBuffer, IM_ARRAYSIZE(hexInputBuffer));
|
||||
ImGui::TextDisabled("Example: AA BB 0F 45");
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::BeginDisabled(!conn_win.IsConnected());
|
||||
ImGui::BeginDisabled(!connectionWindow.isConnected());
|
||||
if (ImGui::Button("SEND PACKET", ImVec2(-1, 35))) {
|
||||
SendHexPayload(hex_input_buffer, conn_win);
|
||||
sendHexPayload(hexInputBuffer, connectionWindow);
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user