The MacView

Virtual Instrumentation from a Mac perspective

My Photo
Name:
Location: Pflugerville, TX, United States

Friday, January 20, 2006

ADVANCED: How To Call The Mac OS Directly From LabVIEW Part III: Simple Parameter Types

See Part I of this series for the obligatory warning about using the Call Library Function Node.

Let's look at another example that shipped with LabVIEW 8.0. In vi.lib/Platform/Miscellaneous.llb, there is a VI, Check Connection To DNS Address.vi. This VI wraps a call to SCNetworkCheckReachabilityByName .

As you can see, the parameters for this call are a little more complicated. First, double click on the Call Library Function Node to see how it is configured. You can see that we are calling into SystemConfiguration.framework (as the documentation above states).

Notice the Parameter return value is Boolean. This string is the label of the return terminal on the Node. I used Boolean here so that the return value type would be more apparent. However, I did make a mistake. If you look in MacTypes.h, you'll notice that a Boolean is defined to be an unsigned char (or Unsigned 8-bit integer), however, I had the return type declared as an Unsigned 32-bit Integer. Luckily it just happens to work in this case, but it will be changed in a future release.

To look at the other parameters you can click on the pop-up next to Parameter. You should see three items in the list (the return type and the two parameters). Go ahead and select DNSName. Notice it is a C String Pointer. When you look at Apple's Documentation, it has a const char *nodename parameter, which is a C String Pointer.

Now lets look at the flags parameter. Notice it is a Pointer to Value. If you look at Apple's Documentation, it says that last parameter is a SCNetworkConnectionFlags, but doesn't say what a SCNetworkConnectionFlags is. If you look in the header file (SCNetwork.h), you can see that it is defined to be a uint32_t (Unsigned 32-bit Integer), and it is passed by pointer.

Now if you look at the dialog (cancel the configuration dialog), you can see that we can just wire a String into the first parameter. The second parameter is an out only parameter, and it is suggested you wire an invalid/NULL/zero value to out inputs.

We use similar techniques to the ones used in the previous post to get the bits out to return. Note that the Index Array primitive (Programming -> Array) starts at zero be default and increments by one. The last two bits we get out are 16 and 17, so we skip to 16 and the next one would be 17.

In part IV, we will look at complex data types passed into and out of the Call Library Function Node.

0 Comments:

Post a Comment

<< Home

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.