我试图将DLL(在Labview中创建)导入python。
我把它简化为一个非常简单的Labview VI,一个字符串进入一个集群,这个集群是DLL中的一个函数,也就是说,这个函数是:void TestCluster(cluster*outputCluster)
我可以从集群中读取除了字符串和数组之外的所有内容。我想我只是没有正确的结构(?)。在
这也可能是因为我对Python中的ctypes知之甚少。在
导入的Python代码示例:#!/usr/bin/env python
import sys, os, string
from ctypes import *
class byteArrayStructure(Structure):
_fields_ = [("dimSize", c_int),("bytes", c_uint8 )]
class clusterStructure(Structure):
_fields_ = [("stringField", c_char*4 ),
("byteArray", byteArrayStructure )]
dll = cdll.LoadLibrary("test.dll")
libc = cdll.msvcrt
def testMain():
retValue = 0
try:
clusterIn = clusterStructure()
dll.TestCluster( byref(clusterIn) )
print clusterIn.byteArray.bytes
print cast(clusterIn.byteArray.bytes,c_char_p)
except ValueError, Argument:
retValue = "Error: " + str(ValueError) + " " + str(Argument)
return retValue
testMain()
编辑:
来自test.h的结构
^{pr2}$
谢谢:)