DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
AMCController.cpp
Go to the documentation of this file.
3#include "utilities.hpp"
4
5#include <fmt/core.h>
6#include <iostream>
7
8#include "logging/Logging.hpp"
9
10namespace dunedaq {
11namespace tdemodules {
12
13AMCController::AMCController(const std::string& ip, uint16_t data_port)
14 : m_ctrl_ip(ip)
15 , m_data_port(data_port)
16{
17
18 // Initialize status command payload
19 m_status_cmd.clear();
22
23 // Initialise start command payload
28
29 // Initialise stop command payload
30 append_big_uint32(m_stop_cmd, data_port);
34
35 // Initialise reset command payload
40}
41
42std::vector<uint8_t>
43AMCController::send_cmd(const std::vector<uint8_t>& cmd)
44{
45 std::vector<uint8_t> reply;
46 try {
47
49
50 reply = client.send_wrq(cmd);
51
52 } catch (const std::exception& e) {
53 ers::error(AMCCommandIssue(ERS_HERE, m_ctrl_ip, m_data_port, e.what()));
54 // std::cerr << "Exception: " << e.what() << "\n";
55 }
56 return reply;
57}
58
59void
64
65void
70
71void
76
77void
79{
80 std::vector<uint8_t> reply = send_cmd(m_status_cmd);
81
82 if (reply.empty()) {
83 TLOG() << "Recieved an empty reply.";
84 return;
85 }
86
87 // Take the first 4 bytes
88 boost::endian::big_uint32_t word0_be;
89 uint32_t word0;
90
91 std::memcpy(&word0_be, reply.data(), sizeof(word0_be));
92 fmt::print("word0 {:08x}\n", word0_be);
93
94 // word0 = ntohl(word0);
95 word0 = word0_be;
96 fmt::print("word0 {:08x}\n", word0);
97
98 uint32_t status = (word0 >> 16) & 0xffff;
99 uint32_t version = (word0) & 0xffff;
100
101 // # meaning of error bits
102 // ErrorBits = { 0:"ADC_CHIPID_ERR",
103 // 1:"ADC_SPEED_GRADE_ERR",
104 // 2:"ADC_ALIGN_0_ERR",
105 // 3:"ADC_ALIGN_1_ERR",
106 // 4:"ADC_SERIAL_CTRL_ERR",
107 // 5:"ADC_SAMPLE_RATE_ERR",
108 // 6:"ADC_OUTPUT_MODE_ERR",
109 // 7:"ADC_TEST_MODE_ERR",
110 // 8:"WRLEN_AMC_TIME_VALID_ERR",
111 // 9:"WRLEN_BITSLIP_ERR" }
112
113 fmt::print("status {:04x}, version {:04x}\n", status, version);
114}
115
116} // namespace tdemodules
117} // namespace dunedaq
#define ERS_HERE
std::vector< uint8_t > m_status_cmd
std::vector< uint8_t > m_start_cmd
AMCController(const std::string &ip, uint16_t data_port)
std::vector< uint8_t > m_reset_cmd
std::vector< uint8_t > send_cmd(const std::vector< uint8_t > &cmd)
std::vector< uint8_t > m_stop_cmd
AMCProtocolClient(const std::string &server_ip, uint16_t port)
#define TLOG(...)
Definition macro.hpp:21
void append_big_uint32(std::vector< uint8_t > &buffer, uint32_t value)
Definition utilities.cpp:19
The DUNE-DAQ namespace.
void error(const Issue &issue)
Definition ers.hpp:101