'How to read Enumeration values via. pyads
I'm recently using the package pyads to connect to Beckhoff TwinCAT3. The reading and writing methods work smoothly. (BTW: TwinCAT3 works fine)
But some error occurs when I try to write a value into an enumeration in TwinCAT3.
I'm using the easiest code to test:
eCtrlMode = plc.write_by_name("GVL_Tset.stTest.eCtrlMode", 1)
eCtrlMode is the instance of an enumeration "E_CtrlMode". The enumeration "E_CtrlMode in" TwinCAT3 as following:
TYPE E_CtrlMode:
(
Off := 0,
Auto := 1,
Reset := 10,
Manual := 20
);
END_TYPE
Error returns:
TypeError: 'NoneType' object is not callable
Any help, direct or recommended reading would be appreciated :)
Solution 1:[1]
Solution right now: An enumeration in this case is no other than a group of INT values. By using the write_by_name function, the pyads.PLCTYPE_INT property should always be added, otherwise it won't work:
eCtrlMode = plc.write_by_name("GVL_Tset.stTest.eCtrlMode", 1, pyads.PLCTYPE_INT)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Schwarz XU |
