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
857 stars 459 forks source link

How to use download handler in python? #371

Open ahsanww opened 2 years ago

ahsanww commented 2 years ago

Hi. I would like to use python wrapper libiec61850 to download file from iec61850 server. But i cant implement download handler from your library. I try using other library from robidev lib61850 with ctypes wrapper and i still cant implement download handler. Jow i can implement this? Any help is much appreciated. Thanks

PhM34 commented 2 years ago

Hi, I have similar issue , libiec61850 used is 1.5 , when I execute this code, I get a valid list from my server but impossible to use FileDirectoryEntry_getFileName : [fileList, error] = iec61850.IedConnection_getFileDirectory(con, "C:/temp/COMTRADE/BCU01") if (error == iec61850.IED_ERROR_OK): fileEntry = iec61850.LinkedList_getNext(fileList) while fileEntry: fname=iec61850.FileDirectoryEntry_getFileName(fileEntry.data)

I always get this cast exception : File "C:\Users\xxx\AppData\Local\Programs\Python\Python310-32\lib\iec61850.py", line 791, in FileDirectoryEntry_getFileName return _iec61850.FileDirectoryEntry_getFileName(_self) TypeError: in method 'FileDirectoryEntry_getFileName', argument 1 of type 'FileDirectoryEntry'

Same error when I try fname=iec61850.FileDirectoryEntry_getFileName(fileEntry)

It looks like this structure is not correctly handled by python wrapper => struct sFileDirectoryEntry { char* fileName; uint32_t fileSize; uint64_t lastModified; };

Thx for any help

ahsanww commented 2 years ago

your 'fileEntry' is LinkedList not FileDirectoryEntry. your 'entry' must convert to FileDirectoryEntry. use this https://github.com/mz-automation/libiec61850/issues/67#issuecomment-918427743 to add new function

PhM34 commented 2 years ago

Thank you , it helped and it works now. I did not imagine we had to create conversion functions for such types.

darkjhesus commented 1 year ago

Thank you , it helped and it works now. I did not imagine we had to create conversion functions for such types.

Dear PhM34, could you share the solution to read files from IEC61850 server?