-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use with External Dlls #45
Comments
Your issue is that not all dependencies of The
Here's a script that I used to successfully load the library. Specifying the from msl.loadlib import Client64, Server32
class DLPR200API(Server32):
def __init__(self, host, port):
super().__init__(path='PortabilityLayer.dll', libtype='cdll', host=host, port=port)
def get_compile_mode(self):
return self.lib.DLP_FlashCompile_GetCompileMode()
class DLPR200(Client64):
def __init__(self):
super().__init__(
module32=__file__,
append_environ_path=r'C:\Program Files (x86)\Texas Instruments-DLP\DLP LightCommander API SW\Lib'
)
def get_compile_mode(self):
return self.request32('get_compile_mode')
if __name__ == '__main__':
dlpr = DLPR200()
print(dlpr.get_compile_mode()) I'm not sure if the |
Thank you for these tips! I'm no longer running into the frozen server issue, but I'm still unsure if it is connect to the library correctly. Running the script above results in a return value of large positive and negative numbers (for example: -1766304000), but the documentation indicates this return value should be either a "0" or "1". To test further, I added other API methods to the Client64 and Server32 classes. I've tried including ctypes to accept the return variables, but haven't seemed to have success with this.
Traceback (most recent call last): C:\Users\ahlquist3\OneDrive - LLNL_xPuSL\General\Programming\BioPrinter, TOP DOWN, 10-3-22, BDM Folder\C\Users\scada-95\Documents\BioPuSL Labview\External Libraries\PythonIPC> |
Unfortunately, there is nothing I can do about that. The fact that you can call a function in the library means
You must define the argtypes (see example) and restype (see example) for the functions in the library. By default,
I suspect that since you didn't define The header file defines def get_version_string(self):
self.lib.DLP_Misc_GetVersionString.argtypes = [ctypes.c_char_p, ctypes.c_int32]
self.lib.DLP_Misc_GetVersionString.restype = ctypes.c_int # fine for an enum
version = ctypes.create_string_buffer(32) # hopefully 32 characters is enough, if not increase value
self.lib.DLP_Misc_GetVersionString(version, len(version))
return version.value # must return the value attribute, not the ctypes string-buffer object
You cannot pass pointers between a 32-bit process (the server) and the 64-bit process (your client) because 32-bit and 64-bit programs cannot share memory space (that's the reason for writing |
I am trying to use this package to interface with 32 bit dll's for a Texas Instruments API, but the server fails to start with the message:
"
raise PyInstallerImportError(name) from base_error
pyimod03_ctypes.install..PyInstallerImportError: Failed to load dynlib/dll 'C:\Users\ahlquist3\Anaconda3\envs\MainEnv\Lib\site-packages\msl\examples\loadlib\PortabilityLayer.dll'. Most likely this dynlib/dll was not found when the application was frozen.
Cannot start the 32-bit server.
"
From numerous stack exchange, this appears to be due to issues with ctypes.cdll() and the suggestions say to refreze the executable with a spec file pointing to the corresponding .dlls needed.
However, when running freeze_server32.main(spec='path-to-spec') it fails with the following info:
2563 INFO: PyInstaller: 4.8
2563 INFO: Python: 3.9.12 (conda)
2585 INFO: Platform: Windows-10-10.0.19045-SP0
2585 INFO: UPX is not available.
2585 INFO: Removing temporary files and cleaning cache in C:\Users\ahlquist3\AppData\Local\pyinstaller
script 'C:\Users\ahlquist3\Anaconda3\Lib\site-packages\msl\loadlib\server32-windows.py' not found
1
b''
Traceback (most recent call last):
File ~\Anaconda3\Lib\site-packages\msl\loadlib\NewServer.py:10 in
freeze_server32.main(spec='C:\Users\ahlquist3\Anaconda3\Lib\site-packages\msl\loadlib\server32-alt.spec')
File ~\Anaconda3\lib\site-packages\msl\loadlib\freeze_server32.py:191 in main
check_call(cmd)
File ~\Anaconda3\lib\subprocess.py:373 in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['C:\Users\ahlquist3\Anaconda3\python.exe', '-m', 'PyInstaller', '--distpath', 'C:\Users\ahlquist3\Anaconda3\Lib\site-packages\msl\loadlib', '--workpath', 'C:\Users\AHLQUI~1\AppData\Local\Temp\tmpciuv22kn', '--noconfirm', '--clean', 'C:\Users\ahlquist3\Anaconda3\Lib\site-packages\msl\loadlib\server32-alt.spec']' returned non-zero exit status 1.
I am eager to find a way around all of these issues - any help is immensely appreciated!
Relevant files for the DLPR200API Installer.exe can be downloaded at: https://dlinnovations.com/resources/product-downloads/ - This includes the PortabilityLayer.dll and other .dll, .lib and .h files
The text was updated successfully, but these errors were encountered: