CAPS Universe documentation  1.0.4
All you need to know to be successful
Functions | Variables
ql-series.c File Reference

Shared functions by all QL label printer drivers. More...

Functions

int ql_numerical_setting_read (struct ql_drv *t, const char *section, const char *keyword)
 
static double ql_float_setting_read (struct caps_drv *drvi, const char *section, const char *keyword, double fallback)
 
static void ql_driver_byte_count_from_INI (struct ql_drv *t)
 
static void ql_driver_dot_count_from_INI (struct ql_drv *t)
 
static void ql_driver_cutter_from_INI (struct ql_drv *t)
 
static void ql_driver_colour_from_INI (struct ql_drv *t)
 
static void ql_driver_margin_from_INI (struct ql_drv *t)
 
static void ql_driver_high_resolution_from_INI (struct ql_drv *t)
 
static void ql_driver_min_max_label_size_from_INI (struct ql_drv *t)
 
static void ql_driver_leading_bytes_from_INI (struct ql_drv *t)
 
void ql_driver_base_setup (struct ql_drv *t)
 
static void ql_driver_feature_add (struct caps_ppd_base *base, const struct caps_ppd_selection *entry)
 
void ql_driver_power_selection_setup (struct ql_drv *t, struct caps_ppd_base *base)
 
void ql_driver_halftone_selection_setup (struct ql_drv *t, struct caps_ppd_base *base)
 
enum ql_half_tone ql_driver_job_halftone_get (struct ql_drv *t)
 
void ql_driver_bi_colour_medium_selection_setup (struct ql_drv *t, struct caps_ppd_base *base)
 
void ql_driver_job_bi_colour_medium_get (struct ql_drv *t)
 
static const struct dk_roll_typesql_dk_element_get (const char *name)
 
int ql_dk_information_get (struct dk_roll_types *medium, const char *name)
 
void ql_driver_raster_crop (struct ql_drv *t)
 
int ql_driver_send (struct ql_drv *t, size_t count, const void *data, int flush)
 
int ql_driver_data_send (struct ql_drv *t, size_t count, const void *data, int flush)
 

Variables

static const struct caps_ppd_selectionql_drv_spare_features_list [10]
 
static const struct caps_ppd_selection_entry ql_drv_feature_power_off_selections []
 
static const struct caps_ppd_selection ql_drv_feature_power_off_selection
 
static const struct caps_ppd_selection_entry ql_drv_feature_power_on_selections []
 
static const struct caps_ppd_selection ql_drv_feature_power_on_selection
 
static const struct caps_ppd_selection_entry ql_drv_feature_halftone_selections []
 
static struct caps_ppd_selection ql_drv_feature_halftone_off_selection
 
static const struct caps_ppd_selection_entry ql_driver_feature_bi_colour_medium_selections []
 
static struct caps_ppd_selection ql_driver_feature_bi_colour_medium_selection
 
static const struct dk_roll_types rolls []
 

Detailed Description

This is a collection of functions and features shared by all QLxxxx drivers.

Function Documentation

◆ ql_numerical_setting_read()

int ql_numerical_setting_read ( struct ql_drv t,
const char *  section,
const char *  keyword 
)

Helper to read in a positive integer INI setting

Parameters
[in,out]tFull job description
[in]sectionName of the section, the setting should be read from
[in]keywordThe keyword/setting to read in
Return values
PositiveThe setting read from the INI
-ENODATANo setting found
-EINVALSetting found, but doesn't look like an ASCII number
-ERANGESetting contains an invalid number for an 'int'

◆ ql_float_setting_read()

static double ql_float_setting_read ( struct caps_drv drvi,
const char *  section,
const char *  keyword,
double  fallback 
)
static

Internal helper to read in a floating point numerical type INI setting

Parameters
[in]drviHandle to access the INI settings
[in]sectionName of the section, the setting should be read from
[in]keywordThe keyword/setting to read in
[in]fallbackValue to return, if not set in the INI
Returns
The setting read from the INI or the fallback if not defined

