polyplay Posted July 10, 2007 Report Share Posted July 10, 2007 http://forums.lavag.org/index.php?act=attach&type=post&id=6328 Hello, I am trying to access function "xlLinSetChannelParams" from vxlapi.dll (see the attached archive). For the parameter "statPar" I need to pass a structure and I use a cluster with the format specified in the function prototype. If Adapt to Type is selected as input type, there are to possibilities to pass data: by value and by pointer. No matter what data format I choose, the function prototype shows me that data will be passed by pointer (short int _xlLinSetChannelParams@28(long portHandle, unsigned long long accessMask, void *LinParam). Any idea how to fix this or use other method to make this function work. P.S. If you manage to make this work, you will receive an error code with values between 0 and 255. The inputs portHandle and accessMask are correct; the problem comes from the structure. Quote Link to comment
Yair Posted July 10, 2007 Report Share Posted July 10, 2007 What is your actual problem? I ran it as is and got back 101. Is that a desirable result? What do you get? Quote Link to comment
polyplay Posted July 11, 2007 Author Report Share Posted July 11, 2007 QUOTE(yen @ Jul 9 2007, 08:34 PM) What is your actual problem?I ran it as is and got back 101. Is that a desirable result? What do you get? 101 is an OK result. In my case LabVIEW crashes. See the attached file. Quote Link to comment
Yair Posted July 11, 2007 Report Share Posted July 11, 2007 Well, I was using the current beta version, so it's possible that this was a bug which was fixed. I suggest you try asking NI support directly. P.S. Does it crash immediately after you call this? How do you know the structure is to blame? Quote Link to comment
Rolf Kalbermatter Posted July 12, 2007 Report Share Posted July 12, 2007 QUOTE(polyplay @ Jul 9 2007, 04:11 AM) http://forums.lavag.org/index.php?act=attach&type=post&id=6328''>http://forums.lavag.org/index.php?act=attach&type=post&id=6328'>http://forums.lavag.org/index.php?act=attach&type=post&id=6328Hello, I am trying to access function "xlLinSetChannelParams" from vxlapi.dll (see the attached archive). For the parameter "statPar" I need to pass a structure and I use a cluster with the format specified in the function prototype. If Adapt to Type is selected as input type, there are to possibilities to pass data: by value and by pointer. No matter what data format I choose, the function prototype shows me that data will be passed by pointer (short int _xlLinSetChannelParams@28(long portHandle, unsigned long long accessMask, void *LinParam). Any idea how to fix this or use other method to make this function work. P.S. If you manage to make this work, you will receive an error code with values between 0 and 255. The inputs portHandle and accessMask are correct; the problem comes from the structure. If your actual C code header file is really as you show in your text file you might have a serious problem here. typedef struct { unsigned int LINMode; int baud rate; < this is definitely not valid C syntax. unsigned int LINVersion; unsigned int reserved; } XLlinStatPar; XLstatus xlLinSetChannelParams (XLportHandle portHandle, XLaccess accessMask, XLlinStatPar statPar); What LabVIEW will assume for structure parameters is: XLstatus xlLinSetChannelParams (XLportHandle portHandle, XLaccess accessMask, XLlinStatPar *statPar); passing the structure by pointer. I'm not aware that this can be done otherwise so maybe the C compiler will automatically make this parameter passed by pointer but that is beyond my C detail knowledge. Rolf Kalbermatter Quote Link to comment
polyplay Posted July 17, 2007 Author Report Share Posted July 17, 2007 QUOTE(rolfk @ Jul 11 2007, 01:08 PM) If your actual C code header file is really as you show in your text file you might have a serious problem here.typedef struct { unsigned int LINMode; int baud rate; < this is definitely not valid C syntax. unsigned int LINVersion; unsigned int reserved; } XLlinStatPar; XLstatus xlLinSetChannelParams (XLportHandle portHandle, XLaccess accessMask, XLlinStatPar statPar); What LabVIEW will assume for structure parameters is: XLstatus xlLinSetChannelParams (XLportHandle portHandle, XLaccess accessMask, XLlinStatPar *statPar); passing the structure by pointer. I'm not aware that this can be done otherwise so maybe the C compiler will automatically make this parameter passed by pointer but that is beyond my C detail knowledge. Rolf Kalbermatter I found a sollution for this, maybe this idea will help somebody with a similar problem. Function prototype looks like this: short int _xlLinSetChannelParams@28(long portHandle, unsigned long long accessMask, unsigned long LINMode, long baudrate, unsigned long LINVersion, unsigned long reserved); http://forums.lavag.org/index.php?act=attach&type=post&id=6364''>http://forums.lavag.org/index.php?act=attach&type=post&id=6364'>http://forums.lavag.org/index.php?act=attach&type=post&id=6364 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.