![]() | WriteBinaryBlock |
Sends an IEEE 488.2 definite-length binary block to a device.
virtual HRESULT WriteBinaryBlock(double* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(float* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(long* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(short* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(BYTE* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(SAFEARRAY* pValues, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(const CString& strCommand, double* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(const CString& strCommand, float* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(const CString& strCommand, long* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(const CString& strCommand, short* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(const CString& strCommand, BYTE* pValues, long lLength, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteBinaryBlock(const CString& strCommand, SAFEARRAY* pValues, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
[in] Command to send to the device before sending the binary block.
[in] Array of numeric values to compose into a definite-length block and send to the device.
[in] Number of elements (not bytes) to send to the device. If the input is a SAFEARRAY, then all elements of the SAFEARRAY are sent.
[in] If true, the formatted I/O write buffer is flushed to the device.
[in] I/O timeout value in milliseconds.
Returns S_OK if successful, otherwise a failure HRESULT.
The WriteBinaryBlock function formats the contents of the pValues input array as an IEEE 488.2 definite-length binary blockand sends it to the formatted I/O write buffer.
If the bFlush parameter is true, then the contents of the I/O write buffer are flushed to the device. If bFlush is false, then the data is queued in the write buffer until the buffer is full or a subsequent operation forces a flush. Queueing data in this fashion can improve I/O performance by reducing the number of I/O roundtrips to the device.
The following example demonstrates use of the WriteBinaryBlock function.
// CoAcme4321.cpp STDMETHODIMP Acme4321::IAcme4321_Configure(SAFEARRAY* psaData) { HRESULT hr = S_OK; // Sends contents of psaData as an IEEE 488.2 definite-length binary block hr = io.WriteBinaryBlock(psaData); return hr; }