ngscopeclient 0.1-dev+51fbda87c
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
CommandLineDriver Class Reference

Helper class for command line drivers: provides helper methods for command line based communication with devices like NanoVNA or TinySA. More...

#include <CommandLineDriver.h>

Inheritance diagram for CommandLineDriver:
Inheritance graph
[legend]
Collaboration diagram for CommandLineDriver:
Collaboration graph
[legend]

Public Member Functions

 CommandLineDriver (SCPITransport *transport)
 
- Public Member Functions inherited from SCPIDevice
 SCPIDevice (SCPITransport *transport, bool identify=true)
 
SCPITransportGetTransport () const
 

Protected Member Functions

std::string ConverseSingle (const std::string commandString, bool hasEcho=true)
 Converse with the device : send a command and read the reply over several lines. More...
 
size_t ConverseMultiple (const std::string commandString, std::vector< std::string > &readLines, bool hasEcho=true, std::function< void(float)> progress=nullptr, size_t expecedLines=0)
 Converse with the device by sending a command and receiving a single line response. More...
 
bool ConverseSweep (int64_t &sweepStart, int64_t &sweepStop, int64_t &points, bool setFreqValues=false)
 Set and/or read the sweep values from the device. More...
 
bool ConverseSweep (int64_t &sweepStart, int64_t &sweepStop, bool setFreqValues=false)
 Set and/or read the sweep values from the device. More...
 
std::string ConverseString (const std::string commandString, std::function< void(float)> progress=nullptr, size_t expecedLines=0)
 Base method to converse with the device. More...
 
std::string DrainTransport ()
 Consume any pending data from the transport layer. More...
 

Protected Attributes

std::recursive_mutex m_transportMutex
 
size_t m_maxResponseSize
 
double m_communicationTimeout
 
- Protected Attributes inherited from SCPIDevice
SCPITransportm_transport
 
std::string m_vendor
 
std::string m_model
 
std::string m_serial
 
std::string m_fwVersion
 

Static Protected Attributes

static const std::string TRAILER_STRING = "ch> "
 
static const size_t TRAILER_STRING_LENGTH = TRAILER_STRING.size()
 
static const std::string EOL_STRING = "\r\n"
 
static const size_t EOL_STRING_LENGTH = EOL_STRING.size()
 

Detailed Description

Helper class for command line drivers: provides helper methods for command line based communication with devices like NanoVNA or TinySA.

Member Function Documentation

◆ ConverseMultiple()

size_t CommandLineDriver::ConverseMultiple ( const std::string  commandString,
std::vector< std::string > &  readLines,
bool  hasEcho = true,
std::function< void(float)>  progress = nullptr,
size_t  expecedLines = 0 
)
protected

Converse with the device by sending a command and receiving a single line response.

Parameters
commandStringthe command string to send
Returns
std::string the received response
Parameters
hasEchotrue (default value) if the device is expected to echo the sent command
progress(optional) download progress function
expectedLines(optional) the number of lines expected from the device
Returns
size_t the number of lines received from the device

◆ ConverseSingle()

std::string CommandLineDriver::ConverseSingle ( const std::string  commandString,
bool  hasEcho = true 
)
protected

Converse with the device : send a command and read the reply over several lines.

Parameters
commandStringthe command string to send
readLinesa verctor to store the reply lines
hasEchotrue (default value) if the device is expected to echo the sent command
Returns
size_t the number of lines received from the device

◆ ConverseString()

std::string CommandLineDriver::ConverseString ( const std::string  commandString,
std::function< void(float)>  progress = nullptr,
size_t  expecedLines = 0 
)
protected

Base method to converse with the device.

Parameters
commandStringthe command string to send to the device
progress(optional) download progress function
expectedLines(optional) the number of lines expected from the device
Returns
std::string a string containing all the response from the device (may contain several lines separated by \r
)

◆ ConverseSweep() [1/2]

bool CommandLineDriver::ConverseSweep ( int64_t &  sweepStart,
int64_t &  sweepStop,
bool  setFreqValues = false 
)
inlineprotected

Set and/or read the sweep values from the device.

Parameters
sweepStartthe sweep start value (in/out)
sweepStopthe sweep stop value (in/out)
setFreqValues(optional, defaults to false) true is the sweep frequency values have to be set on the device
Returns
true is the value returned by the device is different from the one that shoudl have been set (e.g. out of range)

◆ ConverseSweep() [2/2]

bool CommandLineDriver::ConverseSweep ( int64_t &  sweepStart,
int64_t &  sweepStop,
int64_t &  points,
bool  setFreqValues = false 
)
protected

Set and/or read the sweep values from the device.

Parameters
sweepStartthe sweep start value (in/out)
sweepStopthe sweep stop value (in/out)
pointsthe number of points (in/out)
setFreqValues(optional, defaults to false) true is the sweep frequency values have to be set on the device
Returns
true is the value returned by the device is different from the one that shoudl have been set (e.g. out of range)

◆ DrainTransport()

std::string CommandLineDriver::DrainTransport ( )
protected

Consume any pending data from the transport layer.

Returns
the consumed data

The documentation for this class was generated from the following files: