LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parameter type from C to Labview

Solved!
Go to solution

Hello, I have an application on C that interacts with a haptic device and I want to create it in labview. For now, I just want to do a little command to initialize the device "hdInitDevice".
I am using a CLF on labview with the dll for the function, but I'm having trouble with the parameters types.
I think the "arg1" should be an array, since the "nome" is a char.
The return type I don't know.

Download All
0 Kudos
Message 1 of 9
(2,075 Views)

Actually it’s better to configure the parameter as a String, Pass as C Data Pointer.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 9
(2,010 Views)

If i choose the type "String" then I can send it as "C string pointer", it does not appear the option of "C data pointer".

 

And even with this change, it does not work. It gives me the error 1097

0 Kudos
Message 3 of 9
(1,981 Views)

@ritaneves85  ha scritto:

If i choose the type "String" then I can send it as "C string pointer", it does not appear the option of "C data pointer".

 

And even with this change, it does not work. It gives me the error 1097


C String Pointer should be ok. There must be something else wrong.

As a side note, the string to be passed is the name without the quotes.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 9
(1,976 Views)
Solution
Accepted by topic author ritaneves85

@ritaneves85 wrote:

If i choose the type "String" then I can send it as "C string pointer", it does not appear the option of "C data pointer".


Semantics. Arrays call it C Data Pointer, Strings apparently C String Pointer. I meant this one. The difference is that since LabVIEW strings are not zero terminated but C Strings are LabVIEW not only passes the internal pointer to the string buffer to the DLL but first makes sure to append a NULL character to the end of the buffer so that the C function sees a valid C string.

 


@ritaneves85 wrote:

 

And even with this change, it does not work. It gives me the error 1097


Check your Calling Convention. LabVIEW defaults to cdecl, since that is the only one available on most non-Windows systems and LabVIEW generally uses that too for its own functions. Windows 32-bit APIs are mostly using stdcall and many other DLL creators follow that lead.

 

For Windows 64-bit it doesn't matter as there is only one common Calling Convention in user space code, and it is in fact neither stdcall or cdecl but the so called fastcall. 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 5 of 9
(1,959 Views)

I was just going to ask why.  Thanks Rolf

 

Am I correct to assume whitespace in the ID name value would be problematic?  OneOfTheseDays_I_WillLearnToTolerate_c_stringsNUL 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 9
(1,948 Views)

@JÞB  ha scritto:

I was just going to ask why.  Thanks Rolf

 

Am I correct to assume whitespace in the ID name value would be problematic?  OneOfTheseDays_I_WillLearnToTolerate_c_stringsNUL 


No. A whitespace is just another respectable non-null character.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 9
(1,943 Views)

It solved the problem, thank you !

 

0 Kudos
Message 8 of 9
(1,924 Views)

@JÞB wrote:

I was just going to ask why.  Thanks Rolf

 

Am I correct to assume whitespace in the ID name value would be problematic?  OneOfTheseDays_I_WillLearnToTolerate_c_stringsNUL 


Not sure where you are heading at. Whitespace is usually the name used for all kind of characters such as character tab, line feed, lne tabulation, form feed, carriage return, space, next line, and no-break space. The last two do not exist in all ANSI codepages as they reside in codepoints >= 128. They are simply valid characters but are generally white space on the paper, with no inkt, toner or whatever being placed.

 

C only assigns a special meaning to the NULL character. All the rest is simply ANSI defined and for codepoints below 128 also the same in Unicode.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 9 of 9
(1,903 Views)