Tek TDS Hardcopy GPIB C - Page 1
Forum section: electronics / testgear

author: EVlab
author_rank: Contributor
timestamp: August 06, 2014, 01:11:40 pm
content: Hi all!I’m trying to transfer a hardcopy (bitmap-image) from my TDS644B to my PC running Debian Linux.Scope and PC are connected via an Agilent 82357B. Programming is done using plain C (libgpib).I’m able to communicate with the scope and take readings and transferring data. So far, so good.For the hardcopy action, the scope is switch to “talk-only” mode and there is a libgpib-function called “ibrdf” that should write the received data to a file directly.And here my problem starts.Ibrdf writes a file, but there is only partial data of the hardcopy in it.I assume, that there is some kind of a synchronization problem.Thus I started to monitor the GPIB bus status lines to wait for some kind of action if the TDS wants to send data and then call ibrdf.But I had no success.Can anyone help out (or give me a hint)?There are some programming examples on the web, but they all use “fancy new languages” like Phyton, etc.Furthermore they use high level stuff like VISA.I would like to stick with plain C.Best;

author: Andy Watson
author_rank: Super Contributor
timestamp: August 06, 2014, 01:30:39 pm
content: How big is the resulting data file? Is it 64k, or a multiple thereof?

author: EVlab
author_rank: Contributor
timestamp: August 07, 2014, 10:01:48 am
content: I have no idea.I would expect with 8bit-color-depth: 640x480=370200byte + 14byte header + 40 byte info-block for am BMP file.

author: MarkL
author_rank: Unknown
timestamp: August 07, 2014, 02:48:55 pm
content: Try increasing the timeout to a large value, like 30 seconds.I had some problems using the perl library and I was getting half a printout from an HP spectrum analyzer. This was several years ago but if I recall, there was some issue that the transaction had exceeded the timeout, but it was not reported as an error because *some* data was received.

author: Lukas
author_rank: Frequent Contributor
timestamp: August 07, 2014, 08:19:06 pm
content: Quote from: EVlab on August 06, 2014, 01:11:40 pmC and VISA aren't exclusive. Just find the visa.h (propably included in your adapter's driver package) and link your application to the visa dll.

author: EVlab
author_rank: Contributor
timestamp: August 08, 2014, 08:07:27 am
content: I will try the hint from MarkL, as I can imagine that there is some strange behavior regarding a timeout.To my understanding, there is no time-out condition, as long as there is data being send by the GPIB-talker.Anyhow, the libgpib-function generates a timeout.@Lukas: Do you have experience in using VISA? What are the benefits doing so? My intention was to keep the code as simple as possible and not to include additional libraries.

author: Lukas
author_rank: Frequent Contributor
timestamp: August 08, 2014, 08:42:35 pm
content: Quote from: EVlab on August 08, 2014, 08:07:27 amOh, I've noticed you're using linux, this makes things a bit more complicated, since VISA practically is windows-only.

author: davorin
author_rank: Unknown
timestamp: August 08, 2014, 08:57:10 pm
content: Have you tried the communication with a simple terminal software like "ibterm" ?It will just dump the content as hex values on the console...but you know it's working...Haven't done anything in C, just Python...the screendumps from my two LeCroy DSOs work like a charme for HPGL, BMP and TIFF...You might want to post your C code here...

author: EVlab
author_rank: Contributor
timestamp: August 09, 2014, 12:38:01 pm
content: The solution was very simple: You have to make sure, that >timeout< in "/etc/gpib.conf" is set to a value or range in which the data transfer can surely be completed. I used >timeout=T30s< which works fine, as "MarkL" already suggested ;-)>libgpib< will generate a timeout regardless if there is data being transferred successfully ...Anyhow, I also took a look at the SVN repository that "davorin" mentioned. I would recommend any one who tries to get into GPIB programming using C to do so. The tool "ibterm" is very helpful for developing own software. Furthermore, there are some examples, where you can learn a lot by just looking at the code!For the GPIB communication itself you have to distinguish if the scope runs in >talk/listen< or in >talk-only< mode. For my purpose, grep screen images as they are displayed, >talk-only< is what you need. A very simple code stores the data to a file:status = ibrdf( board, file_path );if( status & ERR ){fprintf( stderr, "ibrdf() failed\n" );fprintf( stderr, "%s\n", gpib_error_string( ThreadIberr() ) );return -1;}Thus I can also (like "davorin") state: "the screendumps from my TDS work like a charme for HPGL, BMP and TIFF..."Have a nice weekend!

