LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

".NET refnum" instead of "byte array"

I'm using a .NET library (written in C#) and one of the properties I'm trying to access (using the Property Node) is a fixed byte array in the C# code, but it's seen in Labview as ".NET refnum".  It won't let me input it to a function as a byte array.  Labview won't even let me index the array, so I guess it's being interpreted as a single value rather than an array of values.  Has anyone encountered this problem before?

 

This is what the code and error looks like:

 

http://img600.imageshack.us/img600/3180/errorjo.jpg

0 Kudos
Message 1 of 7
(4,287 Views)

Interesting, from here it looks like Labview should detect the .NET byte array correctly.

Another interesting point that it correclty detects the byte array at "CreateConnection" property at your picture.

Are these properties of the same type inside your C# code?

 

By the way, if during developement you change the type of properties, it better to remove all references to asseblies and rewrite from

the beginning. (At least in Labview 8.6, now may be fixed).

 

Michael.

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


0 Kudos
Message 2 of 7
(4,267 Views)

You might need to convert the refnum into a byte array by using the .NET Object to Variant.vi function. Then investigate what the variant is. Most likely you can connect it directly to the input or optionally use Variant to Data to convert it explicitedly.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 7
(4,262 Views)

Thanks for the suggestion, but it hasn't quite worked.  I tried making it a variant and then using the "Variant to Data" function to convert it into a byte array.  This compiled but gave me an error at runtime that says this: "The data type of the variant is not compatible with the data type wired to the type input." (I wired a numeric array to the input)   When I used an indicator to create a "property" for the value in question, it says it's a FixedElementField, whatever that means.  I'm still not sure why it doesn't interpret the "fixed byte array" in C# as a byte array.  All "fixed" means is that its length is predetermined and unchangeable.  Any suggestions?

0 Kudos
Message 4 of 7
(4,235 Views)

Based on what you've described, it sounds like everything should be working with those settings, but it'd be nice to take a closer look at it. 

 

Would you be able to post your actual code (or at least the part that you've shown in the picture you linked) that is calling the byte array?

 

Also, what is your C# function prototype for your device address?  Once we're able to look at your code with that known func. prototype, we can help verify your return type.

Regards,
Austin S.

National Instruments
Academic Field Engineer
0 Kudos
Message 5 of 7
(4,213 Views)

When I try to connect the two items with no variant, it looks like this and gives me a compile error:

http://img31.imageshack.us/img31/1825/deviceaddressconnection.jpg

 

When I use the .NET Object to Variant tool with the Variant to Data tool, it looks like this but gives me the run-time error I mentioned in my previous post:

http://img198.imageshack.us/img198/6429/deviceaddresstovariantr.jpg

 

This is my function prototype:

http://img825.imageshack.us/img825/6682/createconnectionfunctio.jpg

 

And this is where I declare the deviceAddress property:

http://img863.imageshack.us/img863/7838/gapdevicediscoverydonee.jpg

 

I also created a value indicator and a GetType indicator.  Neither of them told me anything.  Thanks for any help!

0 Kudos
Message 6 of 7
(4,196 Views)

Hello,

 

Hmm, It looks like LabVIEW is still typecasting your input to "slave". Are you sure that the array you are building is EXACTLY the same size/dimensions that your object is expecting? I would not expect labview to have to typecast from similarly sized byte arrays. Try right clicking the terminal to slave, and creating a new constant from there to see exactly what is expected.

Cheers!

TJ G
0 Kudos
Message 7 of 7
(4,185 Views)