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

Pycomm to micro 820 #59

Closed
clemansta opened this issue Jun 14, 2019 · 1 comment
Closed

Pycomm to micro 820 #59

clemansta opened this issue Jun 14, 2019 · 1 comment

Comments

@clemansta
Copy link

I am trying to use the pycomm to speak with a micro 820. The error I am receiving is:
Read in Values:
A session need to be registered before to call forward open
The code I am using is directly from the examples CLX code see below:

from pycomm.ab_comm.clx import Driver as ClxDriver
import logging

from time import *


if __name__ == '__main__':

    logging.basicConfig(
        filename="ClxDriver.log",
        format="%(levelname)-10s %(asctime)s %(message)s",
        level=logging.DEBUG
    )
    c = ClxDriver()

    print c['port']

    if c.open('10.1.0.6', direct_connection=True):
        print("Open Connection")
        while 1:
            try:
                print("Read in Values:")
                print(c.read_tag(['Controls']))
                print(c.read_tag(['Control_Points_1[1]', 'Control_Points_1[2]', 'Control_Points_1[3]',
                                  'Control_Points_1[4]']))

                print("Write out values:")
                print(c.write_tag('Sensor_Active', 3, 'DINT'))
                print(c.write_tag(('Sensor_Active_1', 1, 'DINT')))
                print(c.write_tag([('Control_Points_2[1]', 4.0, 'real'), ('Control_Points_2[3]', 6.0, 'real'),
                                   ('Control_Points_2[5]', 8.0, 'real'), ('Control_Points_2[7]', 10.0, 'real')]))
                time.sleep(1)

            except Exception as e:
                c.close()
                print e
                pass

        # To read an array
        r_array = c.read_array("Sensor_Value", 1750)
        print("Print an array:")
        for tag in r_array:
            print (tag)

        c.close()

Any help would be appreciated.

@clemansta
Copy link
Author

clemansta commented Jun 14, 2019

Added

c = ClxDriver()
c.register_session()

Now the errors are:

Traceback (most recent call last):
  File "/TEMS_Software_V_1_1/API/Comm_CIP.py", line 15, in <module>
    c.register_session()
  File "/usr/local/lib/python2.7/dist-packages/pycomm/cip/cip_base.py", line 656, in register_session
    self._send()
  File "/usr/local/lib/python2.7/dist-packages/pycomm/cip/cip_base.py", line 801, in _send
    raise CommError(e)
pycomm.cip.cip_base.CommError: 'NoneType' object has no attribute 'send'

Am I missing something?

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