Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

New Session ID for VISA serial session?

I accidently posted this question in the Digital I/O section, so I am reposting it here in hopes more people will see it...
 
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 determine 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 string value is written to an .ini file that is read from before my VI runs. This is how the VISA sessioin 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 COM4. COM4 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 (95% of the time it keeps the same session ID). 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.
 
When the COM port string is read out of the initialization file, I had connected it to a VISA session indicator of class Instr. Connecting the string to this indicator causes a coercion dot (clearly...). This VISA session indicator is what is then connected 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?
 
Also, I open only one VISA session and I close that VISA session when the program stops.
 
Any other ideas on how to force a new Session ID in VISA so this error is not an issue in my application?
 
I am using NI-VISA version 4.3 and LabVIEW 8.5.
 
Thanks in advance.
0 Kudos
Message 1 of 3
(4,029 Views)
Hi

It seems you did a thorough investigation. But the coercion dot is probably not the problem.The session ID can be reused of course when a new port is opened.

Possible reason(s):

VISA:  (Hex 0xBFFF006C) An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.

in other words: could it be that already info was sent to the port and not read fast enough.
You can always ignore the first of this error if that is the case.

greetings from the Netherlands
0 Kudos
Message 2 of 3
(4,017 Views)
I have been using a port monitor utility in conjunction with probing the Bytes at Port line and the Bytes Read line to see that everything is read. Something in the computer must get confused and thinks that it should be receiving from the last port when it should really be reading from the current port.
 
Also, I was starting to think that I am going to have to ignore the first instance of this error. I was simply hoping for a more elegant solution. 🙂
 
Thanks.
0 Kudos
Message 3 of 3
(4,014 Views)