Main Content

ni845xfind

Find NI USB-845x connections

Since R2024a

Description

example

N = ni845xfind finds existing persistent connections to NI™ USB-8451 or USB-8452 I2C/SPI Interface Device controllers (USB-845x controllers) and returns an array of ni845x objects corresponding to each connection.

example

N = ni845xfind(Name=Value) finds connections with property values matching those specified by one or more name-value arguments. For instance, N = ni845xfind(Tag="Accel") returns existing USB-845x controller connections whose Tag property is set to "Accel".

Examples

collapse all

When you have an ni845x connection that exists in the MATLAB® workspace or is saved as a class property or app property, the ni845x object might not be accessible in a different function or app callback. In this case, you can use ni845xfind to find and delete the connection.

N = ni845xfind
N = 

  NI845x with properties:

                   Model: "NI USB-8451"
            SerialNumber: "0180D442"
                     Tag: ""
    AvailableDigitalPins: ["P0.0"    "P0.1"    "P0.2"    "P0.3"    "P0.4"    "P0.5"    "P0.6"    "P0.7"]

To close this connection, delete N.

delete(N)

This command deletes the ni485x object and disconnects the device. If you subsequently want to reconnect to the device, you must create a new interface with ni485x.

After the deletion, calling ni485xfind confirms that there are no existing connections.

ni845xfind
ans =

     []

Note that the variable N is still present in the workspace, but it is now an invalid handle.

N
N = 

  handle to deleted NI845x

The variable persists after deletion of the interface because ni845x is a handle object. (For more information about this type of object, see Handle Object Behavior.) You can use clear to remove the invalid handle from the workspace.

clear N

You can assign a tag to a connection and use that tag with ni845xfind to access the connection later. Such tags are useful when you have multiple interfaces to keep track of across several functions. Tags are also useful for locating and accessing connections in app callbacks. To set the tag value, use the Tag property of ni845x.

Create two USB-845x connections, assigning values to the Tag property.

n1 = ni845x("0180D442",Tag="Accel");
n1 = ni845x("0180D442",Tag="Temp")

Find the connection that has the tag "Accel".

N = ni845xfind(Tag="Accel")
N = 

  NI845x with properties:

                   Model: "NI USB-8451"
            SerialNumber: "0180D442"
                     Tag: "Accel"
    AvailableDigitalPins: ["P0.0"    "P0.1"    "P0.2"    "P0.3"    "P0.4"    "P0.5"    "P0.6"    "P0.7"]

Input Arguments

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: ni845xfind(Tag="Accel",Model="NI USB-8451") returns existing connections to USB-8451 controllers whose Tag property is set to "Accel".

For ni845xfind, you can use one or more properties of the ni845x object as name-value arguments to specify characteristics of the connections you want to find.

Output Arguments

collapse all

NI USB-845x connections, returned as a ni845x object or an array of ni845x objects. If you call ni845xfind with no Name=Value pairs, N contains all existing connections. Otherwise, N contains all connections whose properties match the values you specify with Name=Value pairs.

N is empty if:

  • There are no existing USB-845x connections.

  • No existing connections match the specified property values. For instance, if you specify Tag="Scope", and there is no existing connection whose Tag property is "Scope", then S is empty.

  • You try to match a property that doesn't exist in ni845x. For instance, ni845xfind(Address="198.51.100.255") returns an empty array, because ni845x does not have an Address property.

Tips

  • ni845xfind finds existing ni845x connections. To get a list of all USB-845x controller boards in the system whether or not connections exist, use ni845xlist.

Version History

Introduced in R2024a

See Also

|