Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Using C# and VISA to open a Serial Resource

This is my source code:

           But when these code running, I found wasting long time for open a serial resource,wha's problems?

 

            SerialSession serialResource = null;
            try
            {
                serialResource = (SerialSession)ResourceManager.GetLocalManager().Open(devResource);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }

            serialResource.BaudRate = 38400;
            serialResource.DataBits = 8;
            serialResource.StopBits = StopBitType.One;

            serialResource.Parity = Parity.None;

            serialResource.FlowControl = FlowControlTypes.None;

            return serialResource;
 

0 Kudos
Message 1 of 4
(4,684 Views)
How long will you wait? And after this period, is all following OK?


NI Application Engineer
0 Kudos
Message 2 of 4
(4,661 Views)

Hi,

I will wait for about one minute, and following operation to the serialPort is OK, such as Read/Write!

The VISA version that i installed  is 3.5, the setup file is visa350full.exe.

 

Thanks you!

0 Kudos
Message 3 of 4
(4,633 Views)

Hello,

 

I'm not familiar with VISA programming in C#. But maybe you can refer to this example and see if you still have the problem when using this example code.

Thanks.

 

http://zone.ni.com/devzone/cda/epd/p/id/4859

 

NI Application Engineer

0 Kudos
Message 4 of 4
(4,613 Views)