LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a DLL with c_str pointer

Solved!
Go to solution

Hello Labview heroes,

 

I have a working C++ script for communication with a sensor over Ethernet with a DLL that I am trying to repeat in Labview.

This is a snippet of the functioning C++ code:

Luc1234_0-1601041135763.png

 

According to the forums, I need a callback library block:

Luc1234_1-1601041192463.png

From what I read, this should be the correct setting:

Luc1234_2-1601041278668.png

This does not work however and the VI almost crashes.

I have tried the other options as well but no luck.

 

Any help would be appreciated!

This is a link to the functions in the DLL: http://sch-remote.com/doc/SR01E12%20Library%20Functions.pdf

 

Best Regards,

 

Luc

 

 

 

0 Kudos
Message 1 of 9
(3,901 Views)
Solution
Accepted by topic author Luc1234

From the manual:

 

SR_FUNC SR_HANDLE sr_open_eth(const char *ip, unsigned short port = 3101)

 

So you need a string and an unsigned short as an input.

 

So why does it work in C? Probably because they defined a default for the 2nd parameter in the header file.

0 Kudos
Message 2 of 9
(3,865 Views)

Thanks a lot, that was indeed the problem!

Message 3 of 9
(3,825 Views)

Hi Luc:

 

will you please share how are you doing with the SR01E12 board? I am planning to use it

 

thanks

0 Kudos
Message 4 of 9
(3,231 Views)

wiebe@CARYA wrote:

From the manual:

 

SR_FUNC SR_HANDLE sr_open_eth(const char *ip, unsigned short port = 3101)

 

So you need a string and an unsigned short as an input.

 

So why does it work in C? Probably because they defined a default for the 2nd parameter in the header file.


Actually default values for function parameters is a C++ feature. Standard C does not support that at all. The function declaration would be therefore a syntax error in all standard conforming standard C compilers. However some compilers nowadays are C++ compilers that are limited to standard C features by an optional parameter passed to the compiler command. So it is possible that some compilers might not choke on this despite compiling a *.c file as C file.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 9
(3,224 Views)

Hi Tecno,

 

So it took a long time, but I got it working in the end. For me it was difficult, but maybe if you are experienced with Labview, you will have it easier. The board itself is working fine. They are fragile though and should be handled with care.

Hope this answers your question and good luck.

0 Kudos
Message 6 of 9
(3,201 Views)

Hi Luc1234:

 

Thanks for your reply, I am planning to use the i2c and GPIO’s, do you have any vi to share?

 

Thanks

 

0 Kudos
Message 7 of 9
(3,182 Views)

I would like to, but it is company property, so sadly I cannot. Good luck!

0 Kudos
Message 8 of 9
(3,147 Views)

Thanks anyway

0 Kudos
Message 9 of 9
(3,137 Views)