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.

need help to get hardcopy using tekvisanet

Programming examples for remote communication with instruments
C/C++, C#, Python, Matlab, LabVIEW
Post Reply
maxyuri123
Posts: 3
Joined: August 28th, 2017, 7:50 pm
Country: Brazil

need help to get hardcopy using tekvisanet

Post by maxyuri123 » August 28th, 2017, 8:16 pm

Hello there,

I'm trying to get a a print screen of my osciloscope Tektronix TBS 1052B, using tekvisanet.dll in c# project, but with no success.
I read the instrument manual and I get some parameters to write on instrument.
However, when I read the output string it seems that the image is not complete. I've enclosed a sample of what I got as result.
I would appreciate it if someone could help me with this.

This is the code I'm running:

Code: Select all

public static Image GetPrintScreen()
{
	//using TekVisaNet.dll
	VISA tekVISA = new VISA();

	//my instrument name
	string myInstrument = "USB::0x0699::0x0368::C025090::INSTR";

	//open connection with instrument
	tekVISA.Open(myInstrument);

	//send commands to get print screen
	tekVISA.Write("HARDCOPY:FORMAT BMP");        
	tekVISA.Write("HARDCOPY:LAYOUT PORTrait");
	tekVISA.Write("HARDCOPY:PORT USB");
	tekVISA.Write("Hardcopy Start");

	//read the bmp string
	var image_string = "";
	tekVISA.Read(out image_string);

	//convert string to byte array
	byte[] byteArrayIn = Encoding.ASCII.GetBytes(image_string);
	
	//convert byte array to Bitmap
	using (var ms = new MemoryStream(byteArrayIn))
	{
		return Bitmap.FromStream(ms, false);
	}        
}
Thanks in advance.
Attachments
print.PNG
print.PNG (21.6 KiB) Viewed 15064 times

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

Re: need help to get hardcopy using tekvisanet

Post by Carl M » September 7th, 2017, 1:02 pm

my guess is the data from the oscilloscope fine and the code is changing it (e.g. string to bytes, should just be bytes) but i'm not familiar enough with the tekvisanet library to know how to correct it.

We have a hardcopy C# example using the NI-VISA .net control: viewtopic.php?f=580&t=139957
Tektronix Application Engineer

maxyuri123
Posts: 3
Joined: August 28th, 2017, 7:50 pm
Country: Brazil

Re: need help to get hardcopy using tekvisanet

Post by maxyuri123 » September 10th, 2017, 8:57 pm

Hi,

thank you for your reply!

I tryed to reproduce the example code, but the ReadByteArray() function doesn't exist in tekvisaNET.
Just exists a Readbinary() function, but its don't return any values... only Read() return values, but are string...

I already have tested a python example too, creating a C# code using equivalents code logic and functions, but not worked. The image was generate equal my failed example...

I'm lost :/

maxyuri123
Posts: 3
Joined: August 28th, 2017, 7:50 pm
Country: Brazil

Re: need help to get hardcopy using tekvisanet

Post by maxyuri123 » September 11th, 2017, 9:02 pm

HI

If I use NI-VISA, WORKS! :lol: :lol: :lol: :lol: :lol:
but if I use Tekvisa, don't works! :?:

venu13
Posts: 4
Joined: September 17th, 2020, 6:28 am
Country: India

Re: need help to get hardcopy using tekvisanet

Post by venu13 » September 18th, 2020, 2:19 am

Hi, did you solve it using NI VISA dll. Can you let me know the link to download it please?

Post Reply

Return to “Remote Instrument Communication (Programming) Examples”

Who is online

Users browsing this forum: No registered users and 6 guests