From c63bc896771789d5059b03cd6a66788b1ab95e2c Mon Sep 17 00:00:00 2001 From: thanasipantazides Date: Fri, 22 Mar 2024 16:34:48 -0800 Subject: [PATCH] pre x-ray alignment working version with larger CdTe HK frame size --- apps/main.cpp | 24 +++++++++++------------- foxsi4-commands | 2 +- src/TransportLayer.cpp | 13 +++++++++++-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/apps/main.cpp b/apps/main.cpp index c704cb8..3da75c2 100644 --- a/apps/main.cpp +++ b/apps/main.cpp @@ -203,19 +203,17 @@ int main(int argc, char** argv) { auto new_downlink_buffer = std::make_shared>(); std::cout << "uart: \n"; - if (do_uart) { - if (deck->get_sys_for_name("timepix").uart) { - std::cout << "timepix has uart interface\n"; - std::cout << "uart interface: " << deck->get_sys_for_name("timepix").uart->to_string(); - } else { - std::cout << "timepix has no uart interface!\n"; - } - if (deck->get_sys_for_name("uplink").uart) { - std::cout << "uplink has uart interface\n"; - std::cout << "uart interface: " << deck->get_sys_for_name("uplink").uart->to_string(); - } else { - std::cout << "uplink has no uart interface!\n"; - } + if (deck->get_sys_for_name("timepix").uart) { + std::cout << "timepix has uart interface\n"; + std::cout << "uart interface: " << deck->get_sys_for_name("timepix").uart->to_string(); + } else { + std::cout << "timepix has no uart interface!\n"; + } + if (deck->get_sys_for_name("uplink").uart) { + std::cout << "uplink has uart interface\n"; + std::cout << "uart interface: " << deck->get_sys_for_name("uplink").uart->to_string(); + } else { + std::cout << "uplink has no uart interface!\n"; } diff --git a/foxsi4-commands b/foxsi4-commands index d63c8f6..9844c1d 160000 --- a/foxsi4-commands +++ b/foxsi4-commands @@ -1 +1 @@ -Subproject commit d63c8f68ef4e27c531a1da0105e52fbe3da69894 +Subproject commit 9844c1d0586df9edc585cc6bb15b6c56b9949e06 diff --git a/src/TransportLayer.cpp b/src/TransportLayer.cpp index 13d092b..52d9efe 100644 --- a/src/TransportLayer.cpp +++ b/src/TransportLayer.cpp @@ -795,8 +795,8 @@ size_t TransportLayerMachine::sync_remote_buffer_transaction(SystemManager &sys_ utilities::debug_print("\tpacket framer frame.size(): " + std::to_string(pf->get_frame().size()) + "\n"); // write to log - utilities::debug_log("PacketFramer::frame: "); - utilities::trace_log(pf->get_frame()); + // utilities::debug_log("PacketFramer::frame: "); + // utilities::trace_log(pf->get_frame()); // push the frame onto the downlink queue while (!fp->frame_emptied()) { @@ -808,6 +808,9 @@ size_t TransportLayerMachine::sync_remote_buffer_transaction(SystemManager &sys_ // clear the old frame to use the PacketFramer again. pf->clear_frame(); + // should be clear, but just in case clear FramePacketizer for next time. + fp->clear_frame(); + utilities::debug_print("\tpushed ring buffer data to downlink buffer\n"); return last_write_pointer; @@ -924,9 +927,11 @@ std::vector TransportLayerMachine::sync_send_command_to_system(SystemMa uint8_t protocol_id = reply.at(reply.size() - 7); if (status == 0x00) { // utilities::debug_print("\tstatus byte == 0x00!\n"); + utilities::debug_log("TransportLayerMachine::sync_send_command_to_system()\tsuccessfully dispatched command " + cmd.name + ", raw form " + utilities::bytes_to_string(packet) + " to " + sys_man.system.name); break; } else { utilities::error_print("SpaceWire status not confirmed (status == " + std::to_string(status) + ")! Retrying write.\n"); + utilities::error_log("TransportLayerMachine::sync_send_command_to_system()\tcould not confirm write command. Retry " + std::to_string(try_counter)); // try again: ++try_counter; continue; @@ -959,6 +964,7 @@ std::vector TransportLayerMachine::sync_send_command_to_system(SystemMa size_t reply_size = TransportLayerMachine::read(local_tcp_housekeeping_sock, reply, sys_man); reply.resize(reply_size); } + utilities::debug_log("TransportLayerMachine::sync_send_command_to_system()\tdispatched command " + cmd.name + ", raw form " + utilities::bytes_to_string(packet) + " to " + sys_man.system.name); } else if (cmd.type == COMMAND_TYPE_OPTIONS::UART) { utilities::debug_print("sending "); utilities::hex_print(packet); @@ -972,6 +978,7 @@ std::vector TransportLayerMachine::sync_send_command_to_system(SystemMa if (reply_size > 0) { utilities::debug_print("reply: " + utilities::bytes_to_string(reply) + "\n"); } + utilities::debug_log("TransportLayerMachine::sync_send_command_to_system()\tdispatched command " + cmd.name + ", raw form " + utilities::bytes_to_string(packet) + " to " + sys_man.system.name); } } else { utilities::error_print("uncommandable type!\n"); @@ -1052,9 +1059,11 @@ void TransportLayerMachine::sync_uart_receive_to_uplink_buffer(SystemManager &up UplinkBufferElement new_uplink(reply, *commands); (uplink_buffer->at(commands->get_sys_for_code(sys_code))).enqueue(new_uplink); + utilities::debug_log("TransportLayerMachine::sync_uart_receive_to_uplink_buffer()\tqueued command " + new_uplink.get_command()->name + " for " + new_uplink.get_system()->name); } catch (std::out_of_range& e) { // todo: log the error. utilities::error_print("could not add uplink command to queue!\n"); + utilities::error_log("TransportLayerMachine::sync_uart_receive_to_uplink_buffer()\tfailed to store an uplink command!"); return; } utilities::debug_print("\tstored uplink commands\n");