Discussion:
How to Generate a New Session ID in VISA
(too old to reply)
zenthoef
2008-07-28 19:10:08 UTC
Permalink
I am having an issue with my COM port setup that I believe is related to the current Session ID and selected COM port in the VISA Resource Name session.
 
I am developing a utility that allows a user to pick any number of specific USB devices connected to the computer. I do this by reading specific values in the computer's registry and pulling active COM port values for those devices. Once I detirmine the active devices, I allow the user to select the COM port of the device that they wish to use, and then this COM port value is written to an .ini file that is read from before my VI runs. This is how the VIS Asessioin knows what COM port to use. I want this process to be dynamic because different computers will assign the COM ports differently, so hard coding the COM ports is not an option.
 
A problem occurs if multiple devices are connected to the computer and an alternate COM port is selected each time the program is run. Let's say that a user starts the VI from scratch. They have the option to select a device on either COM port 4 or 5. Let's say they pick the device on COM 4. COM 4 is used to open a VISA session. Let's assume the Session ID is 0x9EEAF68 for this VISA session.
 
If the user realizes the device on COM4 is not the device they want, they can stop the program and restart it. Once again, they will be asked to select COM 4 or 5. This time the user selects COM5. The problem is the Session ID may or may not keep the value of 0x9EEAF68. If the VISA session changes the Session ID value to something other than 0x9EEAF68 then no errors will occurs when a VISA write happens. However, most of the time, the old Session ID is used. When the old Session ID is used, the first time there a VISA read occurs the VISA Read will give an error of -1073807252. After this, the old session ID is now associated with COM5 and the error will not happen again.
 
I have noticed if the Session ID changes to a different ID value then this error will not occur, even if a different COM port is selected.
 
Any ideas on how to force a new Session ID in VISA so this error is not an issue in my application?
 
Thanks in advance.
zenthoef
2008-07-28 20:40:07 UTC
Permalink
Each time the program is stopped, the last thing to happen is a VISA clear of the current VISA session. I only have one session in the entire VI. What kind of shift registers might not be initialized correctly to cause this kind of problem? I do not have my VISA session wire connected to a shift register. Nothing else related to the VISA session is related to a shift register either. Also, I always clear and flush the VISA buffers before I close the VISA session.
 
When I put a probe on the VISA session wire right after the VISA open VI, I can see that the Session ID stays the same.
 
I believe I am using NI-VISA version 4.3 (got this from the sfotware section of MAX.
 
Thanks for letting me know that I posted to the incorrect location. I will pay more attention in the future!
Dennis Knutson
2008-07-28 21:40:07 UTC
Permalink
If you are'nt using a shift register to maintain VISA session, then don't worry about it.
I don't see what you see when I create a session. I get a unique id for com1 and a unique one for com4.
Since it sounds like you are reading the names of the available ports from an external file, are you passing a string to the VISA open or an actual resource? If a string, is it COM1 or the canonical name (ASRL1::INSTR)? Frankly, I don't see an issue when I use strings either and just I'm just throwing that out.
zenthoef
2008-07-28 21:40:08 UTC
Permalink
Once I detirmine what COM port is to be used, this gets written in the .ini file and then is read out as a string. When it is read out I had connected it to VISA session indicator of class Instr. Connecting a string to this indicator causes a coercion dot (clearly...). This VISA session indicator is what is then to the VISA Open block. Since I was sloppy and let the coercion dot do the "work" for me, could this be the source of the problem?
 
The string value is not the canonical value, it is in the format of COM4. Since I am getting the values from the registry, this is the format that I get them in.
Dennis Knutson
2008-07-28 20:40:07 UTC
Permalink
You should always be getting a unique session ID for each port. When the program is stopped, are you sure you do a VISA Clear on all open sessions? Any kind of shift register that you might not be initializing correctly when the program is restarted? What version of NI-VISA are you using?
p.s. You posted to the Digital I/O board. In the future, you want to post to the instrument control board.
Continue reading on narkive:
Loading...