| Using VISA.NET > Raw I/O > Writing |
The Raw I/O write operation writes data directly to an instrument either in an array of bytes or in a string.
The Raw I/O Write methods write data until all of the data supplied to the method has been written to an instrument.
The Raw I/O Write methods do not implicitly send an END or termination character to an instrument. You must explicitly include a termination character in the array of bytes or the string to be sent to the instrument.
Only one synchronous write operation can occur at a time. However, multiple asynchronous write methods may be queued for execution, and will execute in the order in which the calls were made.
Because instruments normally interpret strings as 8-bit ASCII characters and .NET strings are all 16-bit UNICODE characters, VISA.NET provides Write method overloads to with string data arguments, which Write then converts to 8-bit ASCII characters for the instrument.
When string conversion is not required, VISA.NET provides overloads of Write methods that accept byte array data arguments. Write sends byte data directly to an instrument.
To avoid needless in-memory copies of data, VISA.NET provides an overload of Write that accepts a pointer to a byte array. This enables Write to avoid a performance penalty for copying the byte array on the boundary between managed and unmanaged code. Since .NET cannot bounds-check an array passed as a pointer, these write methods are unsafe.