Skip to content

Printer is Non-Responsive #21

@UnoYakshi

Description

@UnoYakshi

I guess I somehow broke the connection to the printer (A40). After unsuccessful attempts to print PDF files (tried to convert them to Pillow images and printImage()) my printer doesn't even react to turning it off, it just stays on.

Steps...

Code: PDF-to-Image and printImage()

import subprocess
from pathlib import Path

from PIL import Image
from pdf2image import convert_from_path

import peripage


def get_mac_and_model():
    print('Retrieving MAC and Peripage model...')
    result = subprocess.run(['hcitool', 'scan'], capture_output=True)
    raw_output = result.stdout.decode()
    out = raw_output.replace('Scanning ...\n\t', '').split('\t')

    mac = out[0].strip()
    model = out[1].strip()
    print(f'[{model}] on [{mac}] found')
    return mac, model


mac, model = get_mac_and_model()

printer = peripage.Printer(mac, peripage.PrinterType.A40)
printer.connect()
printer.reset()

# Set print concentration
printer.setConcentration(1)


def print_pdf(file_path: Path) -> None:

    # Convert to PDF-file to multiple images...
    print('Converting a PDF-file into images...')
    pages = convert_from_path(file_path, 200)
    images_files = []
    for count, page in enumerate(pages):
        img_name = f'out_{count}.jpg'
        page.save(img_name, 'JPEG')
        images_files.append(img_name)
        print(f'New PDF page converted: {img_name}')

    # Print save images...
    print('Printing images...')
    for img_name in images_files:
        with Image.open(img_name) as img:
            printer.printlnASCII('NEW PAGE')
            printer.printImage(img)
            printer.printBreak(100)
            print(f'Printed: {img}')


if __name__ == '__main__':
    print_pdf(Path('local_file.pdf'))

Printer Response

It started to use paper, not printing anything on it (before that, I successfully printed "HONK" from the README.md). So I've decided to turn it off by opening the cover (yes, I didn't read the instruction). It kind of worked, the printer stopped. However, it doesn't really work now.

Current State

Now I can't really use the printer. I've tried to install drivers on Win10 but the installer doesn't see the printer as well. None of my tries succeeded in bringing back the printer's functionality. I still see a green LED bear-face no matter what I do.

P.S. Strangely enough, Win10 gave me multiple power surge warnings when I was connecting the printer via a USB-hub. So I might accidentally kill the hub.
P.P.S. Bluetooth-pairing process works just fine on both, Ubuntu and Win10.

Error

    > peripage -m <mac_address> -p A40 -e

Traceback (most recent call last):
  File "<string>", line 3, in recv
_bluetooth.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 5, in recv
bluetooth.btcommon.BluetoothError: timed out

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions