Skip to content
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

Foreign library with cdll instead of windll #77

Open
aquilesC opened this issue Sep 6, 2017 · 0 comments
Open

Foreign library with cdll instead of windll #77

aquilesC opened this issue Sep 6, 2017 · 0 comments

Comments

@aquilesC
Copy link
Contributor

aquilesC commented Sep 6, 2017

I'm building a wrapper for the new Thorlabs Kinesis drivers using from lantz.foreign import LibraryDriver, and found that by default the class Library loads the dll as:

if os.name == 'nt':
    library = ctypes.WinDLL(library)

However, for some reason when I try to call a function, like CC_Open (this is device specific), I get the following error:

Exception: While calling CC_Open with [b'83843619'] (was (b'83843619',)): Procedure probably called with too many arguments (4 bytes in excess)

This is easily solved if i use library = ctypes.CDLL(library).

I imagine that it is not safe to assume the library loader based solely on the operating system, however I don't see a clear way of overriding it; the class Library is able to do so:

class Library(object):
    def __init__(self, library, prefix='', wrapper=None):
        if isinstance(library, str):

just by providing a library that is not a string (i.e. the library already loaded)
But the base class LibraryDriver iterates over names. I don't see a clear solution that wouldn't ruin downstream code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant