Jump to content
  • 0

ArgumentError when calling enable_event() (Python mcculw)


TMWang

Question

Hi,

In the attached Notebook, I was trying to test event callbacks. However, I got the error "ArgumentError: argument 4: TypeError: expected WinFunctionType instance instead of WinFunctionType", which I couldn't figure out the cause of it. I believe I have made a function instance in addition to the function definition (e.g. samplesAcquiredFcn_c in the Notebook). Could you help me find the problem please? I am not familiar with ctypes and couldn't find an example for enable_event(), either.

Thanks for your help!

TM.

System info:

Python - 3.10.13

mcculw - 1.0.0

DAQ - demo board or USB-1608GX-2AO

OS: - Windows 11

 

Screenshot 2024-09-25 160211.png

MCC_demoBoard.ipynb

Edited by TMWang
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I looked into the ul.py file and found that the callback signature in my original code was incorrect. The correct signature can be imported directly:

from mcculw.ul import ULEventCallback

samplesAcquiredFcn_c = ULEventCallback(samplesAcquiredFcn)
endOfScanFcn_c = ULEventCallback(endOfScanFcn)

Alternatively, the signature can be defined directly as:

CALLBACK_FUNC_TYPE = WINFUNCTYPE(None, c_int, c_uint, c_uint, c_void_p)

This should solve the ArgumentError problem mentioned in the post.

I found additional bugs in my code after fixing the ArgumentError problem. Since it's not relevant to this topic and easy to fix, I will just stop here.

Best,

TM.

Edited by TMWang
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...