Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

Incomplete Hardcopy Retrieved from TBS 1052B-EDU

Programming examples for remote communication with instruments
C/C++, C#, Python, Matlab, LabVIEW
Post Reply
ChrisTheBaron
Posts: 2
Joined: February 22nd, 2018, 5:53 am
Country: United Kingdom

Incomplete Hardcopy Retrieved from TBS 1052B-EDU

Post by ChrisTheBaron » February 22nd, 2018, 6:04 am

Using C# and code adapted from viewtopic.php?f=580&t=139957, the response I'm getting back is an incomplete screenshot (See tmp.bmp). I have included

Code: Select all

C:\Windows\assembly\GAC_32\TekVISANet\1.1.1.0__7f19bb2a5a9ae6e8\TekVISANet.dll
in my Visual Studio project.

Code: Select all

// connection code omitted.

TVA.Timeout = 50000;

TVA.Write("HARDCopy:FORMat BMP");
TVA.Write("HARDCopy:LAYout PORTRAIT");
TVA.Write("HARDCopy:INKSaver ON");
TVA.Write("HARDCopy:port USB");
TVA.Write("HARDCopy START");

TVA.Read(out string temp);

using (FileStream fs = new FileStream(@"C:\tmp\tmp.bmp", FileMode.CreateNew))
using (BinaryWriter sw = new BinaryWriter(fs))
{
	sw.Write(Encoding.ASCII.GetBytes(temp));
}
Attachments
tmp.bmp
Example hardcopy.
tmp.bmp (1.1 MiB) Viewed 9136 times

Carl M
Tektronix Applications
Tektronix Applications
Posts: 801
Joined: July 30th, 2008, 4:45 pm
Country: United States

Re: Incomplete Hardcopy Retrieved from TBS 1052B-EDU

Post by Carl M » February 26th, 2018, 3:20 pm

the bytes of the file that comprise the screen capture in BMP format are likely getting terminated early because of a linefeed character. This typically happens when you perform ASCII operations on binary data. You could confirm this with a VISA trace. IIRC, your TVA object has a ReadToFile() method that would be better suited for this task. The example you reference is using the NI VISA library, not the TekVISA ActiveX control. The commands the the instrument are otherwise correct.
Tektronix Application Engineer

ChrisTheBaron
Posts: 2
Joined: February 22nd, 2018, 5:53 am
Country: United Kingdom

Re: Incomplete Hardcopy Retrieved from TBS 1052B-EDU

Post by ChrisTheBaron » March 8th, 2018, 6:04 am

Thank you for replying so promtly.

I have looked, and I cannot find a ReadToFile() method on the TVA object. I have tried ReadBinary() but I get 0 bytes returned. I have also tried a few other string encoders (Unicode, UTF7, UTF8, UTF32, BigEndianUnicode) but none seem to work. Setting the format to JPEG creates an entirely invalid file. For reference I have attached the output if I set the layout to landscape.

I cannot install the NI Visa library as I am developing on a university machine and I do not have admin rights.
Attachments
tmp.bmp
Landscape
tmp.bmp (747.71 KiB) Viewed 8923 times

Post Reply

Return to “Remote Instrument Communication (Programming) Examples”

Who is online

Users browsing this forum: No registered users and 2 guests