.. _set_output_register_bit: set_output_register_bit ------------------------------------------ This function writes a **single bit** to the controller **output register** using the specified **register address** and **bit value**. It is typically used for PLC I/O register control in Ethernet-based environments. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp bool set_output_register_bit(unsigned short address, int val) { return _set_output_register_bit(_rbtCtrl, address, val); }; **Parameter** .. list-table:: :widths: 20 20 20 55 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - address - unsigned short - - - Output register address (bit type, 0~63) * - val - int - - - **Bit value** to write |br| `0` : OFF |br| `1` : ON **Return** .. list-table:: :widths: 25 75 :header-rows: 1 * - **Value** - **Description** * - 0 - Error: failed to write output register bit * - 1 - Success: output register bit written **Example** .. code-block:: cpp #include "DRFLEx.h" #include using namespace DRAFramework; int main() { CDRFLEx robot; const char* ip = "192.168.137.100"; if (!robot.open_connection(ip)) { std::cout << "Failed to connect: " << ip << std::endl; return 1; } // Write bit and read back (timeout 300 ms) // Initialize to -1 to indicate “not read yet” if the call fails. int out_bit = -1; robot.set_output_register_bit(0, 1); robot.get_output_register_bit(0, out_bit, 300); std::cout << "addr=0, out_bit=" << out_bit << std::endl; robot.close_connection(); return 0; } This example sets the output register bit at **address 0 (Bit_Output_Register[0])** to ON and reads it back.