Read bit, Write bit – Measurement Computing SWITCH User Manual
Page 27
![background image](https://www.manualsdir.com/files/797896/content/doc027.png)
Switch & Sense 8 User's Guide Template
Software Library Reference (ICalUSB.dll)
27
PortNum
The port number to access. Valid entries are defined in the header file CbUsb.h and are shown below.
RELAY_PORT (0): Relay settings
FILTER_PORT (2): Filter settings
DataValue
A user-defined integer variable that contains the relay or filter setting value. Supply the value as a decimal
number. For example, to energize all eight relays, set the value to 255.
Return values
CBUSB_SUCCESS (0)
: Call completed successfully
Read bit
long cbUSBDBitIn (int DeviceNum, int PortNum, int BitNum, int *BitValue)
Reads a single bit value for any board port. It is similar to the previous read port function with the addition of a
BitNum argument. BitNum determines the individual input to read.
Use of this function is to read the state of a single isolated input and determine the current state of any one of
the isolated input filters or SPDT relays.
Arguments
DeviceNum
A number assigned by IcalUsb to the physical device. By default, if there is only one device in the system,
this number is 0.
PortNum
The port number to access. Valid entries are defined in the header file CbUsb.h and are shown below.
RELAY_PORT (0)
: Relay settings
ISO_PORT (1):
Isolated input state
FILTER_PORT (2): Filter settings
BitNum
The bit number to access. Each port is eight bits wide so valid entries are from 0 to 7.
DataValue
A pointer to a user-defined integer variable that will receive the state of the specific bit on return. The data
value is either (0) or (1).
Return values
CBUSB_SUCCESS (0):
Call completed successfully.
Write bit
long cbUSBDBitOut (int DeviceNum, int PortNum, int BitNum, int BitValue)
Writes a single bit value to any of the Switch & Sense 8 ports that are write-enabled. This function
complements the Read bit function (see pg. 4-27). The BitNum argument specifies the individual input bit to
write.
Use this function to set the state of a single SPDT relay, or to set the state of any one of the isolated input filters.