在Python中传递路径到Labview DLL [英] Passing a path to Labview DLL in Python
问题描述
我从这里开始我的问题,但意识到可能需要在Labview论坛上进行回答.
I am starting here with my question, but realize it might need to be answered on the Labview forums.
因此,我有一个在Labview中创建的DLL,并且正在通过Python 3.3.3访问它.我知道我可以正确访问它,因为我已经可以访问其中的几个功能.但是,当我尝试传递到遇到问题的文件的路径时,我遇到了问题.
So, I have a DLL that was created in Labview, and I am accessing it via Python 3.3.3. I know that I am accessing it correctly, as I am able to access several of the functions already. However, I am having an issue when I try to pass a path to a file that I am running into issues.
以下是.h文件中的函数调用详细信息,该文件是在创建DLL时创建的:
Here is the function call details from the .h file, that was created when the DLL was created:
/*!
* ClockInit
*/
int32_t __cdecl ClockInit(uint32_t HandleIn, char fileUseDialog[]);
这是我用来调用该函数的Python代码段:
And here is the Python snippet that I use to call the function:
import os, sys, time
from ctypes import *
ftdi=cdll.LoadLibrary('C:\\Python33\\DLLs\\Savlo16FF_DLL_old\\Salvo16FF DLL\\Salvo16FF.dll')
FPGA_DeviceHandle=c_ulong(0)
Status=ftdi.FPGAInit(byref(FPGA_DeviceHandle))
path="C:/Python33/Scripts/RegisterMap_100M_1p8HCSL.txt"
ftdi.ClockInit(FPGA_DeviceHandle,path)
这是我从Labview回来的错误:
And here is the error that I get back from Labview:
http://i.stack.imgur.com/PTz61.png
我能告诉的最好的一点是我没有正确地将路径传递给函数.我尝试了许多不同的变体(将'/'更改为'\',尝试使用create_string_buffer),但无济于事.
The best that I can tell is that I am not passing the path correctly to the function. I have tried many different variations (changed '/' to '\', tried using create_string_buffer), but to no avail.
在此先感谢您的帮助!
推荐答案
在路径变量中,斜杠为LabVIEW的另一种方式,不是路径",如上所述,python3需要使用"b"前缀
Slashes go the other way in the path variable evaluate to LabVIEW "not a path" and as rightfully pointed out above, python3 requires to use the "b" prefix.
这篇关于在Python中传递路径到Labview DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!