取消
显示结果 
搜索替代 
您的意思是: 

Calling a DLL with c_str pointer

已解决!
转到解答

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 项奖励
1 条消息(共 9 条)
5,600 次查看
解答
接受人 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 项奖励
2 条消息(共 9 条)
5,564 次查看

Thanks a lot, that was indeed the problem!

3 条消息(共 9 条)
5,524 次查看

Hi Luc:

 

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

 

thanks

0 项奖励
4 条消息(共 9 条)
4,930 次查看

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
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 项奖励
5 条消息(共 9 条)
4,923 次查看

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 项奖励
6 条消息(共 9 条)
4,900 次查看

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 项奖励
7 条消息(共 9 条)
4,881 次查看

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

0 项奖励
8 条消息(共 9 条)
4,846 次查看

Thanks anyway

0 项奖励
9 条消息(共 9 条)
4,836 次查看