NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Strings: Teststand - LabWindows, IVI

Solved!
Go to solution
Hello all,

I'm trying to initialize a driversession with a logicalName which is stored in a teststand string variable. Please have a look at the following code fragment. s_PMI_init(ViRsrc logicalName, ViBoolean idQuery, ViBoolean resetDevice, ViSession *vi) is a function of my Custom Class Driver, which I loaded dynamically. Has anyone an idea why the initialization fails? I think it's a simple mistake but it drives me mad...

...
ViRsrc * logicalName = NULL; //char *

TS_PropertyGetValString(data->seqContextCVI, &errorInfo, "Step.LogicalName", 0, &logicalName);

//MessagePopup("Info", logicalName); //shows right logicalname

s_PMI_init( "drvsession", FALSE, FALSE, &session ); //works
s_PMI_init( logicalName, FALSE, FALSE, &session ); //doesn't work why?
...

Thanks in advance
7even
0 Kudos
Message 1 of 5
(3,417 Views)

Hi,

 

You seem to be trying to get the string "drvsession" from a TestStand step which has a property call LogicalName.

 

eg Step.LogicalName = "drvsession"

 

Is this a Custom Step Type you are using?

 

What version of TestStand are you using?

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 5
(3,415 Views)
You're right. It's a custom Step Type and the code fragment is from a module which is called during runtime (Post-Step). I'm using Teststand 4.2 and LabWindows 8.1.
0 Kudos
Message 3 of 5
(3,408 Views)

Hi,

 

make sure you are passing a valid SequenceContext into the function to use in

TS_PropertyGetValString(data->seqContextCVI, &errorInfo, "Step.LogicalName", 0, &logicalName);

Also check what the error is returning from TS_PropertyGetValString. 

 

 

But seeing as you are using TS4.2, why dont you pass the LogicalName direct to the function. then you dont need to use TS_PropertyGetValString

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 4 of 5
(3,393 Views)
Solution
Accepted by 7even

Hi,

 

Here is a snipet of passing the LogicalName direct to the function:

 

    // This example test module aquires the instrument session by name.  Provided that
    // another reference to the session exists, this module does not recreate or
    // reinitialize the session.
void __declspec(dllexport) __stdcall ConfigureDMMForVoltageMeasurements(const char *logicalName,
        short *errorOccurred, long *errorCode, char errorMsg[1024])
{
    int error = 0;
    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;
    ViSession   handle;
    CAObjHandle session = 0;

       // get a reference to the session
    tsErrChk( SM_GetSession(logicalName, &session, &errorInfo));

        // get the driver handle (you don't need to release it)
    tsErrChk( SM_GetHandle (session, NULL, SMConst_ClassDriver,
                          &handle, &errorInfo));

        // call the instrument as much as you want:
    errChk( IviDmm_ConfigureMeasurement(handle, IVIDMM_VAL_DC_VOLTS, IVIDMM_VAL_AUTO_RANGE_ON, 0.001));

 

 

 

You can find this example in \TestStand 4.2\Examples\SessionMgr\CVI\

 

Hope this helps

Regards

Ray Farmer
       

Regards
Ray Farmer
Message 5 of 5
(3,387 Views)