mz-automation / libiec61850

Official repository for libIEC61850, the open-source library for the IEC 61850 protocols
http://libiec61850.com/libiec61850
GNU General Public License v3.0
863 stars 461 forks source link

IedConnection_getFile - type error in python #475

Open Harol2n opened 1 year ago

Harol2n commented 1 year ago

Hi,

Im trying to read comtrade files from IEDs, today i can read the file directory and i know exactly where the files are. The problem is when i try to get the file, using:

iec61850.IedConnection_getFile(con,ruta,downloadHandler,None)

i get the next error _TypeError: in method 'IedConnectiongetFile', argument 4 of type 'IedClientGetFileHandler'

seeing the file-tool.c file, the 3° argument (downloadHandler) is a function like this:

def downloadHandler(parameter, buffer, bytesRead):
    prmtr = parameter
    if bytesRead >0:
        print("received: ", bytesRead, " bytes")
        return True
    return False

but it just a function, the 3° argument has to be 'IedClientGetFileHandler' type, but i cant do it. So, how can i get a 'IedClientGetFileHandler' type to the 3 argument?

KartikSoneji commented 11 months ago

You can't pass a python function to C code directly. You'll have to wrap the method in a custom handler, easiest will be to get the whole file and return a bytes object to python.