Here is the function in question. which doesn't return any boolean value.
|
def write_by_name(self, var_name, var_value, var_type): |
|
""" |
|
Write a variable to the PLC by name. |
|
|
|
:param var_name: The name of the variable to write (e.g., 'MAIN.testVar') |
|
:param var_value: The value of the variable to write (e.g., 5) |
|
:param var_type: The type of the variable to write (e.g., pyads.PLCTYPE_DWORD) |
|
""" |
|
with pyads.Connection(self.remote_ads, pyads.PORT_TC3PLC1, self.plc_ip) as plc: |
|
plc.write_by_name(var_name, var_value, var_type) |
Here is where it is returning false in every case:
|
success = self.ads_com.write_by_name( |
|
var_name='MAIN.bTest', |
|
var_value=not self.ads_com.read_by_name('MAIN.bTest', pyads.PLCTYPE_BOOL), # Toggle the existing value |
|
var_type=pyads.PLCTYPE_BOOL) |
|
|
|
if not success: |
|
self.get_logger().error('Failed to write variable to PLC') |
Here is the function in question. which doesn't return any boolean value.
ros2_pyads/ros2_pyads/ros2_pyads/ads_com.py
Lines 59 to 68 in b2dab04
Here is where it is returning false in every case:
ros2_pyads/ros2_pyads/ros2_pyads/ads_com_bool_test_node.py
Lines 41 to 47 in b2dab04