Merge pull request 'fix for printer standby' (#13) from wait_for_printer into main

Reviewed-on: #13
This commit is contained in:
Hendrik Schutter 2022-12-11 11:19:39 +01:00
commit 718f81b8e7
2 changed files with 10 additions and 2 deletions

View File

@ -33,8 +33,9 @@ systemctl enable --now /lib/systemd/system/reHDDPrinter.service
- Brother QL-570
- Paper With: 62mm or 696px
**Hint: Some Brother printers have enabled standby mode. This will disconnect the printer. See [Issue #12](https://git.mosad.xyz/localhorst/reHDDPrinter/issues/12) to disable standby.**
see https://github.com/pklaus/brother_ql
see https://github.com/pklaus/brother_ql for details for printer access

View File

@ -9,6 +9,7 @@
import sysv_ipc
import pycstruct
import os
import time
from brother_ql.brother_ql_create import create_label
from brother_ql.raster import BrotherQLRaster
import layouter
@ -17,6 +18,7 @@ str_buffer_size = 64 #keep this synchronous to reHDD
msg_queue_key = 0x1B11193C0 #keep this synchronous to reHDD
file_name = "output.png"
printer_path = "/dev/usb/lp0"
def get_struct_format():
#keep this synchronous to struct in reHDD
@ -57,10 +59,15 @@ def main():
shred_timestamp=int(driveData['driveShredTimestamp']),\
shred_duration=int(driveData['driveShredDuration']))
while(not os.path.exists(printer_path)):
print("Printer not found, waiting ...")
time.sleep(30) #sleep 30
layouter.generate_image(drive, rehdd_info, file_name)
qlr = BrotherQLRaster("QL-570")
create_label(qlr, file_name, '62')
with open("/dev/usb/lp0", 'wb') as file:
with open(printer_path, 'wb') as file:
file.write(qlr.data)
os.remove(file_name)
except sysv_ipc.ExistentialError: