Test and Measurement Forum

c++ PicoScope 6402B

Post your C and C++ discussions here

c++ PicoScope 6402B

Postby florix » Mon Oct 28, 2013 3:13 pm

Hi,

I try to program the PicoScope 6402B witch c++.

My problem is that can not open the Picoscope.

her is my code
Code: Select all
#include "stdafx.h"
#include "ps6000Api.h"
#include "picoStatus.h"
using namespace System;

int main(array<System::String ^> ^args){

PICO_STATUS status;

status = ps6000OpenUnit( 0, NULL) ;   

   
    return 0;
}


Can you say what is wrong with the code
Thanks
florix
florix
Newbie
 
Posts: 0
Joined: Mon Oct 28, 2013 12:59 pm

Re: c++ PicoScope 6402B

Postby Martyn » Mon Oct 28, 2013 3:33 pm

When you try to open the unit with ps6000OpenUnit what value is returned in status ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2338
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: c++ PicoScope 6402B

Postby hmaarrfk » Sat Dec 28, 2013 12:24 am

The first parameter to openUnit should be a pointer TO the location where you want to save the handle.

the handle is the identifier to the picoscope you are using for all your calls.


therefore your code should look like something like this

Code: Select all
int16_t handle = 0;
int r;
r = ps6000OpenUnit(&handle, NULL);
// check r for any errors

// do things
r = ps6000CloseUnit(handle);


notice how you pass the address to handle.

You should also observe that the value of handle has changed to be non-zero.

You need to use handle in all subsequent ps6000 calls.

You were passing it the value of 0, a NULL pointer effectively. That address is invalid memory. The picoscope driver will either made a special check for that value, or it might just fail with a segfault. People typically check for the NULL pointer when taking in optional arguments, but handle is really necessary in this specific function so I can't speak about the specifics.

Mark
hmaarrfk
Newbie
 
Posts: 0
Joined: Sun Jun 24, 2012 11:41 pm

Re: c++ PicoScope 6402B

Postby Martyn » Sat Dec 28, 2013 9:50 am

That's correct. Make sure you check the return code for all driver function calls in your code, it will help identify issues.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2338
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests