fix
This commit is contained in:
48
main.cpp
48
main.cpp
@ -897,8 +897,6 @@ void expect_ok(const Api& api, int32_t err, const std::string& what) {
|
|||||||
constexpr uint32_t kE502DiSyn2Mask =
|
constexpr uint32_t kE502DiSyn2Mask =
|
||||||
(static_cast<uint32_t>(1U) << 13U) | (static_cast<uint32_t>(1U) << 17U);
|
(static_cast<uint32_t>(1U) << 13U) | (static_cast<uint32_t>(1U) << 17U);
|
||||||
constexpr uint32_t kE502Digital1Mask = (static_cast<uint32_t>(1U) << 0U);
|
constexpr uint32_t kE502Digital1Mask = (static_cast<uint32_t>(1U) << 0U);
|
||||||
constexpr uint32_t kStreamInputAdcFlag = 0x80000000U;
|
|
||||||
constexpr uint32_t kStreamInputCalibratedAdcFlag = 0x40000000U;
|
|
||||||
|
|
||||||
using TickMs = uint64_t;
|
using TickMs = uint64_t;
|
||||||
|
|
||||||
@ -1058,30 +1056,6 @@ int16_t pack_raw_code_to_int16(double avg_raw_code) {
|
|||||||
return static_cast<int16_t>(clamped);
|
return static_cast<int16_t>(clamped);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool try_extract_raw_adc_code(uint32_t word, double& raw_code) {
|
|
||||||
if ((word & kStreamInputAdcFlag) == 0U) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t value = 0;
|
|
||||||
if ((word & kStreamInputCalibratedAdcFlag) != 0U) {
|
|
||||||
const uint32_t payload = word & 0x00FFFFFFU;
|
|
||||||
value = static_cast<int32_t>(payload);
|
|
||||||
if ((payload & 0x00800000U) != 0U) {
|
|
||||||
value |= static_cast<int32_t>(0xFF000000U);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const uint32_t payload = word & 0x0000FFFFU;
|
|
||||||
value = static_cast<int32_t>(payload);
|
|
||||||
if ((payload & 0x00008000U) != 0U) {
|
|
||||||
value |= static_cast<int32_t>(0xFFFF0000U);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
raw_code = static_cast<double>(value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ConsoleCtrlGuard {
|
struct ConsoleCtrlGuard {
|
||||||
bool installed = false;
|
bool installed = false;
|
||||||
|
|
||||||
@ -1679,18 +1653,18 @@ int run(const Config& cfg) {
|
|||||||
|
|
||||||
uint32_t raw_adc_count = 0;
|
uint32_t raw_adc_count = 0;
|
||||||
if (tty_writer) {
|
if (tty_writer) {
|
||||||
for (std::size_t i = 0; i < recvd; ++i) {
|
raw_adc_count = static_cast<uint32_t>(adc_raw_buffer.size());
|
||||||
double raw_code = 0.0;
|
const int32_t raw_process_err = api.ProcessData(device.hnd,
|
||||||
if (!try_extract_raw_adc_code(raw[i], raw_code)) {
|
raw.data(),
|
||||||
continue;
|
static_cast<uint32_t>(recvd),
|
||||||
}
|
0,
|
||||||
if (raw_adc_count >= adc_raw_buffer.size()) {
|
adc_raw_buffer.data(),
|
||||||
fail("Raw ADC parsing overflowed the temporary buffer");
|
&raw_adc_count,
|
||||||
}
|
nullptr,
|
||||||
adc_raw_buffer[raw_adc_count++] = raw_code;
|
nullptr);
|
||||||
}
|
expect_ok(api, raw_process_err, "Process raw ADC data");
|
||||||
if (raw_adc_count != adc_count) {
|
if (raw_adc_count != adc_count) {
|
||||||
fail("Raw ADC parsing returned a different sample count than voltage processing");
|
fail("Raw ADC processing returned a different sample count than voltage processing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tty_di1_group_average) {
|
if (!tty_di1_group_average) {
|
||||||
|
|||||||
@ -8,12 +8,17 @@ BIN="${BIN:-./main.exe}"
|
|||||||
TTY_PATH="${TTY_PATH:-/tmp/ttyADC_data}"
|
TTY_PATH="${TTY_PATH:-/tmp/ttyADC_data}"
|
||||||
CSV_PATH="${CSV_PATH:-capture.csv}"
|
CSV_PATH="${CSV_PATH:-capture.csv}"
|
||||||
SVG_PATH="${SVG_PATH:-capture.svg}"
|
SVG_PATH="${SVG_PATH:-capture.svg}"
|
||||||
|
LIB_DIR="${LIB_DIR:-$HOME/.local/lib}"
|
||||||
|
|
||||||
if [[ ! -x "$BIN" ]]; then
|
if [[ ! -x "$BIN" ]]; then
|
||||||
echo "Binary '$BIN' not found or not executable. Run ./build_main.sh first." >&2
|
echo "Binary '$BIN' not found or not executable. Run ./build_main.sh first." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$LIB_DIR" ]]; then
|
||||||
|
export LD_LIBRARY_PATH="${LIB_DIR}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
|
||||||
|
fi
|
||||||
|
|
||||||
exec "$BIN" \
|
exec "$BIN" \
|
||||||
clock:internal \
|
clock:internal \
|
||||||
internal_ref_hz:2000000 \
|
internal_ref_hz:2000000 \
|
||||||
|
|||||||
Reference in New Issue
Block a user