Skip to content

This function in ads_com "write_by_name" should return a boolean value.  #1

Description

@jodle001

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')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions