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