JHoyParticipantJHoy March 23, 2022 at 11:25 am
I have two issues I am trying to resolve.
1) I am using the Spyder IDE through Anaconda. Lets say I wish to debug and step through the “sweep_plot.py” example. I often need to “cntr+c” or abort using the “stop Debugging” button after the device has been opened, but before it has been closed. After doing this, I cannot reconnect to the device unless I close the console window and/or unplug and re-plug the device. How might I make this a little more robust so that an error like this will automatically reset the device if I no longer have the device handle?
2) I noticed that the C API has a function call to get the S/N of the attached devices “saGetSerialNumberList”. Unfortunately, the Python API does not include this function call and I am not entirely sure how to implement it. I need to run multiple SA124B’s on a single computer and need to present an option for which one to open. How might I get this function to work?
AndrewModeratorAndrew March 23, 2022 at 2:33 pm
1) As long as the DLL is loaded, if you have opened the device via the saOpenDevice function, you will not be able to open the device again until either, you close the device, or unload the DLL. We have seen some environments like Matlab/Labview keep the DLLs loaded until you restart the environment. One way customers have got around this is by closing all possible device handles before their script starts, this ensures any open devices from a previous run close. If you are interfacing a single device, the handle will always be 0, so you can just call saCloseDevice(0) at the beginning of your script and that should make it available again.
2) The Python libraries may not stay completely up to date with the C ones. You can just add the function to the python interface. I believe we have implemented this function for the BB and/or SM200 APIs, you could check the python interfaces for an example of how to do it.
Here is how it is done in the SMAPI, this is defined in the sm_api.py file alongside the other function definitions.
smGetDeviceList = smlib.smGetDeviceList
smGetDeviceList.argtypes = [
numpy.ctypeslib.ndpointer(c_int, ndim=1, flags=’C’),
You must be logged in to reply to this topic.