visa to visadev, how can I pass a header to the "writebinblock" function

조회 수: 5 (최근 30일)
Viktor Ott
Viktor Ott 2023년 1월 16일
편집: John Vandermeer 2023년 5월 3일
How can I pass a header to the "writebinblock" function?
This is the header:
header = ':TRACe1:DATA 1,0,'
old function ("inst" created with the old function "visa"):
binblockwrite(inst, data, 'int16', header)
new function ("inst" created with the new function "visadev"):
writebinblock(inst, data ,"int16")
Is there a manuel way like this? (not working)
header = int16(double(':TRACe1:DATA 1,0,'))
writebinblock(inst, [header data],"int16")

답변 (1개)

HimeshNayak
HimeshNayak 2023년 3월 14일
Hi Viktor
As per my understanding you want to switch from “visa” to “visadev” and pass header with data into “writebinblock” function.
“writebinblock” does not support header now. You may use “write” function for the same.
To convert the following:
binblockwrite(inst, data, uint8, header)
You may write:
header = uint8(headerStr);
rawData = [header, data];
write(inst, rawdata, precision);
For more information on “write” function, you may visit: https://in.mathworks.com/help/instrument/serialport.write.html
Regards
HimeshNayak
  댓글 수: 1
John Vandermeer
John Vandermeer 2023년 5월 3일
편집: John Vandermeer 2023년 5월 3일
What is left out of this conversion is that the binblockwrite() function would automatically pre-pend the IEEE 488.2–1992 section 7.7.6 block data header to the data so that the user did not need to include this in the "header" portion. As far as I can tell, the visadev write() function does NOT do this, so the block data header must be manually added to the desired ASCII header for the SCPI command to the instrument.
From looking at NI I/O Trace of both write and binblockwrite, it does appear that binblockwrite pre-pends the IEEE 488.2–1992 section 7.7.6 block data header to the data buffer that is given, so if you give it a buffer consisting of the SCPI command and data, you end up with the block data header before your SCPI command. So, using write() and manually embedding the block data header is going to be the only solution.
The visadev write function is documented at https://www.mathworks.com/help/instrument/visadev.write.html.
It feels like some of the examples showing how to use the old visa interface need to be ported to the new one to show how to use it properly.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by