◆ ql_driver_byte_count_from_INI()

static void ql_driver_byte_count_from_INI ( struct ql_drv t)
static

Read in and set up the byte count per line from the INI settings

Parameters
[in]tFull job description
Note
Printer variant related value.

◆ ql_driver_dot_count_from_INI()

static void ql_driver_dot_count_from_INI ( struct ql_drv t)
static

Read in and set up the dot count per line from the INI settings

Parameters
[in]tFull job description
Note
Printer variant related value.

◆ ql_driver_cutter_from_INI()

static void ql_driver_cutter_from_INI ( struct ql_drv t)
static

Read in and set up the cutter capabilities from the INI settings

Parameters
[in]tFull job description
Note
Printer variant related value.

◆ ql_driver_colour_from_INI()

static void ql_driver_colour_from_INI ( struct ql_drv t)
static

Read in and set up the bi-colour capabilities from the INI settings

Parameters
[in]tFull job description
Note
Printer variant related value.

◆ ql_driver_margin_from_INI()

static void ql_driver_margin_from_INI ( struct ql_drv t)
static

Read in and set up the margin settings from the INI settings for all kind of labels

Parameters
[in]tFull job description

The printers have some margin requirements at all four edges of a label, we need to consider when printing. This routine sets up two margin assumptions, based on the following experiences:

Guessed Printer Mechanics for Labels with 62 mm in width
Guessed Printer Mechanics for Labels smaller than 62 mm

These experiences are used as the default. But the user can overwrite them.

Note
These margins might conflict with the margins mentioned in the corresponding printers datasheets. They mention larger values for the horizontal margins.

The horizontal margins depend on the width of the label:

  • right: smaller labels need about 1 mm, full size labels need about 0.8 mm
  • left: smaller labels do not need any margin, full size labels need about 0.2 mm

The vertical margins seem always constant and 3 mm both.

◆ ql_driver_high_resolution_from_INI()

static void ql_driver_high_resolution_from_INI ( struct ql_drv t)
static

Read in and set up the printer's high resolution capabilities from the INI settings

Parameters
[in]tFull job description

Some printers are capable of printing in 600 DPI in vertical direction.

◆ ql_driver_min_max_label_size_from_INI()

static void ql_driver_min_max_label_size_from_INI ( struct ql_drv t)
static

Read in and set up the minimum and maximum supported label sizes from the INI settings

Parameters
[in]tFull job description

Various printer variants are restricted in the size when printing on continuous length labels.

Note
The driver depends on external settings to use the correct values regarding the printer variant. The used default in this routine do not match all variants.
For example the maximum label width for the QL10xx series is 102 mm and not 62 mm.

◆ ql_driver_leading_bytes_from_INI()

static void ql_driver_leading_bytes_from_INI ( struct ql_drv t)
static

Read in and set up from the INI file the amount of leading zero bytes to begin a print job

Parameters
[in]tFull job description

Various printer variants define a different amount of zero bytes leading a printing job. QL500 defines 200 bytes, QL650 defines 350 bytes and a QL800 defines 400 bytes.

◆ ql_driver_base_setup()

void ql_driver_base_setup ( struct ql_drv t)

Read in the main INI file settings for the driver

Parameters
[in]tFull job description

◆ ql_driver_feature_add()

static void ql_driver_feature_add ( struct caps_ppd_base base,
const struct caps_ppd_selection entry 
)
static

◆ ql_driver_power_selection_setup()

void ql_driver_power_selection_setup ( struct ql_drv t,
struct caps_ppd_base base 
)

Add the power feature control selections to the printer description based on INI settings

Parameters
[in]tFull job description
[in,out]baseAdd selections to this printer description on demand

Uses the INI boolean key powerctl in section [features] to setup a possible power setting of the printer. In this case, selections defining these features will be added to the printer description PPD.

◆ ql_driver_halftone_selection_setup()

void ql_driver_halftone_selection_setup ( struct ql_drv t,
struct caps_ppd_base base 
)

Add the power feature control selections to the printer description based on INI settings

Parameters
[in]tFull job description
[in,out]baseAdd selections to this printer description on demand

◆ ql_driver_job_halftone_get()

enum ql_half_tone ql_driver_job_halftone_get ( struct ql_drv t)

FIXME

◆ ql_driver_bi_colour_medium_selection_setup()

void ql_driver_bi_colour_medium_selection_setup ( struct ql_drv t,
struct caps_ppd_base base 
)

Add bi-colour medium selection to the printer description based on INI settings

Parameters
[in]tFull job description
[in,out]baseAdd selections to this printer description on demand

The bi-colour capability of the loaded cassette cannot be detected. It must be selected by the user. This function adds a corresponding selection to the printer description, if the printer has bi-colour capabilities.

Precondition
Printer's colour capabilities must be already set (by calling ql_driver_colour_from_INI() first)

◆ ql_driver_job_bi_colour_medium_get()

void ql_driver_job_bi_colour_medium_get ( struct ql_drv t)

Get the current job related selection for the bi-colour medium capabilities

Parameters
[in]tFull job description

The bi-colour capability cannot be detected at runtime. So the user mus select it on a per job base to enable bi-colour print. This function checks the current selection and modifies ql_drv::bi_colour_medium_present accordingly.

◆ ql_dk_element_get()

static const struct dk_roll_types * ql_dk_element_get ( const char *  name)
static

Loop through the list of rolls for a specific one

Parameters
[in]nameThe name to search for
Return values
PointerThe corresponding roll element
NULLname not found

◆ ql_dk_information_get()

int ql_dk_information_get ( struct dk_roll_types medium,
const char *  name 
)

Retrieve settings/information about a specific DK roll/cassette

Parameters
[out]mediumThe settings for the DK roll named by name
[in]nameThe DK roll name the settings should be retrieved for
Return values
0On success, *medium is valid
-EINVALRoll with the given name not found

DK rolls can inherit settings from other rolls. This routine walks through the table and uses the dk_roll_types::like member to re-use their settings.

◆ ql_driver_raster_crop()

void ql_driver_raster_crop ( struct ql_drv t)

Crop the input raster to meet the printer's expectations/requirements

Parameters
[in]tFull job description

The printer device has some - hmm, lets it call - interesting requirements about the print data it accepts. Continuous labels are easy, but pre-cut labels aren't. In order to ensure the printer always cuts inbetween two pre-cut labels, we need to tweak the amount of lines to be print.

Read how_the_driver_deals_with_margins about details.

◆ ql_driver_send()

int ql_driver_send ( struct ql_drv t,
size_t  count,
const void *  data,
int  flush 
)

Send some data to the printer's stream

Parameters
[in,out]tFull job description
[in]countCount of bytes data points to
[in]dataPointer to the to be sent data
[in]flush'1' if the stream should be flushed
Return values
0Data buffered (and send, if flush is nonzero)
-EINVALPrinter device is unsuitable for writing
-EBADFReally bad internal failure
-EFAULTReally bad internal failure made by the caller
-EIOLow-level I/O error
Note
It seems to me, if this call returns with an error code the data wasn't sent.

◆ ql_driver_data_send()

int ql_driver_data_send ( struct ql_drv t,
size_t  count,
const void *  data,
int  flush 
)

Send some data to the printer's stream or the development/debugging file

Parameters
[in,out]tFull job description
[in]countCount of bytes data points to
[in]dataPointer to the to be sent data
[in]flush'1' if the stream should be flushed
Return values
0Data buffered (and send, if flush is nonzero)
-EINVALPrinter device is unsuitable for writing
-EBADFReally bad internal failure
-EFAULTReally bad internal failure made by the caller
-EIOLow-level I/O error

This sends the real printer data to the printer's stream like ql_driver_send() does, but of the debug option –writeto is in use, it writes it to the file instead.

This is for debugging/development purposes, to extract the generated wire data and check its content and format. It is required this way, since the driver depends on interactive data exchange with the printer and if something went wrong, there is no other easy to use chance to see the data in this case.

Todo:
Write a printer emulator instead.

Variable Documentation

◆ ql_drv_spare_features_list

const struct caps_ppd_selection* ql_drv_spare_features_list[10]
static

A spare array to add selections to a printer description on demand

◆ ql_drv_feature_power_off_selections

const struct caps_ppd_selection_entry ql_drv_feature_power_off_selections[]
static
Initial value:
= {
{ .option = "Unchanged", .description = ( "Don't change" ), .value = "keep", },
{ .option = "MIN10", .description = ( "10 Minutes" ), .value = "10", },
{ .option = "MIN20", .description = ( "20 Minutes" ), .value = "20", },
{ .option = "MIN30", .description = ( "30 Minutes" ), .value = "30", },
{ .option = "MIN40", .description = ( "40 Minutes" ), .value = "40", },
{ .option = "MIN50", .description = ( "50 Minutes" ), .value = "50", },
{ .option = "MIN60", .description = ( "60 Minutes" ), .value = "60", },
{ .option = "Disabled", .description = ( "Disabled" ), .value = "off", },
}

Some printers have an auto power off feature.

◆ ql_drv_feature_power_off_selection

const struct caps_ppd_selection ql_drv_feature_power_off_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "PowerOFF",
.description = ( "Auto Power Off" ),
.default_entry = 0,
}
@ LIBCAPS_OT_PICKONE
Definition: libcapsppd.h:282
static const struct caps_ppd_selection_entry ql_drv_feature_power_off_selections[]
Definition: ql-series.c:299

◆ ql_drv_feature_power_on_selections

const struct caps_ppd_selection_entry ql_drv_feature_power_on_selections[]
static
Initial value:
= {
{ .option = "Unchanged", .description = ( "Don't change" ), .value = "keep", },
{ .option = "ON", .description = ( "Go online" ), .value = "on", },
{ .option = "OFF", .description = ( "Keep offline" ), .value = "off", },
}

Some printers have an auto power on feature.

◆ ql_drv_feature_power_on_selection

const struct caps_ppd_selection ql_drv_feature_power_on_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "PowerOn",
.description = ( "Auto Power On" ),
.default_entry = 0,
}
static const struct caps_ppd_selection_entry ql_drv_feature_power_on_selections[]
Definition: ql-series.c:322

◆ ql_drv_feature_halftone_selections

const struct caps_ppd_selection_entry ql_drv_feature_halftone_selections[]
static
Initial value:
= {
{ .option = "NONE", .description = ( "Binary dithering" ), },
{ .option = "ORDERED", .description = ( "Ordered dithering" ), },
{ .option = "DIFFUSION", .description = ( "Diffusion dithering" ), },
}

How to dither the content

◆ ql_drv_feature_halftone_off_selection

struct caps_ppd_selection ql_drv_feature_halftone_off_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "Halftone",
.description = ( "Dithering method" ),
.default_entry = 2,
}
static const struct caps_ppd_selection_entry ql_drv_feature_halftone_selections[]
Definition: ql-series.c:351

◆ ql_driver_feature_bi_colour_medium_selections

const struct caps_ppd_selection_entry ql_driver_feature_bi_colour_medium_selections[]
static
Initial value:
= {
{ .option = "MONO", .description = ( "Monochrome Medium" ), },
{ .option = "BI", .description = ( "Bi-Colour Medium" ), },
}

We need an indicator if the medium is capable of bi-colour printing.

◆ ql_driver_feature_bi_colour_medium_selection

struct caps_ppd_selection ql_driver_feature_bi_colour_medium_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "COLOURCAPS",
.description = ( "Medium Colour Capabilities" ),
}
static const struct caps_ppd_selection_entry ql_driver_feature_bi_colour_medium_selections[]
Definition: ql-series.c:398

◆ rolls

const struct dk_roll_types rolls[]
static