// // tds3 -- Capture Tektronix TDS300 screen images. // // - Set 'scope to print PNG format (RS232 or GPIB). // // The loop consists of: // - monitor serial port for incoming raw data (using comraw1.exe) // - convert/resize bitmap (using IrfanView) // - save PNG and 640x480, 480x360, or 320x240 GIF version // - display image on PC // // 20-Dec-2001 Tom Van Baak (tvb) www.LeapSecond.com/tools // #include #include #include #include void command (char *arg, ...); int sequence_next (void); void main (int argc, char *argv[]) { int port, seq, baud, size; if (argc < 2) { fprintf(stderr, "Usage: %s [COMport] [baud]\n", argv[0]); exit(1); } port = (argc > 1) ? atoi(argv[1]) : 1; baud = (argc > 2) ? atoi(argv[2]) : 19200; size = (argc > 3) ? atoi(argv[3]) : 480; while (1) { char raw_name[100], gif_name[100]; // create unique name for bitmap and capture image. printf("\n"); seq = sequence_next(); #define EXT "png" sprintf(raw_name, "tds%d.%s", seq, EXT); command("comraw1 %d %d %s", port, baud, raw_name); // Create 640x480 GIF (v for VGA). if (size == 640) { sprintf(gif_name, "tds%d%s.gif", seq, "v"); command("i_view32 %s /resample=(640,480) /convert=%s", raw_name, gif_name); _sleep(2000); _mkdir("640"); command("move %s %s", gif_name, "640"); } // Create 320x240 GIF (q for QVGA). if (size == 320) { sprintf(gif_name, "tds%d%s.gif", seq, "q"); command("i_view32 %s /resample=(320,240) /convert=%s", raw_name, gif_name); _sleep(2000); _mkdir("320"); command("move %s %s", gif_name, "320"); } // Create 480x360 GIF (h for half size). if (size == 480) { sprintf(gif_name, "tds%d%s.gif", seq, "h"); command("i_view32 %s /resample=(480,360) /convert=%s", raw_name, gif_name); _sleep(2000); _mkdir("480"); command("move %s %s", gif_name, "480"); } // Display original bitmap and then archive it. if (size != 0) { command("i_view32 %s /one", raw_name); _mkdir(EXT); command("move %s %s", raw_name, EXT); } } } void command (char *arg, ...) { char buf[1000]; va_list vap; va_start(vap, arg); vsprintf(buf, arg, vap); va_end(vap); printf("*** %s\n", buf); system(buf); } #define TMP_SEQ "seq.txt" int sequence_next (void) { FILE *f; char *path = TMP_SEQ; long sequence; if (NULL == (f = fopen(path, "r"))) { sequence = 1; } else { fscanf(f, "%ld", &sequence); fclose(f); } f = fopen(path, "w"); fprintf(f, "%ld\n", sequence + 1); fclose(f); return sequence; }