-
Notifications
You must be signed in to change notification settings - Fork 42
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
incorrect use of WinDLL #261
Comments
Tested the ALPAO mirror wrapper. Replacing microscope/microscope/_wrappers/asdk.py Line 29 in 55138bf
|
carandraug
added a commit
that referenced
this issue
Jan 12, 2023
Thank you for testing Danny. I've pushed e837dfc. I've also asked @thomasmfish by email whether he could check the Linkam stage. |
carandraug
pushed a commit
that referenced
this issue
Mar 20, 2023
Tom Fish says that Diamond is using CDLL for the linkam stage there and it works for them. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We use
ctypes.WinDLL
to load all shared libraries in Windows but that's wrong. We should be usingctypes.CDLL
even on Windows for some libraries.We have been using
WinDLL
under the incorrect assumption that's what one needs to do in Windows. However, the choice is not about the underlying OS, it's about the calling convention used by the functions. We should be usingWinDLL
to access functions that use thestdcall
calling convention andCDLL
to access functions that use the standard C calling convention (calledcdecl
on Windows).If I understood this correctly, we need to check the header files and see if in Windows the functions are defined with
__stdcall
(may happen indirectly such as when theWINAPI
macro is used). If not, then we should be usingCDLL
even on windows. It seems that using the wrong one will not immediately lead to issues but may lead to weird unpredictably issues later.I've checked the header files and seems we need to change for Alpao and BMC mirrors, for Hamamatsu cameras, and for Linkam stages:
microscope/_wrappers/asdk.py
)microscope/_wrappers/BMC.py
)microscope/_wrappers/dcamapi4.py
)microscope/_wrappers/mirao52e.py
)MIRAOCALL
expands to__stdcall
)microscope/cameras/pvcam.py
)PV_DECL
expands to__stdcall
on Windows)microscope/cameras/atmcd.py
)WINAPI
on one version but nothing on other)microscope/cameras/_SDK3.py
)AT_EXP_CONV
expands toWINAPI
)microscope/stages/linkam.py
)However, I no longer have access to any of these. Could someone who does have access test it?
The text was updated successfully, but these errors were encountered: