# Write\_output\_integer\_register command doesn't always sets the value

**URL:** <https://forum.universal-robots.com/t/write-output-integer-register-command-doesnt-always-sets-the-value/27177>\
**Category:** Technical Questions\
**Created:** [March 5, 2023, 10:55pm UTC](https://forum.universal-robots.com/t/write-output-integer-register-command-doesnt-always-sets-the-value/27177 "2023-03-05T22:55:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![igaris](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@igaris](https://forum.universal-robots.com/u/igaris)\
**Post date:** [March 5, 2023, 10:55pm UTC](https://forum.universal-robots.com/t/write-output-integer-register-command-doesnt-always-sets-the-value/27177/1 "2023-03-05T22:55:02Z")

</div>

I’m using `IronPython` to send scripts and commands from C# to the robot through python `rtde.py` and `socket.py` modules.

I want to reset a few output registers such as `output_int_register_24` and bits 0 and 1 of register `output_bit_registers0_to_31`. To do that I send the script below through socket

```auto
"sec clear_registers():\n" +
                    " write_output_integer_register(24 ,0)\n" +
                    " write_output_boolean_register(0, False)\n" +
                    " write_output_boolean_register(1, False)\n" +
 "end\n";

```

After that, I want to make sure the registers have been reset. To do this, I have a loop that receives the state, checks the values of the registers `output_int_register_24` and `output_bit_registers0_to_31` for 0, and if they are really 0 then it breaks the loop. In most cases, the loop ends almost immediately, which means the registers are indeed set to 0. But sometimes the loop never stops, which means the registers are not set to 0. Meaning the condition

```auto
state.output_int_register_24 == 0 && state.output_bit_registers0_to_31 == 0

```

never met. I wonder what the problem might be.  
In the case where this “infinite” loop occurs, if I disconnect and reconnect to the robot and send this script again, it sets them to 0.  
Do I need to use different sets of commands in the script above?

```auto
rtde = rtde.RTDE(robotIP, rtdePort);
rtde.connect();

while (true)
{
	var state = rtde.receive(false);
	if (state == null)
		throw new RTDEException("Couldn't recieve data package from RTDE");

	if (state.output_int_register_24 == 0 && state.output_bit_registers0_to_31 == 0)
		break;
}

```
