Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5371

How pass VISA resource string from C++ as uintptr_t* to a LabVIEW generated DLL ?

$
0
0

My coworker build a DLL from LabVIEW that I am trying to call from C++.

 

void__cdeclMeasureDCvolts(uintptr_t*VISAResourceName, int32_tChannelNumber,LVBoolean*MonitorResult,double*MeasuredVoltage, TD1*errorOut);

 

Does "extcode.h" define macros or functions for string conversions?  Or should I request my coworker rebuild the VI's to make arguments more C/C++ friendly?

 

Thanks in advance for any tips or direction.  Examples are * much * appreciated.

 

 

-Ed

 

 

TestObjectMeasurement* testObjectMeasurement = m_measurementMap[name];
TestObjectInstrument* testObjectInstrument = m_instrumentMap[selectedInstrumentName];
int slot = 1;
int bank = 1;
int channel = 1;
int channelNumber = 1000 * slot + channel;

char * visaResourceName = testObjectInstrument->visaResourceName().toLatin1().data();

LVBoolean monitorResult = LVBooleanFalse;
double measuredVoltage = -1.0;
TD1 errorOut = {0};


try
{
// void __cdecl MeasureDCvolts(uintptr_t *VISAResourceName,
// int32_t ChannelNumber, LVBoolean *MonitorResult, double *MeasuredVoltage,
// TD1 *errorOut);
MeasureDCvolts(reinterpret_cast<uintptr_t*>(visaResourceName), channelNumber, &monitorResult, &measuredVoltage, &errorOut);
}
catch(...)
{
qDebug() << "Exception thrown by: MeasureDCvolts";
}

QString errorSource = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorOut.source)), LHStrLen(errorOut.source));
qDebug() << errorSource;

LStrHandle errorTextHandle = {0};
bool foundErrorText = NIGetOneErrorCode(errorOut.code, &errorTextHandle);
if(foundErrorText)
{
QString errorText = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorTextHandle)), LHStrLen(errorTextHandle));
MessageHelper::messageError(errorText, errorSource);
}


Viewing all articles
Browse latest Browse all 5371

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>