Skip to content

Commit

Permalink
pre x-ray alignment working version with larger CdTe HK frame size
Browse files Browse the repository at this point in the history
  • Loading branch information
thanasipantazides committed Mar 23, 2024
1 parent 0f2c570 commit c63bc89
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
24 changes: 11 additions & 13 deletions apps/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,17 @@ int main(int argc, char** argv) {
auto new_downlink_buffer = std::make_shared<moodycamel::ConcurrentQueue<DownlinkBufferElement>>();

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";
}


Expand Down
13 changes: 11 additions & 2 deletions src/TransportLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -924,9 +927,11 @@ std::vector<uint8_t> 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;
Expand Down Expand Up @@ -959,6 +964,7 @@ std::vector<uint8_t> 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);
Expand All @@ -972,6 +978,7 @@ std::vector<uint8_t> 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");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit c63bc89

Please sign in to comment.