using the DLL to talk to cleverscope using C/C++

Using the DLL to talk to cleverscope using C/C++, a forum discussion on Cleverscope Mixed Signal USB Oscilloscopes. Join us for more discussions on Using the DLL to talk to cleverscope using C/C++ on our Other Issues forum.

Back to Forum Index : Back to Other Issues   RSS

13 Apr 2006

I'm trying to talk to the cleverscope using C/C++, whenever I call the function ""CScopeControlDriver"" I get a segmentation fault somewhere inside the driver.

The function takes a large number of arguments and probably one of the arguments I give it is not what it was expecting. My problem is which one! There is currently no cleverscope supplied example code and the documentation isn't completely explicit*.

Has anyone been able to interface with the driver using a text-based programming language, if so I'd love to know how you did it and perhaps see the code snippet you use.


P.S. my attempt is at

* e.g. the int32 valued variable ChanAAllocSpace is ""Used to declare how much space has been allocated to the Chan A Data array"" So what does one put in here, the number of samples, amount of memory in bytes? (Neither seems to work)

22 Apr 2006
Posts: 481

Hello Jevon, Thanks very much for your post. To answer it we have put a C code application in the Resources section of the site. The zip includes a sample application which illustrates amplitude and time axis control, trigger level and channel, and signal generator frequency and amplitude.

The allocation question is the space available, in bytes, for the output signal array.

5 May 2006

I thought I'd write this down in case anyone else has my problem

I still had a bit of trouble getting code to work in a console applicaton, it was because the driver seems to need windows messages to be processed and just calling ""Sleep()"" in between check_for_samples() from a console application doesn't cause this to happen.

Below is a simple example application which works for me.

Thanks for you help Bart.

#include ""stdafx.h""

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>

#include ""cscope interface.h""

void DoEvents()

MSG msg;
long sts;

do {
if (sts = PeekMessage(&msg, (HWND) NULL, 0, 0, PM_REMOVE)) {
} while (sts);

int main(int argc, char* argv[])
FILE *fp;
int k,j;
double a_vert = 1.0,b_vert=1.0,horz = 1.0e-3;
double sig_gen_freq=500;
double sig_gen_volts=4.0;
double trig_volts=0.0;
int trig_channel=0;
int num_points=1000;
double delta_t=0,t_zero=0;

double awave[max_samples], bwave[max_samples];
memset(awave, 0, max_samples*sizeof(double));
memset(bwave, 0, max_samples*sizeof(double));

k = scope_init();
printf(""error %d initialising scope"",k);

k = scope_config (a_vert, b_vert, horz, num_points,
sig_gen_freq,sig_gen_volts,trig_volts, trig_channel);

printf(""error %d configing scope"",k);

printf(""triggering acquisition
k = scope_acquire ();
printf(""error %d acquiring"",k);

k = check_for_samples();
printf(""checkforsamples returns : %d
if (k!=0) break;

k = scope_read_waveform (awave, bwave, &num_points, &delta_t, &t_zero);
printf(""erroe code %d, reading waveform
printf(""numsamples=%d,delta_t = %g,t_zero= %g

printf(""closing scope
j = scope_close();
printf(""error %d closing scope"",j);

fwrite (&num_points, sizeof(int),1,fp);
fwrite (awave,sizeof(double),num_points,fp);
fwrite (bwave,sizeof(double),num_points,fp);

return 0;
Back to Forum Index : Back to Other Issues   RSS
You must be logged in to post a reply

You need to Register or Log In before posting on these forums.


Your shopping cart is empty.