#!/usr/bin/perl # # only handles 4-bit transfers right now... $bpp=4; $invert=16; open(FILE, "minicom.cap") || die "Unable to open capture file: $!"; binmode FILE; open(OUT, ">qcam.ppm") || die "Unable to open output file: $!"; binmode OUT; print OUT "P5\n320 240\n15\n"; # 320x240 scan @ 16 bits do { $c = getc(FILE); $c = ord($c)-1; # we incremented by one when we sent it, so undo that. $c=255 if ($c==-1); $b1 = ($c & 0xf0)>>4; $b2 = $c & 0xf; print "Alert: corrupt data.\n" if ($b1>16); $b1=16 if ($invert==16 && $b1==0); print OUT chr($invert-$b1); print "Alert: corrupt data.\n" if ($b2>16); $b2=16 if ($invert==16 && $b2==0); print OUT chr($invert-$b2); } while (!eof(FILE)); close FILE; close OUT;