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