Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write and read a specified number of bytes using C++?

I need to send one byte commands followed by 1 or 2 byte data as well as read 1 or 2 byte commands from a RS232 device. How do I ensure that only 1 byte is sent for the commands or 2 bytes of data using VISA?
0 Kudos
Message 1 of 2
(3,393 Views)
Hey BMas05,

Using VISA in C++ you can strings or bytes depending on which polymorphic version of the write you are using. One of the parameters for the VISA Write is the byte array and the number of bytes. This is if you are using the VISA classes for C++. You might have to have Measurement Studio to get these classes.

There is a really good example that installs on your computer at C:\Program Files\National Instruments\MeasurementStudio\VC\Examples\Io\Visa\Serial Visa.

This example shows how you can write just bytes or strings and you can select how many bytes to read back.

I hope this helps out.

JoshuaP
National Instruments
0 Kudos
Message 2 of 2
(3,393 Views)