author: EVlab
author_rank: Contributor
timestamp: August 09, 2014, 05:20:15 pm
content: I studied the SVN examples a bit further and found some interesting code in the examples regarding the timeout.It's worth than mentioned above: You have to disable the GPIB-timeout completely by setting >timeout< to "TNONE".I used this afternoon to modify the example code and to write a small program, that waits for hardcopy data and writes to files that will be numbered ascending.Please find attached the code and the resulting screen dump!

author: davorin
author_rank: Unknown
timestamp: August 09, 2014, 05:33:34 pm
content: Looks nice :-))My 9354AL and 9414 don't feature nice colors...only different pen codes for channels in HPGL mode..that's all (o;I see that you never write anything to the device....as I always write first to send the HCSU and then trigger it remotely via SCDP...But good to have also some nice example written in C....as I'm working now on the OSX driver side for S82357/F82357 adapters...

author: EVlab
author_rank: Contributor
timestamp: March 25, 2015, 05:15:17 am
content: Dear all.I have enhanced my little program with screen dump capability of my Tek 11801.This variant does not wait for a "SCREEN COPY" button to be pressed on the scope.Instead it will setup and grab the screen contents remotely via GPIB when you call the binary.Best regards, Simon

author: bang007
author_rank: Newbie
timestamp: June 24, 2015, 10:57:36 am
content: Hi guys,I try to write a script in python to save the screenshoot in a png file but I get some errors. If any body can have a look on this. I am new in Python.Many thanks for your help.Code:import visarm=visa.ResourceManager('@py')scope = rm.open_resource('GPIB::6::0')scope.write('HARDCOPY:FILENAME "test.png"')scope.write('HARDCOPY:FORMAT PNG')scope.write('HARDCOPY:LAYOUT LANDSCAPE')scope.write('HARDCOPY:PORT GPIB')scope.write('HARDCOPY START')raw_data=scope.read()fid=open('/home/pi/test.png','wb')fid.write(raw_data)fid.close()And I got this errorQuote

author: davorin
author_rank: Unknown
timestamp: June 24, 2015, 08:21:11 pm
content: No need to post in two separate threads (o;Think I already posted my screen dump code somewhere here....but here it is again:Code:#!/usr/bin/pythonimport sysfrom subprocess import Popen, PIPEimport errnoimport shlexhpgl = ""hp2xx = "/usr/bin/hp2xx -m png -c 12445611 -d 150 -D 90 -q -f "cat = "/bin/cat"from Gpib import *file_name = sys.argvhp2xx += file_namehp2xx += ".png"p = Popen(shlex.split(hp2xx), shell=False, stdin=PIPE)bytes = 200inst = Gpib(0,1)inst.write("HCSU DEV,HP7550A")inst.write("SCDP")p.stdin.write(inst.read(bytes))count = 0while inst.ibcnt() == bytes:print 'Bytes read: ',countp.stdin.write(inst.read(bytes))count += bytesprint '\nFinished dumping... 'print hp2xxp.stdin.close()p.wait()Most difficult was to find out how to launch the external hp2xx program in a shell and write the screen dump to stdout...but you won't need this as you dump a bitmap image...

author: icezebra
author_rank: Contributor
timestamp: June 19, 2022, 05:33:04 pm
content: Not all heros wear capes...https://www.eevblog.com/forum/testgear/tds460-hardcopy/msg3571877/#msg3571877http://mkelzenb.caltech.edu/software/TDSHC/index.htmlThanks Mike, you rock.