Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printer is Non-Responsive #21

Open
UnoYakshi opened this issue Dec 5, 2023 · 2 comments
Open

Printer is Non-Responsive #21

UnoYakshi opened this issue Dec 5, 2023 · 2 comments

Comments

@UnoYakshi
Copy link

UnoYakshi commented Dec 5, 2023

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
@bitrate16
Copy link
Owner

  1. What's the current state - does it work or do something
  2. Have you tried to power off / power on completely
  3. Is bluetooth pairing / connection working?
  4. Can you get printer info like battery level, S/F, H/W, S/N, e.t.c?
  5. Have you restarted your bluetooth adapter?
  6. Does it work with official android / ios app?
  7. What if setting connection timeout to large value?

@UnoYakshi
Copy link
Author

Sorry it took so long to reply.

  1. I managed to find the hard reset "button". It was working, and I printed docs via Win10.
  2. Yeah, the power button was unresponsive.
  3. Yep, it worked.
  4. If I remember correctly, no, since I couldn't really connect to the device via this repository CLI.
  5. Yep, full laptop/PC restart, too. It was the printer issue.
  6. I don't use smartphones, hence, couldn't check it.
  7. Haven't tried it, however, I don't think that would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants