My coworker built a DLL from LabVIEW that I am trying to call from C++.
How do I create a VISA resource name in C++ and pass as uintptr_t* to the DLL?
Is there a macro or helper function in "extcode.h" that can make life easy?
Or should we rebuild the DLL's to use a more common string type?
Example DLL Function:
void __cdecl MeasureDCvolts(uintptr_t *VISAResourceName, int32_t ChannelNumber, LVBoolean *MonitorResult, double *MeasuredVoltage, TD1 *errorOut);
Thanks in advance for any advice or direction,
-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);
}