From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Deploy VISA serial application - baud rate setting

I am developing a simple program to capture data (read) from serial port every second and save it to an xml file and graph...  I am using COM1 to perform the task on my development system.  I use the meas studio (7.1) task (and set the com port to 4800 baud).  I am then reading from the port, parsing the data (visually), then assigning to the graph and a dataset (for xml output).  This works fine on my development system (my laptop).  I loaded the same version of NI VISA on the instrument computer.  I set the port properties in Windows (XP) to 4800 baud, rebooted, then opened up NI VISA test panels.  When I get the Baud property, it's d9600.  If I try and read from the COM1, it is garbled.  Then, if I manually set to d4800, I can read the data fine (and with Hyperterminal).  When I install my app, it gives me a framing error for the parsing operation.  This happens every time - even if I open up NI VISA and set it to d4800 before running my app.  Is there any way I can force the value to be set at 4800 (I did some similar apps in MS 7.0 by using the NationalInstruments.VisaNS.SerialSession namespace which allowed defining the port settings - I had to parse the data "manually" though).  I must be missing something?  Any help would be appreciated.
 
Tom
 
0 Kudos
Message 1 of 3
(3,029 Views)
Tom,

the standard baud setting on a given PC is set in the system_control_center>device_manager>Ports>properties, AFAIR. My system is German, so my translations may be a bit off 😉
So either you set the baud rate explicitely within your code (preferred solution as it works on every system) or you set the proper defaults in the above mentioned properties. The latter is somehow dangerous, as when _you_ can set this, everyone else can do it as well and stop your program this way.
Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 2 of 3
(3,018 Views)
Lul,

Thanks for the rapid response...  I believe I have done what you suggested - In US Eng versions of WinXP, the Device Manager allows you to set the port properties (which I did at 4800 baud).  If  I open my *.vb file created from the Meas Studio VISATask (*.mxb file), I can see where the read operation calls the "ASLR1::INSTR" resource (i.e. COM1), but I don't see any settings (i.e. baud, stop bits, etc) where I can add to the code.  In the mxb environment, I set the port properties to COM1, 4800 baud, etc.  I assumed this should translate into how the device is used when the class is automatically coded in MStudio and instantiated at runtime?  Somehow, the *.vb file created using Meas Studio doesn't put the port settings in explicitly (at least that I can find).  Is there a way to modify this vb file, or do I need to have to use the VisaNS.SerialSession namespace and parse the file in code????

Thanks again for responding.  Perhaps this is a bug in MStudio - This is the first time I've tried building the VISATask graphically (just upgraded to 7.1 pro from standard - one month before 8.0 came out!!!!).

Tom
0 Kudos
Message 3 of 3
(3,015 Views)