Reading String output of a DLL in Sikuli

Asked by Vinitha Palanisamy on 2020-07-15

Hi,

I have a DLL which was built using LabVIEW. The syntax of the function I have to call in Sikuli is given below.

void __cdecl ReadString(char StrOutput[], int32_t len);

The DLL was built with 'C Calling Convention'. Can anyone please help me to handle the C type String in Sikuli? I have tried some methods but nothing seems to be working.

Thanks,
Vinitha

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-07-15
Last reply:
2020-07-21
RaiMan (raimund-hocke) said : #1

please provide a code snippet, where you call the DLL and try to evaluate the return value.

Vinitha Palanisamy (vinitha-p) said : #2

Hi Raiman,

Thank you for your time. Actually my problem was solved. Following is the working code. I have missed the line 'ocrStrBufObj = ocrStrBufClass(ocrInitStr)' (line 4 in following snippet) previously which made my code not working.

from ctypes import *

ocrStrBufClass = c_char_p
ocrStrBufSize = 100
ocrInitStr = ' ' * ocrStrBufSize
ocrStrBufObj = ocrStrBufClass(ocrInitStr)

dllPath = "D:\Sikuli\LabVIEWOCR\DLL\LabVIEWOCR.dll"

#void __cdecl PerformOCR(char ReadString[], int32_t len);

mydll = cdll.LoadLibrary(dllPath)
funcPerformOCR = mydll.PerformOCR
funcPerformOCR.argtypes = [c_char_p, c_longlong]
funcPerformOCR.restype = c_void_p
funcPerformOCR(ocrStrBufObj, ocrStrBufSize)
print(ocrStrBufObj.value)

Regards,
Vintiha

RaiMan (raimund-hocke) said : #4

by user himself