visa to visadev, how can I pass a header to the "writebinblock" function
2 次查看(过去 30 天)
显示 更早的评论
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")
0 个评论
回答(1 个)
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
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!