Skip to content

Commit

Permalink
Implemented BITS command
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed May 6, 2021
1 parent 754b9ae commit 68af445
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/ps6000d/ScpiServerThread.cpp
Expand Up @@ -55,6 +55,9 @@
[chan]:RANGE [num]
Sets channel full-scale range to num volts
BITS [num]
Sets ADC bit depth
DEPTH [num]
Sets memory depth
Expand Down Expand Up @@ -227,7 +230,7 @@ void ScpiServerThread()
else if(cmd == "CHANS")
ScpiSend(client, to_string(g_numChannels));

//Get memory depth
//Get legal sample rates for the current configuration
else if(cmd == "RATES")
{
string ret = "";
Expand Down Expand Up @@ -308,6 +311,39 @@ void ScpiServerThread()
UpdateChannel(channelId);
}

else if( (cmd == "BITS") && (args.size() == 1) )
{
lock_guard<mutex> lock(g_mutex);

ps6000aStop(g_hScope);

//Even though we didn't actually change memory, apparently calling ps6000aSetDeviceResolution
//will invalidate the existing buffers and make ps6000aGetValues() fail with PICO_BUFFERS_NOT_SET.
g_memDepthChanged = true;

int bits = stoi(args[0].c_str());
switch(bits)
{
case 8:
ps6000aSetDeviceResolution(g_hScope, PICO_DR_8BIT);
break;

case 10:
ps6000aSetDeviceResolution(g_hScope, PICO_DR_10BIT);
break;

case 12:
ps6000aSetDeviceResolution(g_hScope, PICO_DR_12BIT);
break;

default:
LogError("User requested invalid resolution (%d bits)\n", bits);
}

if(g_triggerArmed)
StartCapture(false);
}

else if( (cmd == "COUP") && (args.size() == 1) )
{
lock_guard<mutex> lock(g_mutex);
Expand Down Expand Up @@ -688,6 +724,8 @@ void StartCapture(bool stopFirst)
g_sampleIntervalDuringArm = g_sampleInterval;
g_triggerSampleIndex = g_memDepth/2;

//TODO: implement g_triggerDelay

if(stopFirst)
ps6000aStop(g_hScope);

Expand Down

0 comments on commit 68af445

Please sign in to comment.