2

I would like to access our Citect SCADA system from external script in Python. I found some example code here: https://github.com/mitchyg/Random/blob/master/pyctapi/src/pyctapi.py

When I run this fragment of code:

def ct_tag_read(self, tag_name):
    buffer = create_string_buffer('\000' * 32)
    ok = windll.CtApi.ctTagRead(self.hCTAPI, tag_name, byref(buffer), sizeof(buffer), None)

    return buffer.value

I get this error:

line 63, in create_string_buffer
raise TypeError(init)
TypeError:  

I am using Python 3.5.

Here is description of Citect API function ct_TagRead:

http://www.citect.schneider-electric.com/webhelp/vijeo740/Content/ctTagRead.html

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

OK, first of all i mixed up arguments for ctCicode and ctTagRead so code should look like(without ",None" argument):

def ct_tag_read(self, tag_name):
    buffer = create_string_buffer('\000' * 32)
    ok = windll.CtApi.ctTagRead(self.hCTAPI, tag_name, byref(buffer), sizeof(buffer))
    if ok == False:
        print("Unable to read TAG")
        return

return buffer.value

I switched to python 2.7 and everything works fine.