LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LStr issues when using Python to call functions from LabVIEW dll

Hello,

I have a rather specific problem - from the beginning:

The concept is to create a dll from a LabVIEW VI and call a function from the dll using Python. The pictures illustrates my first approach. The VI takes Fahrenheit as input and converts it to Celsius which is output, very simple.

 

FtoC.JPG

Now, I wish to do this in Python by calling the dll created from the VI with this specifics:



MyDLLproperties.JPG

 

The python script uses ctypes to import the dll and to fetch its function(s). It looks like this:

 

pythonscript.JPG

 

Thus, all is well and moving forward to a slightly more complicated VI. The next VI sets a specified voltage to a specified channel, accordingly:

VoltageSetter.JPG

 

The properties of the dll is specified as:

MyDLLproperties2.JPG

Again a similar function call is made in Python with the following script. This time it won't work, is it because of the LStrHandle *PhysicalChannel parameter?

 


pythonfailscript.JPG

 

It seems like the Physical Channel parameter must be given as a LabVIEW string type, but how to do it in Python? Preferably I would like to do it directly in Python but a C++ wrap will work as well if necessary.

 

Cheers,

K. Berg

 

 

PS. Thank you for this excellent board which has answered a battery of questions already .DS

0 Kudos
Message 1 of 4
(3,224 Views)

I solved it by replacing the tedious LabVIEW stringtype in the VI with a simple string input - a very simple solution to a simple problem. Just hope that someone has use of this answer and question.

 

Have a good one,

K.Berg

0 Kudos
Message 2 of 4
(3,209 Views)

Very useful for me.  Thanks for SPAMming the forum with Python code!  Smiley Wink

 

EDIT:  BTW, I found most of the NI DAQmx functions ported into a Python module on the web recently.  Search it out if you haven't already.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 3 of 4
(3,205 Views)

@NIquist wrote:

Very useful for me.  Thanks for SPAMming the forum with Python code!  Smiley Wink

 

EDIT:  BTW, I found most of the NI DAQmx functions ported into a Python module on the web recently.  Search it out if you haven't already.


Woha!

Thanks a lot, this is dynamite: http://packages.python.org/PyDAQmx/usage.html

 

You've got to love the internet

/Karl

0 Kudos
Message 4 of 4
(3,193 Views)