92{
93
94 TLOG() <<
"Board: " <<
m_ip <<
", sending command " << cmd;
95 std::vector<uint64_t> bytes;
96 for (char ch : cmd) {
97 bytes.push_back(static_cast<uint64_t>(ch));
98 }
99 bytes.push_back(0x0d);
100
102
103
104 for (size_t i = 0; i < (bytes.size() + 49) / 50; ++i) {
105 std::vector<uint64_t> part(bytes.begin() + i * 50, bytes.begin() + std::min((i + 1) * 50, bytes.size()));
107 }
108
109 TLOG() <<
"Board: " <<
m_ip <<
", Command sent, waiting for result";
110
111 command_result res;
112 std::string* writing_pointer = nullptr;
113
114 auto start_time = std::chrono::high_resolution_clock::now();
115
116 int more = 40;
117 while (more > 0) {
119 for (size_t i = 0; i < data_block.size(); ++i) {
120 if (data_block[i] == 255) {
121 break;
122 } else if (data_block[i] == 1) {
123
124 writing_pointer = &res.
command;
125 } else if (data_block[i] == 2) {
126
127 writing_pointer = &res.
result;
128 } else if (data_block[i] == 3) {
129
130 writing_pointer = nullptr;
131 } else if (isprint(static_cast<int>(data_block[i]))) {
132 more = 40;
133 char c =
static_cast<char>(data_block[i]);
134 if (writing_pointer) {
135 *writing_pointer += static_cast<char>(data_block[i]);
136 } else {
137 TLOG() <<
"Failed adding charachter " <<
c;
138 }
139 }
140 }
141 auto now = std::chrono::high_resolution_clock::now();
142
144
146 TLOG() <<
"Details of timeout";
147 for (size_t i = 0; i < data_block.size(); ++i) {
148 TLOG() << i <<
"\t" << std::hex << data_block[i] << std::dec;
149 }
151 auto delay_us = std::chrono::duration_cast<std::chrono::microseconds>(delay);
152 throw CommandTimeout(
ERS_HERE, cmd, delay_us.count());
153 }
154
155 std::this_thread::sleep_for(std::chrono::milliseconds(1));
156 --more;
157 }
158
159 return res;
160}
std::vector< uint64_t > read_buffer(uint64_t addr, uint8_t size) const
void write_buffer(uint64_t addr, std::vector< uint64_t > &&data) const
std::mutex m_command_mutex