From ce08bd84e4989d577ffc300928815adc5ff69eb0 Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Fri, 11 Oct 2024 21:02:09 +0200 Subject: [PATCH] Add command AIN:ACQUIRE:ENABLE --- doc/remote_control.md | 13 +++++++++++++ sw/src/userspace/remotectl.cpp | 26 +++++++++++++++++++++----- sw/src/userspace/version.hpp | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/doc/remote_control.md b/doc/remote_control.md index 8b33ae4..41e2986 100644 --- a/doc/remote_control.md +++ b/doc/remote_control.md @@ -119,6 +119,7 @@ In the response string, such data elements are separated by space characters. | `AIN:TRIGGER:STATUS?` | Trigger status. | | `AIN:TRIGGER:EXT:CHANNEL` | External trigger channel. | | `AIN:TRIGGER:EXT:EDGE` | External trigger edge. | +| `AIN:ACQUIRE:ENABLE` | Enable analog acquisition. | | `TT:SAMPLE?` | Digital input state. | | `TT:EVENT:MASK` | Timetagger event mask. | | `TT:MARK` | Emit timetagger marker. | @@ -382,6 +383,18 @@ This command selects rising or falling edges in the external trigger signal. Query: `AIN:TRIGGER:EXT:EDGE?`
Response: either `RISING` or `FALLING`. +### `AIN:ACQUIRE:ENABLE` + +Command: `AIN:ACQUIRE:ENABLE en`
+Parameter _en_: either `0` or `1`. + +This command enables or disables analog acquisition. +When enabled, analog samples are acquired according to the configured trigger mode. +When disabled, all triggers are ignored and any ongoing analog acquisition stops immediately. + +Query: `AIN:ACQUIRE:ENABLE?`
+Response: either `0` or `1`. + ### `TT:SAMPLE?` Query: `TT:SAMPLE?`
diff --git a/sw/src/userspace/remotectl.cpp b/sw/src/userspace/remotectl.cpp index b16f699..6ecac7c 100644 --- a/sw/src/userspace/remotectl.cpp +++ b/sw/src/userspace/remotectl.cpp @@ -543,9 +543,6 @@ public: m_device.set_record_length(1024); m_device.set_timetagger_event_mask(0); m_device.clear_adc_range(); - - // Enable analog acquisition. - m_device.set_acquisition_enabled(true); } /** @@ -901,6 +898,12 @@ private: } } + /** Handle command AIN:ACQUIRE:ENABLE? */ + std::string qry_acquire_enable(CommandEnvironment env) + { + return m_device.is_acquisition_enabled() ? "1" : "0"; + } + /** Handle command TT:SAMPLE? */ std::string qry_tt_sample(CommandEnvironment env) { @@ -1288,6 +1291,18 @@ private: return "OK"; } + /** Handle command AIN:ACQUIRE:ENABLE */ + std::string cmd_acquire_enable(CommandEnvironment env, + const std::string& arg) + { + unsigned int n; + if ((! parse_uint(arg, n)) || (n > 1)) { + return err_invalid_argument(); + } + m_device.set_acquisition_enabled(n != 0); + return "OK"; + } + /** Handle command TT:EVENT:MASK */ std::string cmd_tt_event_mask(CommandEnvironment env, const std::string& arg) @@ -1367,6 +1382,7 @@ private: { "ain:chN:sample:raw?", &CommandHandler::qry_channel_sample }, { "ain:chN:minmax?", &CommandHandler::qry_channel_minmax }, { "ain:chN:minmax:raw?", &CommandHandler::qry_channel_minmax }, + { "ain:acquire:enable?", &CommandHandler::qry_acquire_enable }, { "ain:srate?", &CommandHandler::qry_srate }, { "ain:srate:divisor?", &CommandHandler::qry_srate_divisor }, { "ain:srate:mode?", &CommandHandler::qry_srate_mode }, @@ -1402,6 +1418,7 @@ private: { "ain:chN:offset:RR", &CommandHandler::cmd_channel_offset }, { "ain:chN:gain", &CommandHandler::cmd_channel_gain }, { "ain:chN:gain:RR", &CommandHandler::cmd_channel_gain }, + { "ain:acquire:enable", &CommandHandler::cmd_acquire_enable }, { "ain:srate", &CommandHandler::cmd_srate }, { "ain:srate:divisor", &CommandHandler::cmd_srate_divisor }, { "ain:srate:mode", &CommandHandler::cmd_srate_mode }, @@ -1864,13 +1881,12 @@ int run_remote_control_server( command_handler.add_data_server(acq_server); command_handler.add_data_server(timetagger_server); - // Restore firmware status on exit from this function. + // Disable DMA on exit from this function. struct ScopeGuard { PuzzleFwDevice& m_device; ScopeGuard(PuzzleFwDevice& device) : m_device(device) { } ~ScopeGuard() { m_device.set_dma_enabled(false); - m_device.set_acquisition_enabled(false); } } scope_guard(device); diff --git a/sw/src/userspace/version.hpp b/sw/src/userspace/version.hpp index 4b602c1..6075dcc 100644 --- a/sw/src/userspace/version.hpp +++ b/sw/src/userspace/version.hpp @@ -1,2 +1,2 @@ #define PUZZLEFW_SW_MAJOR 0 -#define PUZZLEFW_SW_MINOR 3 +#define PUZZLEFW_SW_MINOR 4