来自Hantek sdk的C++
HTMARCH_API short WINAPI dsoReadHardData(WORD DeviceIndex,
short* pCH1Data,
short* pCH2Data,
ULONG nReadLen,
short* pCalLevel,
int nCH1VoltDIV,
int nCH2VoltDIV,
short nTrigSweep,
short nTrigSrc,
short nTrigLevel,
short nSlope,
int nTimeDIV,
short nHTrigPos,
ULONG nDisLen,
ULONG* nTrigPoint,
short nInsertMode);C#
[DllImport("HTMarch.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.StdCall)]
public static extern short dsoReadHardData(short DeviceIndex,
short[] pCH1Data,
short[] pCH2Data,
uint nReadLen,
short[] pCalLevel,
int nCH1VoltDIV,
int nCH2VoltDIV,
short nTrigSweep,
short nTrigSrc,
short nTrigLevel,
short nSlope,
int nTimeDIV,
short nHTrigPos,
uint nDisLen,
uint nTrigPoint,
short nInsertMode);使用
int nReadLen = 10240;//10k
int nDrawLen = 10000;
short nTrigLevel = 64;
short nSlope = 0;// 0:Rise; 1: Fall
short nHTrigPos = 50;// 0 ~ 100
uint nTrigPoint = 0;
short[] pCH1Data = new short[nReadLen];
short[] pCH2Data = new short[nReadLen];
short nRe = Hantek.dsoReadHardData(m_nDevIndex,
pCH1Data,
pCH2Data,
(uint)nReadLen,
m_nCalData,
m_nCH1VoltDIV,
m_nCH2VoltDIV,
0,//0:AUOT; 1:Normal; 2: Signal
0,//CH1
nTrigLevel,
nSlope,
m_nTimeDIV,
nHTrigPos,
(uint)nDrawLen,
nTrigPoint,
0);怎么了?当程序员就地停止pCH1Data和pCH2Data中的所有数据时。尝试写入包装器,但有错误的零值。
发布于 2013-12-01 11:36:33
C声明和DLLImport语句中的第五个参数被定义为指向短/短指针数组的类型,但是您在函数调用中传递的第五个参数被命名为m_nCalData,这意味着一个整数值。确保传递一个短数组作为第五个参数。
发布于 2014-03-06 03:12:50
参数nTrigPoint是一个指向无符号长整型的指针,您重新声明了它是一个无符号整数,它需要是一个指针,并且您需要为它提供一个无符号长整型的地址,因为该DLL函数将把nTrigPoint指向的任何内容设置为触发点索引(相对于原始数据数组)。
参数pCalLevel需要是一个大小为32的短数组的地址,只要memset为0,或者先用dsoGetCalLevel()填充即可。
https://stackoverflow.com/questions/20308310
复制相似问题