Skip to main content

Python driver for IBM/Toshiba 4610 SureMark POS printers with USB interface

Project description

IBM/Toshiba 4610 SureMark

PyPI Python Release

Toshiba/IBM 4610 1NR

Python library for IBM / Toshiba 4610 SureMark POS thermal receipt printers, communicating over USB.

There are three communication modes supported:

  • Compatibility Legacy 4610
  • Native Mode
  • EPSON Emulation (RS-232 only)

This library targets the Native Mode which is basically the only viable option for the models with USB interface.

The library has been slop-reverse-engineered from JavaPOS, and then slop-coded into python. It's on the way to getting groomed to be a regular mediocre human-made nonsense.

Communication: Github Issues

Hardware

Model Station(s) Tested Notes
4610-1NR Receipt (thermal roll) + VID=0x04B3 PID=0x4535
4610-TI3 Receipt + Slip/DI + Check scanner - Full-featured model
Other Varies - Use IBM4610 base class

Installation

pip install py-ibm-4610

pyusb may require libusb to be installed on the system. This needs to be verified.

Also udev features must listed and verified.

Quick start

import logging
from py_ibm_4610 import IBM4610_1NR
from py_ibm_4610 import FONT_A, FONT_B, FONT_C, ALIGN_CENTER, BC_CODE39, QR_EC_H

logging.basicConfig(
    level=logging.DEBUG,
)

# Context manager opens and closes the USB connection automatically
with IBM4610_1NR() as p:
    # Modifying parameters one by one
    p.select_font(FONT_B)
    p.alignment(ALIGN_CENTER)
    p.bold(True)
    p.scale_font(width=1, height=1)
    p.text("py-ibm-4610 works!\n")
    # Print all we've got so far
    p.flush()
    # An easy way to go back to defaults
    p.reinit()
    # Modifying parameters in chain
    second_line = ("That's an example of how to use our library."
                   "The newlines are handled automatically by the printer")
    p.bold(True).text(f"{second_line}\n").bold(False)
    # Showing off with a barcode
    p.barcode(BC_CODE39, "IT-WORKS", height=50, width=4, align=ALIGN_CENTER)
    p.feed(2)
    # Print a QR Code
    url = "https://github.com/printer-stream/py-ibm-4610"
    p.qr_code(url, ec=QR_EC_H)
    p.flush()
    # Feed paper so the print get above the knife
    p.feed(10)
    # Finally cut the paper
    p.cut()

Reference page

There is a ReferencePage() class slop-coded recently. It needs to be refactored.

Usage:

from py_ibm_4610 import IBM4610_1NR, ReferencePage

with IBM4610_1NR() as p:
    ReferencePage(p).enable_all().print()

Available sections: TEXT_FORMATTING, FONT_SCALING, FONT_FACES, ALIGNMENT, FONT_COLOR, ROTATION, LINE_SPACING, FEED, TAB_STOPS, MARGINS, DOT_SPACING, CHAR_SETS, PRINT_QUALITY, BARCODES, BITMAP, PAGE_MODE, BUFFER_CONTROL, STATUS, LINE_COUNT, STATUS_SENT, ERROR_RECOVERY, FEED_BUTTON, CASH_DRAWER, BEEPER, MCT, STATISTICS.

Refer to the source code for more information. Otherwise, please submit a ticket with your question.

API overview

All command methods return self for chaining. Data is buffered until flush() is called (or cut(), which flushes automatically).

p.select_station(STATION_RECEIPT)
p.bold(True).text("Header\n").bold(False)
p.alignment(ALIGN_CENTER).text("Centered\n").alignment(ALIGN_LEFT)
p.barcode(BC_EAN13, "5901234123457", height=60)
p.feed(5)
p.cut()

Buffered workflow

This is not tested well enough, and could be unstable.

p.select_station(STATION_RECEIPT)
p.text("Line 1\n")
p.text("Line 2\n")
total_bytes = p.flush()             # sends everything at once

Printing QR Codes

QR Code printing on IBM/Toshiba 4610 from python is possible now with py-ibm-4610 and IBM4610_1NR.qr_code() method.

Refer to examples for more information.

Print QR Barcode command supported on 4610 models 1NR, 2NR, and 2CR at firmware level OF.xx or above. Command will be rejected on older model printers (4610-TIx) and on 4610-1NR/2NR/2CR that are not at level OF.xx or above.

Building from source

make build        # produces dist/py_ibm_4610-<version>-py3-none-any.whl
make install      # installs the wheel for the current user
make clean        # removes the built wheel

Notes

Reverse-engineered from the IBM JavaPOS driver (posj.jar) sourced out of a random place most probably.

License

GNU General Public License v3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_ibm_4610-1.3.0.tar.gz (74.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_ibm_4610-1.3.0-py3-none-any.whl (55.7 kB view details)

Uploaded Python 3

File details

Details for the file py_ibm_4610-1.3.0.tar.gz.

File metadata

  • Download URL: py_ibm_4610-1.3.0.tar.gz
  • Upload date:
  • Size: 74.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_ibm_4610-1.3.0.tar.gz
Algorithm Hash digest
SHA256 44432809b9f98c129a415fbff62b48a65d8ad71255a1d96d0f1671697aca9287
MD5 d59d5d245fc0e8a9145e21faecd7a9f2
BLAKE2b-256 503da969a78b88a5c037dae3de61f03b51b59ab46da5eff93ee663e632157853

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_ibm_4610-1.3.0.tar.gz:

Publisher: release.yml on printer-stream/py-ibm-4610

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_ibm_4610-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: py_ibm_4610-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 55.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_ibm_4610-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf41ac6b445c508cbc6b96968c8dae2d54ef33ac8c36391dc167e08886a67300
MD5 f817a84553bd866f1b23898c1d50852a
BLAKE2b-256 23e52b1509e5ee4d0904486225f0cc11a28425c13c9ed69813d48d1a991cfda3

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_ibm_4610-1.3.0-py3-none-any.whl:

Publisher: release.yml on printer-stream/py-ibm-4610

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page