Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

setting VISA serial port settings does not persist

Solved!
Go to solution

when I set the baud rate using the VISA Interactive Control panel for a particular serial port (ASRL) and then close the window for that ASRL, the baud rate goes back to the default.  Why doesn't the baud rate stick?

 

Also when I change port settings for a particular serial port (COM) on the Windows side, why don't I see those same port settings when I look at them from the VISA Interactive Control panel??

 

Also, when I programatically set the baud rate for a particular ASRL (C code), why is it reset back to the default when I re-run my program and do a get on the baud rate???

 

Some background:

My C program runs on an industrial PC that has a MXI PXI expansion chassis connected to it.  The 3 serial cards are in the expansion chassis.

0 Kudos
Message 1 of 21
(5,744 Views)

I don't think the interactive control or a program that calls the same functions is supposed to change the system defaults. If you open MAX and for the com port, go to the port settings tab, those do persist. And when I change the port settings in windows device manager and then open MAX, I get a message saying that settings conflict and asks which ones do I want to keep.

 

Message 2 of 21
(5,736 Views)

Dennis is correct, changing settings in your application does not change the system defaults. I recommend you configure all the parameters you need in your application, and not rely on system defaults. Relying on default values causes problems if you move your application to another computer, or set it to use another serial port, where the defaults may be different.

0 Kudos
Message 3 of 21
(5,721 Views)

What I am trying to do is to program the device using the VISA API in a C program running on windows.

 

In my program I am calling viSetAttribute() on the VI_ATTR_ASRL_BAUD attribute of a particular ASRL (serial port).  I change the baud rate to 4800.  Then I do a viGetAttribute() on the baud rate and I see that it has changed.  Then I do a viClose (instr) and a viClose (defaultRM) and exit.

 

I would expect that when I come back into my program and do a viGetAttribute on the baud rate, that it would be the value that I last set it to.

 

I would also expect that MAX would show the baud rate that I just set in my program for that particular serial port.

 

This is not the case.  The baud rate that I read when I go back into the program is the one that had been set earlier (before I ran my program the first time) in MAX.

 

So it seems that I cannot change the baud rate programmatically and have the changes persist.

0 Kudos
Message 4 of 21
(5,706 Views)
Solution
Accepted by topic author Tim4software

When you close out the VISA session and/or close out your application, the port settings goes back to the system defaults.  This is very normal behavior.  As long as you keep your VISA session open, the port will behave the way you told it (set Baud Rate, etc.).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 21
(5,703 Views)

Just set the baud rate and start commuication. In my opinion, first checking the existing baud rate, changing it, and then checking it again is just a waste of time. If your viSetAttribute() fails to set the baud rate, you will get an error.

Message 6 of 21
(5,699 Views)

the only reason I was getting and setting and then reading back the attribute was to prototype and experiment with how the VISA API worked in conjunction with MAX.

 

0 Kudos
Message 7 of 21
(5,697 Views)

Just to clarify.  If I open a session inside my program and configure the serial ports in a certain way.  Then as long as I have that session open, the serial port parameters will be what I have set them to.

 

OK  Now if I go to MAX and look at the serial port parameters there (while my program is running and the session is open), should MAX reflect the changes to the serial port attributes that I made in the program???

0 Kudos
Message 8 of 21
(5,661 Views)

I don't have a computer to try this right now, but my gut feel is that MAX will show the default settings, not what the current settings are.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 21
(5,654 Views)

I am facing an error in the VISA Test panel as "IS PORT CONNECTED". I'm able to select the port as VCOM from the device manager at the same time from the NI MAX Devices and Interfaces. I have attached the screenshot of the error. Can anyone discuss on debugging this. 

0 Kudos
Message 10 of 21
(5,078 Views)