cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

Crash when passing a structure into a call library function node

¡Resuelto!
Ir a solución

 

     I'm trying to use a Fortran type (which I think is similar to a struct) in a LabVIEW call library function node.  I've been reading a few recourses on it, but I'm not entirely sure if I need to add the name of the structure to the node's parameter list.  Right now, when I run my VI it just closes LabVIEW entirely with no message.  I've attached the VI, that I'm using and the fortran source code, that compiles into my .dll. 

 

Any help is appreciated.

Descargar todos
0 kudos
Mensaje 1 de 7
3.462 Vistas

I know nothing about Fortran but have some experience calling DLLs from LabVIEW, and I think you need to pass each element of the arrays (VelocityVehicle, VelocityWind) as separate parameters.  LabVIEW passes arrays by pointer because in LabVIEW, arrays can have variable size.  In your Fortran code you declare them as fixed size, so they are stored inline with your structure.  The corresponding LabVIEW type for a fixed-size array is a cluster of identical elements, but since you are passing the cluster by value you need to pass each element individually.

 

If you were to change this to pass the cluster by reference, you would need to replace the LabVIEW arrays with clusters containing the right number of elements to match the fixed-size arrays in your Fortran code.

Mensaje 2 de 7
3.455 Vistas

Thanks for the tip.  I'm going to try this.  Something I'm still not exactly sure about though is do I need to include the name of my structure in the library node parameter list?  Right now, I just have each element of the structure included in the list, but should I have the name of the structure included as well?  I haven't yet seen a good example of this when searching through boards.

0 kudos
Mensaje 3 de 7
3.441 Vistas

I tried replacing the arrays with clusters and have attempted to pass each element by itself into my library node, but I still get the same behavior, with pretty much none of the values coming through correctly.  I've re-attached the .vi as it is now.

0 kudos
Mensaje 4 de 7
3.434 Vistas
Solución
Aceptado por el autor del tema adams156

Do you know if Fortran passes parameters by value, or by reference?  I've never used it.  A really quick internet search suggests that parameters should be passed by reference.  If this is the case, then you need to pass the entire cluster as a single parameter, similar to the Fortran declaration.  You also need to rearrange the cluster order to match the order in the Fortran declaration.  Try the attached VI.

Mensaje 5 de 7
3.427 Vistas

I think that's got it, and it's much simpler than the way I was trying to do it!  As soon as I adjusted the order and the representation on the values in the program you attached, it worked just fine.  Thanks a lot for your help.  I was also going to ask real quick about kudos on this forum.  All of your posts in this thread have been relatively helpful, so would it be appropriate for me to put kudos on all of them, or just the one that I mark as a solution?

0 kudos
Mensaje 6 de 7
3.409 Vistas

I'll take all the kudos I can get! 🙂

I don't know if there's any definite etiquette, and I've never investigated what value Solutions have versus Kudos.  Certainly no one is going to call you out for your kudos habits, but marking solutions correctly is appreciated.

Mensaje 7 de 7
3.405 Vistas