TTL-Send_solver #2

Merged
lyf merged 2 commits from TTL-Send_solver into main 2025-12-01 18:51:38 +08:00
2 changed files with 4 additions and 2 deletions
Showing only changes of commit c2be6378b7 - Show all commits

View File

@@ -4,6 +4,7 @@
#include <chrono>
#include <thread>
#include <memory>
#include <unistd.h>
#include <opencv2/opencv.hpp>
@@ -37,11 +38,12 @@ void output_control_data(const cv::Point2f* ballistic_point,
else if (target_color == "blue") simplified_color = "b";
// Construct send string
send_str << "s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y);
send_str << "s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y) << "\n";
// Send data
if (ttl_communicator != nullptr) {
ttl_communicator->send_data(send_str.str());
}else{
std::cerr << "Error: TTLCommunicator is a null pointer!" << std::endl;
}

View File

@@ -52,7 +52,7 @@ bool TTLCommunicator::send_data(const std::string& data) {
std::cerr << "Error writing to serial port: " << strerror(errno) << std::endl;
return false;
} else {
std::cout << "Sent " << bytes_written << " bytes: " << data << std::endl;
std::cout << "Sent " << bytes_written << " bytes: " << data;
fsync(serial_fd); // Ensure data is sent
return true;
}