ngscopeclient 0.1-dev+51fbda87c
Functions | Variables
scopehal.cpp File Reference

Implementation of global functions. More...

#include "scopehal.h"
#include "scopehal-version.h"
#include <libgen.h>
#include "AgilentOscilloscope.h"
#include "AlientekPowerSupply.h"
#include "HP662xAPowerSupply.h"
#include "AntikernelLabsOscilloscope.h"
#include "AntikernelLogicAnalyzer.h"
#include "DemoOscilloscope.h"
#include "DemoPowerSupply.h"
#include "DigilentOscilloscope.h"
#include "DSLabsOscilloscope.h"
#include "KeysightDCA.h"
#include "LeCroyOscilloscope.h"
#include "LeCroyFWPOscilloscope.h"
#include "PicoOscilloscope.h"
#include "RigolOscilloscope.h"
#include "RohdeSchwarzOscilloscope.h"
#include "RSRTO6Oscilloscope.h"
#include "SCPIPowerSupply.h"
#include "SiglentSCPIOscilloscope.h"
#include "TektronixOscilloscope.h"
#include "TektronixHSIOscilloscope.h"
#include "ThunderScopeOscilloscope.h"
#include "TinySA.h"
#include "AntikernelLabsTriggerCrossbar.h"
#include "MultiLaneBERT.h"
#include "CSVStreamInstrument.h"
#include "SocketCANAnalyzer.h"
#include "OwonXDMMultimeter.h"
#include "RohdeSchwarzHMC8012Multimeter.h"
#include "OwonXDGFunctionGenerator.h"
#include "RigolFunctionGenerator.h"
#include "GWInstekGPDX303SPowerSupply.h"
#include "RigolDP8xxPowerSupply.h"
#include "RohdeSchwarzHMC804xPowerSupply.h"
#include "SiglentPowerSupply.h"
#include "RidenPowerSupply.h"
#include "KuaiquPowerSupply.h"
#include "SiglentLoad.h"
#include "AseqSpectrometer.h"
#include "UHDBridgeSDR.h"
#include "CopperMountainVNA.h"
#include "NanoVNA.h"
#include "PicoVNA.h"
#include "SiglentVectorSignalGenerator.h"
#include "CDR8B10BTrigger.h"
#include "CDRNRZPatternTrigger.h"
#include "DCAEdgeTrigger.h"
#include "DropoutTrigger.h"
#include "EdgeTrigger.h"
#include "GlitchTrigger.h"
#include "NthEdgeBurstTrigger.h"
#include "PulseWidthTrigger.h"
#include "RuntTrigger.h"
#include "SlewRateTrigger.h"
#include "UartTrigger.h"
#include "WindowTrigger.h"
#include <dlfcn.h>
#include <sys/stat.h>
#include <wordexp.h>
#include <dirent.h>

Functions

void VulkanCleanup ()
 Free all global Vulkan resources in the correct order.
 
void TransportStaticInit ()
 Static initialization for SCPI transports.
 
void DetectCPUFeatures ()
 Static initialization for CPU feature flags.
 
void ScopehalStaticCleanup ()
 
void DriverStaticInit ()
 Static initialization for instrument drivers.
 
string GetDefaultChannelColor (int i)
 
uint64_t ConvertVectorSignalToScalar (const vector< bool > &bits)
 Converts a vector bus signal into a scalar (up to 64 bits wide)
 
void InitializePlugins ()
 Initialize all plugins.
 
string Trim (const string &str)
 Removes whitespace from the start and end of a string.
 
string TrimQuotes (const string &str)
 Removes quotes from the start and end of a string.
 
string BaseName (const string &path)
 
float FreqToPhase (float hz)
 Converts a frequency in Hz to a phase velocity in rad/sec.
 
string to_string_sci (double d)
 Like std::to_string, but output in scientific notation.
 
string to_string_hex (uint64_t n, bool zeropad, int len)
 Like std::to_string, but output in hex.
 
uint64_t next_pow2 (uint64_t v)
 Rounds a 64-bit integer up to the next power of 2.
 
uint64_t prev_pow2 (uint64_t v)
 Rounds a 64-bit integer down to the next power of 2.
 
string ReadFile (const string &path)
 Returns the contents of a file.
 
string GetDirOfCurrentExecutable ()
 Gets the path to the directory containing the current executable.
 
void InitializeSearchPaths ()
 
string ReadDataFile (const string &relpath)
 Locates and returns the contents of a data file as a std::string.
 
vector< uint32_t > ReadDataFileUint32 (const string &relpath)
 Locates and returns the contents of a data file as a std::vector<uint32_t>
 
string FindDataFile (const string &relpath)
 Locates a data file.
 
void GetTimestampOfFile (string path, time_t &timestamp, int64_t &fs)
 
vector< string > explode (const string &str, char separator)
 Splits a string up into an array separated by delimiters.
 
string strtolower (const string &s)
 Converts a string to lower case.
 
string str_replace (const string &search, const string &replace, const string &subject)
 Replaces all occurrences of the search string with "replace" in the given string.
 
uint32_t GetComputeBlockCount (size_t numGlobal, size_t blockSize)
 
string ExpandPath (const string &in)
 
void CreateDirectory (const string &path)
 
uint32_t CRC32 (const uint8_t *bytes, size_t start, size_t end)
 Calculates a CRC32 checksum using the standard Ethernet polynomial.
 
uint32_t CRC32 (const vector< uint8_t > &bytes)
 
const char * ScopehalGetVersion ()
 Returns the library version string (Semantic Version formatted)
 
bool OnMemoryPressure (MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
 Called when we run low on memory. More...
 

Variables

bool g_gpuFilterEnabled = false
 True if filters can use GPU acceleration.
 
bool g_gpuScopeDriverEnabled = false
 True if scope drivers can use GPU acceleration.
 
vector< string > g_searchPaths
 
set< MemoryPressureHandlerg_memoryPressureHandlers
 List of handlers for low memory registered by various subsystems.
 

Detailed Description

Implementation of global functions.

Author
Andrew D. Zonenberg

Function Documentation

◆ OnMemoryPressure()

bool OnMemoryPressure ( MemoryPressureLevel  level,
MemoryPressureType  type,
size_t  requestedSize 
)

Called when we run low on memory.

Parameters
levelIndicates if this is a soft or hard memory exhaustion condition
typeIndicates if we are low on CPU or GPU memory
requestedSizeFor hard memory exhaustion, the size of the failing allocation. For soft exhaustion, ignored and set to zero
Returns
True if memory was freed, false if no space could be freed