CAPS Universe documentation  1.0.4
All you need to know to be successful
Macros | Functions
device-io.c File Reference

Functions to setup the required I/O to the USB printer device. More...

Macros

#define PRINTER_STREAM_BUFFER_DEFAULT_SIZE   128
 
#define PRINTER_STREAM_BUFFER_MAX_SIZE   8192
 

Functions

static size_t _caps_drv_buffer_size_read (struct caps_drv *cdrv)
 
int caps_drv_global_stream_io (struct caps_drv *cdrv)
 

Detailed Description

Author
Jürgen Borleis
Warning
Use as experimental

Macro Definition Documentation

◆ PRINTER_STREAM_BUFFER_DEFAULT_SIZE

#define PRINTER_STREAM_BUFFER_DEFAULT_SIZE   128

The default local printer data buffer size in kiB

Used to send large pieces of print data instead of many small pieces due to data processing.

Attention
The value is documented in the corresponding INI file, refer section interface, variable buffer_size and Feature: printing data buffer_size

◆ PRINTER_STREAM_BUFFER_MAX_SIZE

#define PRINTER_STREAM_BUFFER_MAX_SIZE   8192

The max size of the local printer data buffer in kiB

Note
'8192' is an arbitrary value.
Attention
The value is documented in the corresponding INI file, refer section interface, variable buffer_size and Feature: printing data buffer_size

Function Documentation

◆ _caps_drv_buffer_size_read()

static size_t _caps_drv_buffer_size_read ( struct caps_drv cdrv)
static

Extract the printing data buffer size from the INI setting

Parameters
[in,out]cdrvFull state information
Return values
sizeBuffer size in bytes (can be '0')

This function deals with the setting described in Feature: printing data buffer_size

Returns PRINTER_STREAM_BUFFER_DEFAULT_SIZE kiB if no setting exists or in case the setting is invalid.
If the settings exceeds PRINTER_STREAM_BUFFER_MAX_SIZE, it is limited to this value.

Note
The special value '0' means any buffering is disabled.

◆ caps_drv_global_stream_io()

int caps_drv_global_stream_io ( struct caps_drv cdrv)

Convert the file descriptor to the printer into stream IO and configure it

Parameters
[in,out]cdrvFull state information
Return values
0On success
negativeThe error codes fdopen() (file descriptor to stream IO) may returns

This functions sets up a stream IO from the given filedescriptor to be used by the printer driver. The filedescriptor is kept to be used later on to query the printer's status.

Some printers are in trouble (or time out) if there are pauses in the printing data between some kind of header data and the following printing data. These pauses can occur due to data processing, at least on slow host systems.
That's why increase the stream IO buffer size is a good idea to have most data already processed, before the printer will "see" the data. The user can control the used buffer size via the corresponding INI file in section interface, variable buffer_size. It is possible to disable a buffer at all. Refer Feature: printing data buffer_size for details.

Precondition
Never call a second time
The open device descriptor to the printer should already be tested and valid