zenthoef
2008-07-28 19:10:08 UTC
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.
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.