需要使用TD1 ** TD1Hdl变量的帮助(LabVIEW) [英] Need help using TD1 **TD1Hdl variable (LabVIEW)
问题描述
所以我从LabView vi生成了一个.dll.我要使用的变量声明如下:
So I generated a .dll from a LabView vi. The variable I''m trying to use is declared as follows:
typedef struct {
long dimSize;
LStrHandle elt[1];
} TD1;
typedef TD1 **TD1Hdl;
我要调用的函数是:
The function I want to call is:
void __cdecl getFileList(TD1Hdl *SpecResults);
根据LabView,SpecResults是我可以使用的输出变量(它是vi中的数组).
我已经用它编译了几种不同的方法,但是无论我做什么,我都无法检索到我需要的数据(dimSize和elt).
这是我得到的最接近的东西:
where, according to LabView, SpecResults is an output variable that I can use (it is an array in the vi).
I have gotten it to compile several different ways, but no matter what I do, I can''t retrieve the data I need (dimSize and elt).
Here is the closest I''ve gotten:
int main(int argc, char *argv[])
{
TD1 *tdptr = (TD1 *)malloc(sizeof(long) + (6 * sizeof(LStrHandle))); // the array I''m getting has 6 elements
TD1Hdl tdhdl = &tdptr;
SetupWO();
getFileList(&tdhdl);
return 0;
}
使用tdptr和tdhdl的手表进行调试时,两者均显示未找到符号".
SetupWO()启动主vi,getFileList是子vi.
在此先感谢您的帮助.
添加行
Debugging with watches for tdptr and tdhdl says "symbol not found" for both.
SetupWO() starts the main vi, getFileList is a subvi.
Thanks in advance for any help.
Adding the lines
if(tdptr = NULL)
return 0;
else
printf("memory allocated");
在声明tdptr之后立即给出dimSize = ???并且elt = 0x00000004,我想这比我得到的要好一些?我不知道,因为我整周都在努力研究,所以我需要弄清楚这个问题,直到我这样做之前,我无法再取得任何进步.非常感谢您提供任何帮助...
right after tdptr is declared gives dimSize = ??? and elt = 0x00000004, which I guess is a little better than what I was getting? I don''t know, I need to get this figured out as I''ve been working on it all week and I can''t make any more progress until I do. Any help is greatly appreciated...
推荐答案
不幸的是,这些面板上没有得到任何答案,但我或多或少都知道了.我将发布代码,以防将来有人遇到类似问题.现在已分成几类,因此看起来有些不同.
wrapper.h:
Unfortunately didn''t get any answers on these boards but I have it more or less figured out. I''ll post the code in case anyone has a similar problem in the future. It''s separated into classes now so it looks a little different.
wrapper.h:
#include <ansi_c.h>
#include <labviewLib.h>
#include <iostream>
#include <stdlib.h>
#include "createMPTfile.h"
using namespace std;
class wrapper
{
public:
void run();
~wrapper(){delete create;}
private:
void LStrToCStr(LStrHandle lstr, char *cStrBuff, long buffLen);
TD1 tdptr;
TD1Hdl tdhdl;
};
wrapper.cpp:
wrapper.cpp:
#include "wrapper.h"
void wrapper::run()
{
tdhdl = NULL;
SetupWO();
getFileList(&tdhdl);
tdptr.dimSize = (*tdhdl)->dimSize;
for(int i = 0; i < tdptr.dimSize; i++)
{
tdptr.elt[i] = (*tdhdl)->elt[i];
char atpString[256];
LStrToCStr(tdptr.elt[i], atpString, 256);
printf(atpString);
printf("\n");
}
}
void wrapper::LStrToCStr(LStrHandle lstr, char* cStrBuff, long buffLen)
{
int32 len = LHStrLen(lstr);
if(len >= buffLen)
len = buffLen - 1;
memcpy(cStrBuff, LHStrBuf(lstr), len);
cStrBuff[len] = 0;
}
这篇关于需要使用TD1 ** TD1Hdl变量的帮助(LabVIEW)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!