ESC/P2 Converter
Interprocess communication
Open and use shared memory object created by converters
- libreprinter.legacy_interprocess_com.debug_shared_memory()[source]
Display content of status messages in shared memory
Note
Pending jobs are not showed.
- libreprinter.legacy_interprocess_com.get_status_message(offset)[source]
Get value at the given address in shared memory
Expects that
initialize_interprocess_com()is called before.Note
Equivalent of legacy “peekPacketWord”
- Return type:
int
- libreprinter.legacy_interprocess_com.initialize_interprocess_com()[source]
Init/open shared memory
Shared file is at /dev/shm/retroprinter-shared-mem and initially created by converters.
We just purpose a hacky r/w binding to this object (which is very badly implemented in converters: the original project hopes to store a packet based on int16 into 2 int8 in 2 separated bytes in shared memory. In fact the OS uses 4 bytes (int32) for each “int” stored. So, for 512 packets we use 2048 bytes, and by accessing to 405 offset we access to 1620 offset in file. The file is badly initialized but it works because the OS reserves much more data than 512 bytes: a multiple of page size.).
Note
Equivalent of legacy “initialize_interface_comms”
- Returns:
The file handler on the shared memory file for its proper closing.
- Return type:
<_io.BufferedRandom>
- libreprinter.legacy_interprocess_com.send_status_message(offset, value)[source]
Put given value to the given offset in shared memory
Expects that
initialize_interprocess_com()is called before.Note
Equivalent of legacy “pokePacketWord”
- Parameters:
offset (int) – Address
value (int) – Value
Converter wrapper
Parametrize and launch espc2 converter binary as subprocess
- libreprinter.plugins.lp_escp2_converter.launch_escp2_converter(config)[source]
Start escp2 converter
If the config files contains a directory in escp2_converter_path setting, we expect that the binary is in this directory and has the name convert-escp2.
convert-escp2 <path> <timeout> <retain_data> <printing> <endlesstext> <retain_pdf>
Fixed parameters:
path: Path in output_path configuration variable.
timeout: 4, Wait for more data in file; pause waiting new byte in file
retain_data: 1, Useless param didn’t used
printing: 0, Do not let the converter send pdf to printer; see
libreprinter.jobs_to_printer_watchdog().endlesstext: Configured in endlesstext configuration variable.
retain_pdf: 1, Useless param didn’t used; endlesstext handles this behaviour
Ex: convert-escp2 ./ 4 1 0 0 1
Ex priority reg: nice -n19 <command>
- Parameters:
config (configparser.ConfigParser) – ConfigParser object
- Returns:
subprocess descriptor
- Return type:
subprocess.Popen