Open FernandoGM5 opened 1 year ago
The Python wrapper is experimental. The C API is not completely wrapped in Python. But there is some examples for establishing a MMS connection: we use the IedConnection_create() API. And the error object, in that case, is fully defined.
Why don't you use the 'IedConnection' API in Python?
I am using version 1.5.0 and came across MmsConnection_connect issue requiring an MmsError * parameter type. You can do a workaround by creating an IedConnection object first, and from that object, get an MmsConnection object. So far, mms_error = None works with the other MmsConnection methods. This is just a sample code and you should add some error handling.
ip_address = "xxx.xxx.xxx.xxx"
tcp_port = 102
con = iec61850.IedConnection_create()
ied_conn_error = iec61850.IedConnection_connect(con, ip_address, tcp_port)
if (ied_conn_error == iec61850.IED_ERROR_OK):
print(f'IedConnection creation successful.')
print('trying to get the MmsConnection from the Ied Connection!')
mms_connection = iec61850.IedConnection_getMmsConnection(con)
if (mms_connection):
print('mms connection created!')
mms_error = None
mms_server_identity = iec61850.MmsConnection_identify(
mms_connection, mms_error)
if(not mms_server_identity):
print(
f'mms connection error: {mms_error} object type: {type(mms_error)}')
else:
print(f'vendor: {mms_server_identity.vendorName}')
print(f'model name: {mms_server_identity.modelName}')
print(f"revision: {mms_server_identity.revision}")
else:
print(
f"IED connection failed!")
Not possible to call MmsConnection_connect, MmsConnection_abort, ... MsgError type is required to pass an attriburte to the methods, but it's not defined in iec61850 python library.
I've seen this option: mmsError = iec61850.toMmsErrorP()
but this method it's not present in the latest lib version
Thanks