describing the error. Based on the instrumentDescriptor parameter which contains the instrument address descriptor, we try to open a communication session with the instrument located at that address. This is done using the viOpen() function with the param- eters listed below (Figure 12.43). Direction Description Resource Manager session (should always be the session returned from viOpenDefaultRM()) rsrcName Unique symbolic name of a resource. See the Description section for more information. accessMode Specifies the mode by which the resource is to be accessed. See the Description section for valid values. If the parameter value is VI_NULL, the session uses VISA-supplied default values. Multiple access modes can be used simultaneously by specifying a bit-wise OR of the values other than VI NULL. timeout Specifies the maximum time period (in milliseconds) that this operation waits before returning an error. Unique logical identifier reference to a session. Figure 12.43 Parameters of viOpen() function. Tele-Measurement Services for m-Learning Direction Description Unique logical identifier to a session. Location of a data block to be sent to a device. count Number of bytes to be written. retCount Number of bytes actually transferred. Figure 12.44 Parameters of viWrite() function. status = viOpen (defaultRM, instrumentDescriptor, (I NULL, VI_NULL, &instr) i The viOpen() function opens a session to the specified resource. It returns a session identifier that can be used to call any other operation of that resource. After successfully opening a session to the instrument resource, we will try to write the command on this resource. This is done using the viWrite() function provided by NI-VISA with the following parameters (Figure 12.44): ViUInt32 writeCount; status = viWrite (instr, (ViBuf) command, (ViUInt32) strlen (command) , &writeCount) ; if (status < VI_SUCCESS) status = viClose (instr) ; status = viClose (defaultRM) ; cmdRes - > executionStatus = "ERROR"; cmdRes - > errorMessage = "Error writing to the device"; r