11-26-2019 06:08 AM - edited 11-26-2019 06:09 AM
Hello,
I have an issue when I try to open multiple communicating sessions between my controller and Asterion AC power model AST2253.
To establish the initial communication I use NI VISA toolset 5.6.0 and VISA library.
In my program I must use multiple access mechanism and then I call at least two times "viOpen" VISA function.
My problem is the following :
As I said above, I call the function viOpen twice to open two sessions on my instrument. The both status returned are SUCCESS and handles are differents. I can work with the both handles together without any problems.
However, at the end of the first part of my program, I close the first open handle with function viClose. After this step I cannot use any session on my instrument ... The other functions which use second open handle return FAILURE with VI_ERROR_INV_OBJECT error code.
It seems that the first (and the only) call of viClose() on the first open handle has closed ALL open handles.
This program works perfectly with all my others instruments (DMM+DCPWR+SWITCH) and then I need help to resolve my issue...
For debuging I used Wireshark to see all VXI frames between the controller and the instrument and I saw something may be interesting :
The call of viOpen function send create_link() request (VXI function) and then it creates a session designated by a unique ID.
In all correct cases at each time the function create_link() is called, a unique ID is returned by each call.
In the bad case all call of create_link() returns the SAME ID. And so when the first call of viClose occurs the VXI function destroy_link() terminates the only ID which is opened. Then the following functions use an ID which is already close.
For example :
Good behavior :
-Create_link call in instrument 1 (opening handle 1)
-Return ID = 0x01
-Create_link call in instrument 1 (another time)
-Return ID = 0x02
/*** My program using handles 1 & 2 ***/
-Destroy_link call ID = 0x01
/*** My program using only handle 2 ***/
-Destroy_link call ID = 0x02
Bad behavior :
-Create_link call in ASTERION
-Return ID = 0x01
-Create_link call in ASTERION
-Return ID = 0x01
/*** My program using handles 1 & 2 ***/
-Destroy_link call ID = 0x01
/*** My program using only handle 2 ***/
-Destroy_link call ID = 0x01
I've checked many datasheets, programming manuals, VXI standard, etc... but I did not find any way to resolve my issue.
Is there a flag or a key somewhere to activate this behavior ? Or something else ?
Please, can you help me ?
Thanks
11-26-2019 11:41 AM
Without any specifics, I can only reply in the general.
Most instruments only allow a single connection and the second open may only be acting as link to the original open. This would explain why it allowed a second open, but close everything at the first appearance of a Vi Close. Instruments expect the following:
11-27-2019 02:58 AM
Thanks for your answer.
So it is only the instrument which is specified as a "single session device" ? Of course I have no access to the instrument ...
I think I know the answer but, there is a way to "force" the multisession on the instrument from the controller ? Maybe a special configuration of MAX, or something else ?
11-27-2019 06:34 AM
You need to think of this from the instrument standpoint and not NIMax. If it were capable of 2 separate threads, and received the following from both:
What would you expect to read?
That is the reason that most instruments only handle a single thread.
11-28-2019 02:54 AM
My architecture is built as the following :
thread 1 > safety module : open a session (handle A) + event configuration (install handlers/enable events/etc...) + asynchronous error management, etc...
thread 2 > application module : open a new session (handle B) + execute application (set/write/read/etc...)
The both threads are built to be independant and according to previous tests it seems they are. I can open/close sessions at every moment of first thread, the second works perfecly.
Because of specifications I need to do a polling on the STB register which will continue all over the runtime process. So, I create a third thread which open a third session and query "STB?" every polling period (5 sec for example). It works perfectly (with my all instruments) even if one of the other thread closes his session meantime. Except for my new PWR SUPPLY which closes all opened session when we call the viClose of the first thread.