multiple fixes -- now prints successfully to a PT-2450DX.

Wed, 05 Aug 2009 15:15:47 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 05 Aug 2009 15:15:47 +0100
changeset 15
e5577dd259c6
parent 14
088286f9e1e4
child 16
57eff547e4f1

multiple fixes -- now prints successfully to a PT-2450DX.
FIX: job options were being set in GetStatus, now moved to their rightful home in Initialise()
REFACTOR: small mods to structure of Initialise, now uses PT_ERR_* consts, calls pt_Close on failure, exit logic slightly changed.
FIX: debug options should NOT have been set in Hg source (especially SKIP_STATUS_READBACK), now fixed.

src/ptouch.c file | annotate | diff | revisions
     1.1 diff -r 088286f9e1e4 -r e5577dd259c6 src/ptouch.c
     1.2 --- a/src/ptouch.c	Wed Aug 05 15:04:55 2009 +0100
     1.3 +++ b/src/ptouch.c	Wed Aug 05 15:15:47 2009 +0100
     1.4 @@ -9,11 +9,11 @@
     1.5   ****************************************************************************/
     1.6  
     1.7  // TODO: disable
     1.8 -#define DEBUG
     1.9 +//#define DEBUG
    1.10  
    1.11  // This debug option forces Request Status to always "see" a good status
    1.12  // block. Mostly useful for testing using write-to-file mode.
    1.13 -#define DEBUG_SKIP_STATUS_READ
    1.14 +//#define DEBUG_SKIP_STATUS_READ
    1.15  
    1.16  #include <stdio.h>
    1.17  #include <stdlib.h>
    1.18 @@ -50,12 +50,19 @@
    1.19  	dev->fp = prn;
    1.20  
    1.21  	// Memory allocation OK, now get the printer's status
    1.22 -	if (pt_GetStatus(dev) == 0) {
    1.23 -		return dev;
    1.24 -	} else {
    1.25 -		free(dev);
    1.26 +	if (pt_GetStatus(dev) != PT_ERR_SUCCESS) {
    1.27 +		// GetStatus failed, close the device and exit.
    1.28 +		pt_Close(dev);
    1.29  		return NULL;
    1.30  	}
    1.31 +
    1.32 +	// Set printing parameters to defaults --
    1.33 +	//   Mirror off
    1.34 +	//   Autocut off
    1.35 +	dev->mirror = false;
    1.36 +	dev->autocut = false;
    1.37 +
    1.38 +	return dev;
    1.39  }
    1.40  
    1.41  int pt_GetStatus(pt_Device *dev)
    1.42 @@ -121,12 +128,6 @@
    1.43  		dev->pixelWidth = ((dev->mediaWidth * 180 * 10) / 254) - 2;
    1.44  	}
    1.45  
    1.46 -	// Set printing parameters to defaults --
    1.47 -	//   Mirror off
    1.48 -	//   Autocut on
    1.49 -	dev->mirror = false;
    1.50 -	dev->autocut = false;
    1.51 -
    1.52  	// Operation succeeded
    1.53  	return PT_ERR_SUCCESS;
    1.54  }