Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jodle001 opened this issue Apr 18, 2024 · 0 comments
Open

Comments

@jodle001
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant