CAPS Universe documentation  1.0.4
All you need to know to be successful
Macros | Functions | Variables
hl-hbp.c File Reference

Create printer's wire data for HL monochrome laser printers according to HBP. More...

Macros

#define HBP_ECO_OFF   0x00
 
#define HBP_ECO_DARK   0x01
 
#define HBP_ECO_MID   0x02
 
#define HBP_ECO_LIGHT   0x03
 
#define HBP_MEDIUM_TYPE   0x00
 
#define HBP_REGULAR_TYPE   0x00
 
#define HBP_THICK_TYPE   0x01
 
#define HBP_THICKER_TYPE   0x02
 
#define HBP_TRANSPARENCY   0x03
 
#define HBP_THIN_TYPE   0x04
 
#define HBP_BOND_TYPE   0x05
 
#define HBP_ENVELOP_TYPE   0x06
 
#define HBP_THICK_ENVELOP_TYPE   0x07
 
#define HBP_THIN_ENVELOP_TYPE   0x08
 
#define HBP_PRINT_MODE   0x02
 
#define HBP_NORMAL_MODE   0x00
 
#define HBP_ENVELOP_MODE   0x01
 
#define HBP_RES_600DPI   0x00
 
#define HBP_RES_300DPI   0x05
 
#define HBP_RES_150DPI   0x0A
 
#define HBP_RES_1200DPI   0x0F /* not all printers */
 

Functions

static void _hl_hbp_mode_density (FILE *prn, struct hl_drv *t)
 
static void _hl_hbp_mode_temperature (FILE *prn, struct hl_job_options *j)
 
static void _hl_hbp_mode_medium (FILE *prn, struct hl_job_options *j)
 
static void hl_hbp_mode_job_start (struct hl_drv *t, struct hl_job_options *j)
 
static void hl_hbp_mode_line_send (const struct cm1030_line *cline, FILE *prn)
 
static int hl_hbp_mode_page_encode (struct hl_drv *t)
 
static void hl_hbp_mode_page_finish (struct hl_drv *t)
 
static void hl_hbp_mode_job_finish (struct hl_drv *t)
 

Variables

const struct hl_encoder_calls hbp_calls
 

Detailed Description

Note
HBP is an acronym for Host Based Printing. Yet another GDI protocol.

Recently I found a paper from Brother where the HBP printing mode is described. It uses the 1030 encoding method, but has some different printer control codes around the graphics data. This mode is entered via "@PJL ENTER LANGUAGE = HBP" and exited via "@X".

Note
<size> is a sequence of three bytes and encoded in big-endian.

It seems, in this mode there is no need to divide the print data into bands of some size. Because the manual states:

‍The printer driver can send the printer 1 page of print data divided into sections by sending these commands continuously. It is recommended to send 1 page of print data without dividing into sections when the 1 page print data is more than the printer memory (500 Kbytes) as the printer will print this 'on the fly' and sending it in one block will improve the print performance.

Note
It seems the HBP mode is limited up to 600 DPI (or does "@PJL SET RAS1200MODE = TRUE" change the game like in PCL?)

The last line sent for a page should always be an empty line:

‍@G<0x0><0x00><0x01><0xff>

Attention
Even if my HL2130 printer states it is capable of HBP, it doesn't print anything and just spits out many empty media, for a file which tries to print one page only. Thus, we need a printer which is really capable to deal with commands and data in HBP mode.

Macro Definition Documentation

◆ HBP_ECO_OFF

#define HBP_ECO_OFF   0x00

◆ HBP_ECO_DARK

#define HBP_ECO_DARK   0x01

◆ HBP_ECO_MID

#define HBP_ECO_MID   0x02

◆ HBP_ECO_LIGHT

#define HBP_ECO_LIGHT   0x03

◆ HBP_MEDIUM_TYPE

#define HBP_MEDIUM_TYPE   0x00

◆ HBP_REGULAR_TYPE

#define HBP_REGULAR_TYPE   0x00

◆ HBP_THICK_TYPE

#define HBP_THICK_TYPE   0x01

◆ HBP_THICKER_TYPE

#define HBP_THICKER_TYPE   0x02

◆ HBP_TRANSPARENCY

#define HBP_TRANSPARENCY   0x03

◆ HBP_THIN_TYPE

#define HBP_THIN_TYPE   0x04

◆ HBP_BOND_TYPE

#define HBP_BOND_TYPE   0x05

◆ HBP_ENVELOP_TYPE

#define HBP_ENVELOP_TYPE   0x06

◆ HBP_THICK_ENVELOP_TYPE

#define HBP_THICK_ENVELOP_TYPE   0x07

◆ HBP_THIN_ENVELOP_TYPE

#define HBP_THIN_ENVELOP_TYPE   0x08

◆ HBP_PRINT_MODE

#define HBP_PRINT_MODE   0x02

◆ HBP_NORMAL_MODE

#define HBP_NORMAL_MODE   0x00

◆ HBP_ENVELOP_MODE

#define HBP_ENVELOP_MODE   0x01

◆ HBP_RES_600DPI

#define HBP_RES_600DPI   0x00

◆ HBP_RES_300DPI

#define HBP_RES_300DPI   0x05

◆ HBP_RES_150DPI

#define HBP_RES_150DPI   0x0A

◆ HBP_RES_1200DPI

#define HBP_RES_1200DPI   0x0F /* not all printers */

Function Documentation

◆ _hl_hbp_mode_density()

static void _hl_hbp_mode_density ( FILE *  prn,
struct hl_drv *  t 
)
static

Adapt density setting for this print job

Note
The higher the value, the lighter the print

◆ _hl_hbp_mode_temperature()

static void _hl_hbp_mode_temperature ( FILE *  prn,
struct hl_job_options *  j 
)
static

Adapt temperature according to the medium type/thickness

This step is important, since the printer must adapt the temperature according to the material (thicker medium -> higher temperature <- assumption only).

Todo:
If j->media_type contains 'THICK'/'ENVTHICK', "THICK2" or "TRANSPARENCY", we switch to HBP_THICK_TYPE, HBP_THICKER_TYPE or HBP_TRANSPARENCY else to HBP_REGULAR_TYPE
  • "REGULAR" is defined as 80 g per m²
  • "THICK" is defined to 90g ... 105g per m²
  • "THICK2" is defined to 105g ... 161g per m²
Precondition
Depends on specific media type keywords in the printer's hl*_media_type_selections list.

◆ _hl_hbp_mode_medium()

static void _hl_hbp_mode_medium ( FILE *  prn,
struct hl_job_options *  j 
)
static

Adapt the printing to a regular (large) medium or to (smaller) envelops

The printer needs to know, if it should print to envelops. I don't know exactly why, yet.

Todo:
If j->media_type contains 'ENV', we switch to HBP_ENVELOP_MODE, else to HBP_NORMAL_MODE
  • 'ENVELOPES, is defined as an "Envelope"
  • "ENVTHICK" is defined as a "Thick envelope"
  • "ENVTHIN" is define as a "Thin envelope"
Precondition
Depends on specific media type keywords in the printer's hl*_media_type_selections list.

◆ hl_hbp_mode_job_start()

static void hl_hbp_mode_job_start ( struct hl_drv *  t,
struct hl_job_options *  j 
)
static
Precondition
The printer is in HBP mode

◆ hl_hbp_mode_line_send()

static void hl_hbp_mode_line_send ( const struct cm1030_line cline,
FILE *  prn 
)
static
Precondition
Printer must be in HBP mode

◆ hl_hbp_mode_page_encode()

static int hl_hbp_mode_page_encode ( struct hl_drv *  t)
static

Encode the full page according to the 1030 method but in HBP mode

Parameters
[in]tOur driver instance description
Return values
0on success
-errnoon failures

The description of the HBP mode differs from the PCL mode in that, it doesn't need to send data in bands and blocks. It seems, we can send the whole page at once.

Precondition
Printer must be in HBP mode

◆ hl_hbp_mode_page_finish()

static void hl_hbp_mode_page_finish ( struct hl_drv *  t)
static

Finish the page by ejecting it ("form feed")

Parameters
[in]tOur driver instance description

According to the HBP mode description, an empty line must proceed the form feed command

Precondition
Printer must be in HBP mode

◆ hl_hbp_mode_job_finish()

static void hl_hbp_mode_job_finish ( struct hl_drv *  t)
static

Finish the job, exit the HBP mode and re-enter the PJL mode

Parameters
[in]tOur driver instance description

This commad should be sent when the print job is fully printed.

Note
Afer sending this command, most settings (refer #hl_hbp_mode_enter()) are undefined again)
Precondition
Printer must be in HBP mode
Postcondition
The printer is again in PJL mode

Variable Documentation

◆ hbp_calls

const struct hl_encoder_calls hbp_calls
Initial value:
= {
.encoder = HL_PRN_LANG_HBP,
.job_start = hl_hbp_mode_job_start,
.job_finish = hl_hbp_mode_job_finish,
.page_encode = hl_hbp_mode_page_encode,
.page_finish = hl_hbp_mode_page_finish,
}
static void hl_hbp_mode_job_finish(struct hl_drv *t)
Definition: hl-hbp.c:332
static void hl_hbp_mode_job_start(struct hl_drv *t, struct hl_job_options *j)
Definition: hl-hbp.c:196
static void hl_hbp_mode_page_finish(struct hl_drv *t)
Definition: hl-hbp.c:310
static int hl_hbp_mode_page_encode(struct hl_drv *t)
Definition: hl-hbp.c:260