...
This commit is contained in:
parent
eb09de7a21
commit
c8829d6ee6
@ -112,13 +112,15 @@ std::string formatByteArr(const std::ranges::range auto& bytes, std::string_view
|
|||||||
{
|
{
|
||||||
std::string res;
|
std::string res;
|
||||||
|
|
||||||
|
using el_t = std::make_unsigned_t<std::ranges::range_value_t<decltype(bytes)>>;
|
||||||
|
|
||||||
auto sz = std::ranges::size(bytes);
|
auto sz = std::ranges::size(bytes);
|
||||||
|
|
||||||
if (!sz) {
|
if (!sz) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& el : bytes | std::views::take(sz - 1)) {
|
for (el_t el : bytes | std::views::take(sz - 1)) {
|
||||||
res += std::format("0x{:02X}{}", el, delim);
|
res += std::format("0x{:02X}{}", el, delim);
|
||||||
}
|
}
|
||||||
res += std::format("0x{:02X}", *(bytes.end() - 1));
|
res += std::format("0x{:02X}", *(bytes.end() - 1));
|
||||||
@ -351,11 +353,11 @@ bool RaptorEagleCCD::initCamera(int unitmap)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = resetMicro();
|
// ok = resetMicro();
|
||||||
if (!ok) {
|
// if (!ok) {
|
||||||
logError("Cannot reset microcontroller!");
|
// logError("Cannot reset microcontroller!");
|
||||||
return ok;
|
// return ok;
|
||||||
}
|
// }
|
||||||
|
|
||||||
getSystemState();
|
getSystemState();
|
||||||
|
|
||||||
@ -411,7 +413,7 @@ size_t RaptorEagleCCD::clRead(byte_seq_t& bytes)
|
|||||||
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap));
|
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap));
|
||||||
|
|
||||||
if (!nbytes) {
|
if (!nbytes) {
|
||||||
logWarn("There are no bytes in Rx-buffer! Waiting for {} as timeout ...", CL_DEFAULT_TIMEOUT);
|
logWarn("There are no bytes in Rx-buffer! Polling buffer during {} ...", CL_DEFAULT_TIMEOUT);
|
||||||
while ((std::chrono::steady_clock::now() - start_tp) <= CL_DEFAULT_TIMEOUT) {
|
while ((std::chrono::steady_clock::now() - start_tp) <= CL_DEFAULT_TIMEOUT) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
nbytes = pxd_serialRead(_cameraUnitmap, 0, nullptr, 0);
|
nbytes = pxd_serialRead(_cameraUnitmap, 0, nullptr, 0);
|
||||||
@ -424,9 +426,14 @@ size_t RaptorEagleCCD::clRead(byte_seq_t& bytes)
|
|||||||
logWarn("Cameralink reading operation timeout!");
|
logWarn("Cameralink reading operation timeout!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// here the call is only for logging purpose
|
||||||
|
xclibApiCall(nbytes = pxd_serialRead(_cameraUnitmap, 0, nullptr, 0),
|
||||||
|
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
nbytes += _clCommandAckBit + _clChecksumBit;
|
|
||||||
|
// nbytes += _clCommandAckBit + _clChecksumBit;
|
||||||
|
|
||||||
if (bytes.size() < nbytes) {
|
if (bytes.size() < nbytes) {
|
||||||
bytes.resize(nbytes);
|
bytes.resize(nbytes);
|
||||||
@ -434,7 +441,7 @@ size_t RaptorEagleCCD::clRead(byte_seq_t& bytes)
|
|||||||
|
|
||||||
xclibApiCall(pxd_serialRead(_cameraUnitmap, 0, (char*)bytes.data(), nbytes),
|
xclibApiCall(pxd_serialRead(_cameraUnitmap, 0, (char*)bytes.data(), nbytes),
|
||||||
std::format("pxd_serialRead({}, 0, {}, {}) -> [{}]", _cameraUnitmap, (void*)bytes.data(), nbytes,
|
std::format("pxd_serialRead({}, 0, {}, {}) -> [{}]", _cameraUnitmap, (void*)bytes.data(), nbytes,
|
||||||
details::formatByteArr(bytes)));
|
details::formatByteArr(bytes | std::views::take(nbytes))));
|
||||||
|
|
||||||
|
|
||||||
// if (_loggerSPtr->level() == spdlog::level::trace) {
|
// if (_loggerSPtr->level() == spdlog::level::trace) {
|
||||||
@ -454,7 +461,8 @@ size_t RaptorEagleCCD::clReadAndCheckAck(byte_seq_t& bytes)
|
|||||||
auto nbytes = clRead(bytes);
|
auto nbytes = clRead(bytes);
|
||||||
|
|
||||||
if (_clCommandAckBit && nbytes) {
|
if (_clCommandAckBit && nbytes) {
|
||||||
auto ack = *(bytes.end() - 1 - _clChecksumBit);
|
// auto ack = *(bytes.end() - 1 - _clChecksumBit);
|
||||||
|
auto ack = *(bytes.begin() + nbytes - 1 - _clChecksumBit);
|
||||||
if (ack != CL_ETX) {
|
if (ack != CL_ETX) {
|
||||||
// throw std::system_error(std::error_code(ack, RaptorEagleControllerErrorCategory::get()));
|
// throw std::system_error(std::error_code(ack, RaptorEagleControllerErrorCategory::get()));
|
||||||
throw std::system_error(ack, RaptorEagleControllerErrorCategory::get());
|
throw std::system_error(ack, RaptorEagleControllerErrorCategory::get());
|
||||||
@ -509,9 +517,12 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
|||||||
etx_checksum_bytes[1] = details::computeChecksum(bytes);
|
etx_checksum_bytes[1] = details::computeChecksum(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
xclibApiCall(
|
xclibApiCall(nbytes = pxd_serialWrite(_cameraUnitmap, 0, (char*)bytes.data(), bytes.size()),
|
||||||
nbytes = pxd_serialWrite(_cameraUnitmap, 0, (char*)bytes.data(), bytes.size()),
|
std::format("pxd_serialWrite({}, 0, [{}], {})", _cameraUnitmap, details::formatByteArr(bytes),
|
||||||
std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap, (void*)bytes.data(), bytes.size()));
|
bytes.size()));
|
||||||
|
// xclibApiCall(
|
||||||
|
// nbytes = pxd_serialWrite(_cameraUnitmap, 0, (char*)bytes.data(), bytes.size()),
|
||||||
|
// std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap, (void*)bytes.data(), bytes.size()));
|
||||||
|
|
||||||
// send trailing ETX and possible checksum bytes
|
// send trailing ETX and possible checksum bytes
|
||||||
|
|
||||||
@ -522,7 +533,7 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xclibApiCall(pxd_serialWrite(_cameraUnitmap, 0, (char*)etx_checksum_bytes, tr_nbytes),
|
xclibApiCall(pxd_serialWrite(_cameraUnitmap, 0, (char*)etx_checksum_bytes, tr_nbytes),
|
||||||
std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap,
|
std::format("pxd_serialWrite({}, 0, [{}], {})", _cameraUnitmap,
|
||||||
details::formatByteArr(std::string_view((const char*)etx_checksum_bytes, 2) |
|
details::formatByteArr(std::string_view((const char*)etx_checksum_bytes, 2) |
|
||||||
std::views::take(tr_nbytes)),
|
std::views::take(tr_nbytes)),
|
||||||
tr_nbytes));
|
tr_nbytes));
|
||||||
@ -668,22 +679,30 @@ bool RaptorEagleCCD::resetFPGA(const std::chrono::milliseconds& timeout)
|
|||||||
cnt > 10 ? std::chrono::milliseconds(cnt / 10) : std::chrono::milliseconds(10);
|
cnt > 10 ? std::chrono::milliseconds(cnt / 10) : std::chrono::milliseconds(10);
|
||||||
|
|
||||||
// clearSystemStateBit(CL_SYSTEM_STATUS_FPGA_RST_HOLD_BIT); // set bit to 0 to hold FPGA in reset state
|
// clearSystemStateBit(CL_SYSTEM_STATUS_FPGA_RST_HOLD_BIT); // set bit to 0 to hold FPGA in reset state
|
||||||
setSystemState(0x52);
|
clWrite({0x4F, 0x52});
|
||||||
|
clRead(ack); // ignore answer
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
setSystemState(0x50);
|
clWrite({0x4F, 0x50});
|
||||||
|
clRead(ack); // ignore answer
|
||||||
// setSystemStateBit(CL_SYSTEM_STATUS_FPGA_RST_HOLD_BIT); // set bit to 1 to boot FPGA
|
// setSystemStateBit(CL_SYSTEM_STATUS_FPGA_RST_HOLD_BIT); // set bit to 1 to boot FPGA
|
||||||
|
|
||||||
|
clWrite({0x4F, 0x52});
|
||||||
|
clRead(ack); // ignore answer
|
||||||
|
|
||||||
// according to instruction manual rev 1.1 FPGA will take approximately 500msecs to reset
|
// according to instruction manual rev 1.1 FPGA will take approximately 500msecs to reset
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
|
||||||
// poll controller
|
// poll controller
|
||||||
auto start = std::chrono::steady_clock::now();
|
auto start = std::chrono::steady_clock::now();
|
||||||
do {
|
do {
|
||||||
clWrite({0x4F, 0x52});
|
clWrite({0x49});
|
||||||
std::this_thread::sleep_for(sleep_dur);
|
std::this_thread::sleep_for(sleep_dur);
|
||||||
clRead(ack);
|
clRead(ack);
|
||||||
|
|
||||||
if (ack[0] == CL_ETX) {
|
auto bits = std::bitset<8>(ack[0]);
|
||||||
|
|
||||||
|
if (bits.test(CL_SYSTEM_STATUS_FPGA_BOOT_OK_BIT)) {
|
||||||
|
// logInfo("bits = {}", bits.to_string());
|
||||||
logInfo("Camera FPGA is reset successfully!");
|
logInfo("Camera FPGA is reset successfully!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -708,6 +727,7 @@ void RaptorEagleCCD::getHardwareInfo()
|
|||||||
|
|
||||||
// get manufacturer data
|
// get manufacturer data
|
||||||
clWrite({0x53, 0xAE, 0x05, 0x01, 0x00, 0x00, 0x02, 0x00});
|
clWrite({0x53, 0xAE, 0x05, 0x01, 0x00, 0x00, 0x02, 0x00});
|
||||||
|
clReadAndCheckAck();
|
||||||
clWrite({0x53, 0xAF, 0x12});
|
clWrite({0x53, 0xAF, 0x12});
|
||||||
clReadAndCheckAck(_manufacturerData);
|
clReadAndCheckAck(_manufacturerData);
|
||||||
|
|
||||||
@ -731,7 +751,8 @@ void RaptorEagleCCD::getHardwareInfo()
|
|||||||
// compute linear relation: Temp = k*ADC + b
|
// compute linear relation: Temp = k*ADC + b
|
||||||
_adcCCDTempCalibCoeffs[0] = (cnt2 - cnt1) / (ADC_CALIBRATION_POINT_2 - ADC_CALIBRATION_POINT_1); // k
|
_adcCCDTempCalibCoeffs[0] = (cnt2 - cnt1) / (ADC_CALIBRATION_POINT_2 - ADC_CALIBRATION_POINT_1); // k
|
||||||
_adcCCDTempCalibCoeffs[1] = ADC_CALIBRATION_POINT_2 - _adcCCDTempCalibCoeffs[0] * cnt2;
|
_adcCCDTempCalibCoeffs[1] = ADC_CALIBRATION_POINT_2 - _adcCCDTempCalibCoeffs[0] * cnt2;
|
||||||
logDebug("Computed ADC-to-Temp linear relation: Temp(C) = {:7.4}*ADC(counts)+{:6.2}");
|
logDebug("Computed ADC-to-Temp linear relation: Temp(C) = {:7.4f}*ADC(counts)+{:6.2f}", _adcCCDTempCalibCoeffs[0],
|
||||||
|
_adcCCDTempCalibCoeffs[1]);
|
||||||
|
|
||||||
logDebug("");
|
logDebug("");
|
||||||
logDebug("DAC calib data [{}, {}] counts at [{}C, {}C]", _dacTECSetPointCalibData[0], _dacTECSetPointCalibData[1],
|
logDebug("DAC calib data [{}, {}] counts at [{}C, {}C]", _dacTECSetPointCalibData[0], _dacTECSetPointCalibData[1],
|
||||||
@ -742,11 +763,13 @@ void RaptorEagleCCD::getHardwareInfo()
|
|||||||
|
|
||||||
_dacTECSetPointCalibCoeffs[0] = (cnt2 - cnt1) / (DAC_CALIBRATION_POINT_2 - DAC_CALIBRATION_POINT_1);
|
_dacTECSetPointCalibCoeffs[0] = (cnt2 - cnt1) / (DAC_CALIBRATION_POINT_2 - DAC_CALIBRATION_POINT_1);
|
||||||
_dacTECSetPointCalibCoeffs[1] = DAC_CALIBRATION_POINT_2 - _dacTECSetPointCalibCoeffs[0] * cnt2;
|
_dacTECSetPointCalibCoeffs[1] = DAC_CALIBRATION_POINT_2 - _dacTECSetPointCalibCoeffs[0] * cnt2;
|
||||||
logDebug("Computed DAC-to-Temp linear relation: Temp(C) = {:7.4}*DAC(counts)+{:6.2}");
|
logDebug("Computed DAC-to-Temp linear relation: Temp(C) = {:7.4f}*DAC(counts)+{:6.2f}",
|
||||||
|
_dacTECSetPointCalibCoeffs[0], _dacTECSetPointCalibCoeffs[1]);
|
||||||
|
|
||||||
_dacTECSetPointCalibCoeffs[2] = (DAC_CALIBRATION_POINT_2 - DAC_CALIBRATION_POINT_1) / (cnt2 - cnt1);
|
_dacTECSetPointCalibCoeffs[2] = (DAC_CALIBRATION_POINT_2 - DAC_CALIBRATION_POINT_1) / (cnt2 - cnt1);
|
||||||
_dacTECSetPointCalibCoeffs[3] = cnt2 - _dacTECSetPointCalibCoeffs[0] * DAC_CALIBRATION_POINT_2;
|
_dacTECSetPointCalibCoeffs[3] = cnt2 - _dacTECSetPointCalibCoeffs[0] * DAC_CALIBRATION_POINT_2;
|
||||||
logDebug("Computed DAC-to-Temp linear relation: DAC(counts) = {}*Temp(C)+{}");
|
logDebug("Computed DAC-to-Temp linear relation: DAC(counts) = {}*Temp(C)+{}", _dacTECSetPointCalibCoeffs[2],
|
||||||
|
_dacTECSetPointCalibCoeffs[3]);
|
||||||
|
|
||||||
logDebug("---------------------------------");
|
logDebug("---------------------------------");
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public:
|
|||||||
/* class constants */
|
/* class constants */
|
||||||
|
|
||||||
// separator char sequence of serialized representation of user FITS keywords array
|
// separator char sequence of serialized representation of user FITS keywords array
|
||||||
static constexpr std::string_view USER_FITS_KEY_SEP_SEQ{"\n"};
|
static constexpr std::string_view USER_FITS_KEY_SEP_SEQ{"\v"};
|
||||||
|
|
||||||
static constexpr size_t DEFAULT_ACQ_RING_BUFFER_SIZE = 3;
|
static constexpr size_t DEFAULT_ACQ_RING_BUFFER_SIZE = 3;
|
||||||
|
|
||||||
@ -339,7 +339,9 @@ private:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (std::ranges::size(func_name)) {
|
if (std::ranges::size(func_name)) {
|
||||||
logDebug("XCLIB API call ('{}') finished successfully", func_name);
|
logDebug("XCLIB API call ('{}') finished successfully (exitcode = {})", func_name, err);
|
||||||
|
} else {
|
||||||
|
logDebug("XCLIB API call finished successfully (exitcode = {})", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user