7.2.9.2 The BITSET statement

Some devices report their fault state as a number in which each bit represents one fault flag. The BITSET statement is used to decode flags from such a status value. Usually the fault status is read into an internal variable if the driver. Then the fault bits are decoded from this internal variable using the BITSET statement.

bitset-statement.gif

The bit position zero addresses the least significant bit in the source variable. The destination variable gets set to 1 or true if the addressed bit is set, to 0 or false if not. If the variable name is preceded by an exclamation mark, this mapping is inverted.

Example

        INPUT internal.flags
        BITSET faults.01 = internal.flags  4    // Temperature
        BITSET faults.02 = internal.flags  5    // Signal level
        BITSET faults.03 = ! internal.flags  11 // Video lock (inv)
        BITSET faults.04 = ! internal.flags  9  // Audio lock (inv)
        BITSET faults.05 = internal.flags  13   // High BER
        BITSET faults.06 = internal.flags  15   // Demodulator lock
        BITSET faults.07 = internal.flags  14   // Conditional Access

The example above reads a value into the variable internal.flags. BITSET statements are used to extract seven faults flags from this variable. internal.flags must be declared READONLY to make this example work.