Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Has anyone had success accessing VXI peek and Poke functions with .Net ?

We have used the low-level VXI peek and poke functions from the NI-VXI libraries v.2.11 for 10 years. These
functions provide the fastest acquistion of data over the VME/MXI-2 Interface. We have since moved to .Net and are using VISA.
How do we get access to the peek and poke functions ? And if there are not available, why not ?
 
 
0 Kudos
Message 1 of 8
(4,883 Views)
Hello. 
 
Thank you for posting to the NI Discussion Forums. 
 
Unfortunatly, there is no native .NET support for those low level functions such as poke and peek.  Instead, I would recommend using viMoveIn, viMoveOut, and viMapAddress.  For more information on these functions, please consult the NI-VXI Help document. 
 
Let me know if you have any further questions!
 
Brian F
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(4,865 Views)
Hi dBolles,

As Brian mentioned, we didn't expose viPeek and viPoke in the .NET API when we created it. Our initial thoughts were that customers would use the RegisterBasedSession.InXX and RegisterBasicedSession.OutXX methods instead of the viPeek and viPoke methods. 

In C a good use case is that the low-level viMapAddress functionality gives you back a pointer that you can just directly dereference. Of course you can't do this in .NET because the .NET Framework doesn't allow direct memory referencing. 

Now with all that said, I am working on a small code snippet that will demonstrate how to use P/Invoke to load the VISA32.dll and call those methods from .NET.  When I get a basic example, I will post it.

Additionally, we are going to look into adding viPeek and viPoke support into the VISA .NET API in a future version.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 3 of 8
(4,850 Views)

John and Brian,

Thankyou for your response.

Currently, we have a number of software/hardware applications that require us to get data as fast as possible over a VME/MXI-2 Interface. On a 1 GHz Pentium  we are able to get a 300 KHz transfer rate (reading 32-bit data) using VXI peek and poke with the old NI-VXI v.2.11 drivers.

We are now using VISA and .Net using the higher level routines, and the best transfer rate is about 20 to 30 KHz, which is way too slow.

We need a higher transfer rate (> 200 KHz or better). 

Thanks for looking into this. 

Dave B.

 

 

0 Kudos
Message 4 of 8
(4,842 Views)
Hi dBolles,

What language are you using (C# or VB.NET)? I didn't want to give you an example in a language you were not familiar with.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 5 of 8
(4,838 Views)
Hi dBolles,

One of my co-workers corrected me on a previous statement of mine that was "Of course you can't do this in .NET because the .NET Framework doesn't allow direct memory referencing".  The .NET CLR does allow this and C# supports it (VB.NET does not). This is discussed in the Unsafe Code and Pointers Microsoft document.

Sorry for the confusion.

Just let me know on the language you are programming and and I can create an example.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 6 of 8
(4,827 Views)
Jonathan,
 
We actually have one on VB.net and the other in C#.
 
The C# application has the highest priority, but we could defintely use examples for both.
 
dBolles
0 Kudos
Message 7 of 8
(4,810 Views)
Hi dBolles,

Attached is an example of calling the viPeek16 function from VB.NET and from C#. I uses around 5 or 6 of the VISA functions such as viOpenDefaultRM, viOpen, viMemAlloc, etc.

I tried to follow one of the examples located in the C:\Documents and Settings\All Users\Documents\National Instruments\NI-VISA\Examples\C\Vxi-vme (of course you may just have these examples in the C:\VXIpnp\WinNT\NIvisa depending upon what versions of Visa you have installed; We changed the example locations recently).

The entire code runs but of course you would need to modify the code to fit your application needs. I didn't do any error checking and you probably want to clean it up, but here is the framework you need. 

Have fun!

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 8 of 8
(4,800 Views)