libiec61850
libiec61850 copied to clipboard
How to read INT16U in Python?
Hello. how to read INT16U value by IEC client?
This not working:
def read_int16u(var_name):
con = iec61850.IedConnection_create()
error = iec61850.IedConnection_connect(con, "127.0.0.1", 102)
if error != iec61850.IED_ERROR_OK:
iec61850.IedConnection_destroy(con)
assert False, "IEC-61850 connection failed!"
val = iec61850.IedConnection_readUnsigned32Value(con, var_name, iec61850.IEC61850_FC_ST)
print("READ IEC Var: ", var_name, " value: ", val)
iec61850.IedConnection_close(con)
iec61850.IedConnection_destroy(con)
It should work this way. What is the error?
It should work this way. What is the error?
Value is 0. Correct value is 2.
I did solved this problem.
I did created new function -> IedConnection_readBitStringAsIntegerBigEndian()
def read_bit_string(var_name):
con = iec61850.IedConnection_create()
error = iec61850.IedConnection_connect(con, "127.0.0.1", 102)
if error != iec61850.IED_ERROR_OK:
iec61850.IedConnection_destroy(con)
assert False, "IEC-61850 connection failed!"
val = iec61850.IedConnection_readBitStringAsIntegerBigEndian(con, var_name, iec61850.IEC61850_FC_ST)
print("READ IEC Var:", var_name, " value:", val)
iec61850.IedConnection_close(con)
iec61850.IedConnection_destroy(con)
return val[0]
My pull request - https://github.com/mz-automation/libiec61850/pull/277