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

LibraryInterpreter.read_raw and write_raw do not allow switching array dtypes #578

Open
bkeryan opened this issue May 8, 2024 · 0 comments

Comments

@bkeryan
Copy link
Collaborator

bkeryan commented May 8, 2024

LibraryInterpreter.read_raw sets cfunc.argtypes based on the dtype of the array you pass in:

    def read_raw(self, task, num_samps_per_chan, timeout, read_array):
        samples_read = ctypes.c_int()
        number_of_bytes_per_sample = ctypes.c_int()

        cfunc = lib_importer.windll.DAQmxReadRaw
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes.c_int, ctypes.c_double,
                        wrapped_ndpointer(dtype=read_array.dtype, flags=('C', 'W')),
                        ctypes.c_uint, ctypes.POINTER(ctypes.c_int),
                        ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)]
        ...

However, this is incorrect because cfunc.argtypes is only initialized once.

I haven't tested this yet, but I expect it to remember the dtype of the 1st array that you pass to task.in_stream.read_into() and reject any array with a different dtype.

I think the correct way to make ndpointer accept any array dtype is to specify dtype=None.

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