Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -301706 USB8452 device reference invalid

Solved!
Go to solution

Hi, I am a newbie here. I am trying to write a program for the I2C communication between USB8452 and other devices using python in VScode. I have encountered this error when trying to run the program. Can someone explain to me what this solution means. I got it from another person asking the same question but this answer was like 23 years ago. I already change the device alias in MAX, but still I don't know why it's not working. I have included the code as well. Thank you.

Solution:
Error -301706, indicates that the device reference is invalid. The NI-8451 driver does not support automatic detection within the VISA control. In Measurement and Automation explorer you should be able to change the name of the alias for the device to another name then save it. Your device should now run without error. I know you mention that you did provide the reference name, but you might not have saved the changes. You might get problems while reopening the resource ones the error occurs. In order to avoid this problem, errors should be cleared from the error line before passing it into the NI-845x Close Reference VI. This will allow the VI to operate properly, freeing the resource so that it can be opened in the next iteration of the program.

0 Kudos
Message 1 of 4
(160 Views)
Solution
Accepted by topic author RudyTS

Any chance that you are running 64-bit Python? The handle for the ni845x.dll is a pointer sized value, not a 32-bit value.

 

You should change the declaration in your code for all handle types in this way:

 

find_device_handle = ctypes.c_void_p()
Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(116 Views)

Hi rolfk,

 

actually yes. I came across similar post with this error. It was exactly as you have described. The NiHandle is the cause of this problem. I just changed it to ctypes.ulonglong and it works! Thank you for replying.

Regards,
RudyTS

0 Kudos
Message 3 of 4
(111 Views)

ulonlong will be a problem if you ever try to run that in 32-bit Python. It will not just give you a runtime error but corrupt your stack with all nasty problems of that.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(101 Views)