Git Product home page Git Product logo

catprinter's People

Contributors

akx avatar c7h avatar david-lor avatar dependabot[bot] avatar hexpunk avatar jauderho avatar joaocostaifg avatar knilch0r avatar omgmog avatar rbaron avatar wang-yue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

catprinter's Issues

iTerm2 crash when trying to access Bluetooth

edit: not catprinter's fault, see followup comment


(macOS 12.3 on M1 Pro, Python 3.10.2, zsh 5.8, iTerm2 3.5.0beta2)

The installation instructions worked great, but the script is crashing when trying to actually connect to bluetooth devices:

$ python3 print.py --show-preview test.jpg
โณ Applying Floyd-Steinberg dithering to image...
โœ… Done.
โ„น๏ธ  Displaying preview.
๐Ÿค” Go ahead with print? [Y/n]?
โœ… Read image: (386, 384) (h, w) pixels
โœ… Generated BLE commands: 14851 bytes
โณ Trying to auto-discover a printer...
zsh: abort      python3 print.py --show-preview test.jpg

(screenshot)

The crash log includes the following:

Termination Reason:    Namespace TCC, Code 0 
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data.

โ€” it seems like this should be an easy fix, or maybe even a permission I can override myself at runtime, but I'm not familiar enough with macos dev to know how, and having trouble googling for the right answer here. I'd find it super valuable to include the needed file(s) or just some readme instructions in this repo.

Full crash log attached:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process: Python [15390]
Path: /opt/homebrew/*/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
Identifier: org.python.python
Version: 3.10.2 (3.10.2)
Code Type: ARM-64 (Native)
Parent Process: zsh [6995]
Responsible: iTerm2 [9763]
User ID: 501

Date/Time: 2022-04-15 09:44:49.5130 -0400
OS Version: macOS 12.3 (21E230)
Report Version: 12
Anonymous UUID: 64A6AD5A-7C02-7D4E-502D-370E11E5AAC5

Sleep/Wake UUID: 5AA72AF8-2334-4C87-9839-127076CC022E

Time Awake Since Boot: 1500000 seconds
Time Since Wake: 70683 seconds

System Integrity Protection: enabled

Crashed Thread: 3 Dispatch queue: com.apple.root.default-qos

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: Namespace TCC, Code 0
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data.

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x19bc8c290 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x19bcc683c _pthread_cond_wait + 1236
2 Python 0x102e515d4 PyThread_acquire_lock_timed + 396
3 Python 0x102eae2ac acquire_timed + 256
4 Python 0x102eae4e8 lock_PyThread_acquire_lock + 56
5 Python 0x102d06a34 method_vectorcall_VARARGS_KEYWORDS + 156
6 Python 0x102df5854 call_function + 128
7 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
8 Python 0x102de70ec _PyEval_Vector + 328
9 Python 0x102df5854 call_function + 128
10 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
11 Python 0x102de70ec _PyEval_Vector + 328
12 Python 0x102df5854 call_function + 128
13 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
14 Python 0x102de70ec _PyEval_Vector + 328
15 _objc.cpython-310-darwin.so 0x10383f58c pysel_call + 540
16 Python 0x102cf994c _PyObject_MakeTpCall + 136
17 Python 0x102df58e4 call_function + 272
18 Python 0x102df0404 _PyEval_EvalFrameDefault + 32836
19 Python 0x102de70ec _PyEval_Vector + 328
20 Python 0x102cf9c24 _PyObject_FastCallDictTstate + 208
21 Python 0x102d70630 slot_tp_init + 196
22 Python 0x102d68968 type_call + 288
23 Python 0x102cfa36c _PyObject_Call + 128
24 Python 0x102df05ec _PyEval_EvalFrameDefault + 33324
25 Python 0x102d115e0 gen_send_ex2 + 224
26 Python 0x102deb888 _PyEval_EvalFrameDefault + 13512
27 Python 0x102d115e0 gen_send_ex2 + 224
28 Python 0x102deb888 _PyEval_EvalFrameDefault + 13512
29 Python 0x102d115e0 gen_send_ex2 + 224
30 _asyncio.cpython-310-darwin.so 0x103194a74 task_step_impl + 440
31 _asyncio.cpython-310-darwin.so 0x103194848 task_step + 52
32 Python 0x102cf994c _PyObject_MakeTpCall + 136
33 Python 0x102e0bd50 context_run + 92
34 Python 0x102d4cde8 cfunction_vectorcall_FASTCALL_KEYWORDS + 84
35 Python 0x102df05ec _PyEval_EvalFrameDefault + 33324
36 Python 0x102de70ec _PyEval_Vector + 328
37 Python 0x102df5854 call_function + 128
38 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
39 Python 0x102de70ec _PyEval_Vector + 328
40 Python 0x102df5854 call_function + 128
41 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
42 Python 0x102de70ec _PyEval_Vector + 328
43 Python 0x102df5854 call_function + 128
44 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
45 Python 0x102de70ec _PyEval_Vector + 328
46 Python 0x102df5854 call_function + 128
47 Python 0x102df0384 _PyEval_EvalFrameDefault + 32708
48 Python 0x102de70ec _PyEval_Vector + 328
49 Python 0x102df5854 call_function + 128
50 Python 0x102df0404 _PyEval_EvalFrameDefault + 32836
51 Python 0x102de70ec _PyEval_Vector + 328
52 Python 0x102df5854 call_function + 128
53 Python 0x102df0438 _PyEval_EvalFrameDefault + 32888
54 Python 0x102de70ec _PyEval_Vector + 328
55 Python 0x102de6f90 PyEval_EvalCode + 104
56 Python 0x102e406cc run_eval_code_obj + 84
57 Python 0x102e40614 run_mod + 112
58 Python 0x102e40280 pyrun_file + 148
59 Python 0x102e3fb94 _PyRun_SimpleFileObject + 268
60 Python 0x102e3f1d4 _PyRun_AnyFileObject + 232
61 Python 0x102e6140c pymain_run_file_obj + 220
62 Python 0x102e60b5c pymain_run_file + 72
63 Python 0x102e603cc Py_RunMain + 868
64 Python 0x102e61578 pymain_main + 36
65 Python 0x102e617ec Py_BytesMain + 40
66 dyld 0x102859088 start + 516

Thread 1:
0 libsystem_pthread.dylib 0x19bcc1078 start_wqthread + 0

Thread 2:
0 libsystem_pthread.dylib 0x19bcc1078 start_wqthread + 0

Thread 3 Crashed:: Dispatch queue: com.apple.root.default-qos
0 libsystem_kernel.dylib 0x19bcb54c4 __abort_with_payload + 8
1 libsystem_kernel.dylib 0x19bcb7ebc abort_with_payload_wrapper_internal + 104
2 libsystem_kernel.dylib 0x19bcb7ef0 abort_with_payload + 16
3 TCC 0x1a0e517cc TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION + 172
4 TCC 0x1a0e520e4 __TCCAccessRequest_block_invoke.194 + 588
5 TCC 0x1a0e4f6bc __tccd_send_message_block_invoke + 632
6 libxpc.dylib 0x19b9fe9d0 _xpc_connection_reply_callout + 124
7 libxpc.dylib 0x19b9fe8c0 _xpc_connection_call_reply_async + 88
8 libdispatch.dylib 0x19bb02248 _dispatch_client_callout3 + 20
9 libdispatch.dylib 0x19bb1fc24 _dispatch_mach_msg_async_reply_invoke + 340
10 libdispatch.dylib 0x19bb14658 _dispatch_kevent_worker_thread + 1292
11 libsystem_pthread.dylib 0x19bcc2398 _pthread_wqthread + 344
12 libsystem_pthread.dylib 0x19bcc1080 start_wqthread + 8

Thread 4:
0 libsystem_pthread.dylib 0x19bcc1078 start_wqthread + 0

Thread 3 crashed with ARM Thread State (64-bit):
x0: 0x000000000000000b x1: 0x0000000000000000 x2: 0x0000000117310070 x3: 0x0000000000000022
x4: 0x00000001173100a4 x5: 0x0000000000000000 x6: 0x00fb000004220122 x7: 0x0000000000000001
x8: 0x0000000000000020 x9: 0x39d5ecb5a84400df x10: 0x0100000100000000 x11: 0x00000000009f68a0
x12: 0x00000010134141e7 x13: 0x0000000000000000 x14: 0x0000020000011000 x15: 0x0000000100000000
x16: 0x0000000000000209 x17: 0x00000001f5e57d00 x18: 0x0000000000000000 x19: 0x0000000000000000
x20: 0x00000001173100a4 x21: 0x0000000000000022 x22: 0x0000000117310070 x23: 0x0000000000000000
x24: 0x000000000000000b x25: 0x0000600003fd58c0 x26: 0x0000000000000000 x27: 0x0000000000000000
x28: 0x0000000000000000 fp: 0x000000016d902630 lr: 0x000000019bcb7ebc
sp: 0x000000016d9025f0 pc: 0x000000019bcb54c4 cpsr: 0x40001000
far: 0x0000000117310000 esr: 0x56000080 Address size fault

Binary Images:
0x19bc87000 - 0x19bcbefff libsystem_kernel.dylib () <1d7b3b8e-75a1-34ea-aa52-9f7c23155c55> /usr/lib/system/libsystem_kernel.dylib
0x19bcbf000 - 0x19bccbfff libsystem_pthread.dylib (
) /usr/lib/system/libsystem_pthread.dylib
0x102c88000 - 0x102f63fff org.python.python (3.10.2, (c) 2001-2021 Python Software Foundation.) <00c5723d-1ca4-3147-945c-9423aebf940e> /opt/homebrew//Python.framework/Versions/3.10/Python
0x103800000 - 0x103857fff _objc.cpython-310-darwin.so (
) <58ede521-caa3-34a4-90f1-cd49c469972a> /Users/USER//_objc.cpython-310-darwin.so
0x103190000 - 0x103197fff _asyncio.cpython-310-darwin.so (
) /opt/homebrew//Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_asyncio.cpython-310-darwin.so
0x102854000 - 0x1028b3fff dyld (
) /usr/lib/dyld
0x1a0e4c000 - 0x1a0e67fff com.apple.TCC (1.0) <5397213b-5dc5-3512-b525-bd2c4f95164f> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
0x19b9ef000 - 0x19ba30fff libxpc.dylib () <4c6eb90b-bd32-3cad-9f25-c9f234775efb> /usr/lib/system/libxpc.dylib
0x19bafe000 - 0x19bb44fff libdispatch.dylib (
) /usr/lib/system/libdispatch.dylib

External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 0
thread_create: 0
thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=929.9M resident=0K(0%) swapped_out_or_unallocated=929.9M(100%)
Writable regions: Total=1.6G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.6G(100%)

                            VIRTUAL   REGION 

REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Accelerate framework 256K 2
Activity Tracing 256K 1
CG image 496K 4
ColorSync 576K 25
CoreAnimation 3008K 8
CoreGraphics 16K 1
CoreUI image data 752K 5
Foundation 16K 1
Kernel Alloc Once 32K 1
MALLOC 278.3M 47
MALLOC guard page 192K 11
MALLOC_MEDIUM (reserved) 960.0M 8 reserved VM address space (unallocated)
MALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)
STACK GUARD 80K 5
Stack 18.1M 5
VM_ALLOCATE 18.5M 24
__AUTH 1859K 163
__AUTH_CONST 10.8M 319
__DATA 24.5M 440
__DATA_CONST 14.3M 442
__DATA_DIRTY 704K 111
__FONT_DATA 4K 1
__LINKEDIT 602.7M 125
__OBJC_CONST 1477K 133
__OBJC_RO 82.9M 1
__OBJC_RW 3152K 1
__TEXT 327.2M 458
__UNICODE 592K 1
dyld private memory 1024K 1
mapped file 67.8M 14
shared memory 848K 15
=========== ======= =======
TOTAL 2.7G 2374
TOTAL, minus reserved VM space 1.4G 2374


Full Report

{"app_name":"Python","timestamp":"2022-04-15 09:44:53.00 -0400","app_version":"3.10.2","slice_uuid":"64e72042-bcc0-380d-86c3-0155dd2ba814","build_version":"3.10.2","platform":1,"bundleID":"org.python.python","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.3 (21E230)","incident_id":"2027E8CC-CD59-4BB2-A927-C935ECF4E5C0","name":"Python"}
{
"uptime" : 1500000,
"procLaunch" : "2022-04-15 09:44:35.4759 -0400",
"procRole" : "Background",
"version" : 2,
"userID" : 501,
"deployVersion" : 210,
"modelCode" : "MacBookPro18,3",
"procStartAbsTime" : 36830690852586,
"coalitionID" : 2319,
"osVersion" : {
"train" : "macOS 12.3",
"build" : "21E230",
"releaseType" : "User"
},
"captureTime" : "2022-04-15 09:44:49.5130 -0400",
"incident" : "2027E8CC-CD59-4BB2-A927-C935ECF4E5C0",
"bug_type" : "309",
"pid" : 15390,
"procExitAbsTime" : 36831025681275,
"translated" : false,
"cpuType" : "ARM-64",
"procName" : "Python",
"procPath" : "/opt/homebrew//Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python",
"bundleInfo" : {"CFBundleShortVersionString":"3.10.2","CFBundleVersion":"3.10.2","CFBundleIdentifier":"org.python.python"},
"storeInfo" : {"deviceIdentifierForVendor":"8313ACB2-CE8F-5516-BD69-5002BFD6333A","thirdParty":true},
"parentProc" : "zsh",
"parentPid" : 6995,
"coalitionName" : "com.googlecode.iterm2",
"crashReporterKey" : "64A6AD5A-7C02-7D4E-502D-370E11E5AAC5",
"responsiblePid" : 9763,
"responsibleProc" : "iTerm2",
"wakeTime" : 70683,
"sleepWakeUUID" : "5AA72AF8-2334-4C87-9839-127076CC022E",
"sip" : "enabled",
"isCorpse" : 1,
"exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
"termination" : {"flags":518,"code":0,"namespace":"TCC","details":["This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data."]},
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
"faultingThread" : 3,
"threads" : [{"id":10446828,"queue":"com.apple.main-thread","frames":[{"imageOffset":21136,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":0},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":1},{"imageOffset":1873364,"symbol":"PyThread_acquire_lock_timed","symbolLocation":396,"imageIndex":2},{"imageOffset":2253484,"symbol":"acquire_timed","symbolLocation":256,"imageIndex":2},{"imageOffset":2254056,"symbol":"lock_PyThread_acquire_lock","symbolLocation":56,"imageIndex":2},{"imageOffset":518708,"symbol":"method_vectorcall_VARARGS_KEYWORDS","symbolLocation":156,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":259468,"symbol":"pysel_call","symbolLocation":540,"imageIndex":3},{"imageOffset":465228,"symbol":"_PyObject_MakeTpCall","symbolLocation":136,"imageIndex":2},{"imageOffset":1497316,"symbol":"call_function","symbolLocation":272,"imageIndex":2},{"imageOffset":1475588,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32836,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":465956,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":208,"imageIndex":2},{"imageOffset":951856,"symbol":"slot_tp_init","symbolLocation":196,"imageIndex":2},{"imageOffset":919912,"symbol":"type_call","symbolLocation":288,"imageIndex":2},{"imageOffset":467820,"symbol":"_PyObject_Call","symbolLocation":128,"imageIndex":2},{"imageOffset":1476076,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":33324,"imageIndex":2},{"imageOffset":562656,"symbol":"gen_send_ex2","symbolLocation":224,"imageIndex":2},{"imageOffset":1456264,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":13512,"imageIndex":2},{"imageOffset":562656,"symbol":"gen_send_ex2","symbolLocation":224,"imageIndex":2},{"imageOffset":1456264,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":13512,"imageIndex":2},{"imageOffset":562656,"symbol":"gen_send_ex2","symbolLocation":224,"imageIndex":2},{"imageOffset":19060,"symbol":"task_step_impl","symbolLocation":440,"imageIndex":4},{"imageOffset":18504,"symbol":"task_step","symbolLocation":52,"imageIndex":4},{"imageOffset":465228,"symbol":"_PyObject_MakeTpCall","symbolLocation":136,"imageIndex":2},{"imageOffset":1588560,"symbol":"context_run","symbolLocation":92,"imageIndex":2},{"imageOffset":806376,"symbol":"cfunction_vectorcall_FASTCALL_KEYWORDS","symbolLocation":84,"imageIndex":2},{"imageOffset":1476076,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":33324,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475460,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32708,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475588,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32836,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1497172,"symbol":"call_function","symbolLocation":128,"imageIndex":2},{"imageOffset":1475640,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":32888,"imageIndex":2},{"imageOffset":1437932,"symbol":"_PyEval_Vector","symbolLocation":328,"imageIndex":2},{"imageOffset":1437584,"symbol":"PyEval_EvalCode","symbolLocation":104,"imageIndex":2},{"imageOffset":1803980,"symbol":"run_eval_code_obj","symbolLocation":84,"imageIndex":2},{"imageOffset":1803796,"symbol":"run_mod","symbolLocation":112,"imageIndex":2},{"imageOffset":1802880,"symbol":"pyrun_file","symbolLocation":148,"imageIndex":2},{"imageOffset":1801108,"symbol":"_PyRun_SimpleFileObject","symbolLocation":268,"imageIndex":2},{"imageOffset":1798612,"symbol":"_PyRun_AnyFileObject","symbolLocation":232,"imageIndex":2},{"imageOffset":1938444,"symbol":"pymain_run_file_obj","symbolLocation":220,"imageIndex":2},{"imageOffset":1936220,"symbol":"pymain_run_file","symbolLocation":72,"imageIndex":2},{"imageOffset":1934284,"symbol":"Py_RunMain","symbolLocation":868,"imageIndex":2},{"imageOffset":1938808,"symbol":"pymain_main","symbolLocation":36,"imageIndex":2},{"imageOffset":1939436,"symbol":"Py_BytesMain","symbolLocation":40,"imageIndex":2},{"imageOffset":20616,"symbol":"start","symbolLocation":516,"imageIndex":5}]},{"id":10446853,"frames":[{"imageOffset":8312,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]},{"id":10447006,"frames":[{"imageOffset":8312,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]},{"triggered":true,"id":10447008,"threadState":{"x":[{"value":11},{"value":0},{"value":4684054640},{"value":34},{"value":4684054692},{"value":0},{"value":70650219223712034},{"value":1},{"value":32},{"value":4167497295157526751},{"value":72057598332895232},{"value":10447008},{"value":69042520551},{"value":0},{"value":2199023325184},{"value":4294967296},{"value":521},{"value":8420424960},{"value":0},{"value":0},{"value":4684054692},{"value":34},{"value":4684054640},{"value":0},{"value":11},{"value":105553183201472},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6908772028},"cpsr":{"value":1073745920},"fp":{"value":6133130800},"sp":{"value":6133130736},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6908761284,"matchesCrashFrame":1},"far":{"value":4684054528}},"queue":"com.apple.root.default-qos","frames":[{"imageOffset":189636,"symbol":"__abort_with_payload","symbolLocation":8,"imageIndex":0},{"imageOffset":200380,"symbol":"abort_with_payload_wrapper_internal","symbolLocation":104,"imageIndex":0},{"imageOffset":200432,"symbol":"abort_with_payload","symbolLocation":16,"imageIndex":0},{"imageOffset":22476,"symbol":"TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION","symbolLocation":172,"imageIndex":6},{"imageOffset":24804,"symbol":"__TCCAccessRequest_block_invoke.194","symbolLocation":588,"imageIndex":6},{"imageOffset":14012,"symbol":"__tccd_send_message_block_invoke","symbolLocation":632,"imageIndex":6},{"imageOffset":63952,"symbol":"_xpc_connection_reply_callout","symbolLocation":124,"imageIndex":7},{"imageOffset":63680,"symbol":"_xpc_connection_call_reply_async","symbolLocation":88,"imageIndex":7},{"imageOffset":16968,"symbol":"_dispatch_client_callout3","symbolLocation":20,"imageIndex":8},{"imageOffset":138276,"symbol":"_dispatch_mach_msg_async_reply_invoke","symbolLocation":340,"imageIndex":8},{"imageOffset":91736,"symbol":"_dispatch_kevent_worker_thread","symbolLocation":1292,"imageIndex":8},{"imageOffset":13208,"symbol":"_pthread_wqthread","symbolLocation":344,"imageIndex":1},{"imageOffset":8320,"symbol":"start_wqthread","symbolLocation":8,"imageIndex":1}]},{"id":10447009,"frames":[{"imageOffset":8312,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]}],
"usedImages" : [
{
"source" : "P",
"arch" : "arm64e",
"base" : 6908571648,
"size" : 229376,
"uuid" : "1d7b3b8e-75a1-34ea-aa52-9f7c23155c55",
"path" : "/usr/lib/system/libsystem_kernel.dylib",
"name" : "libsystem_kernel.dylib"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 6908801024,
"size" : 53248,
"uuid" : "cee8bc77-6923-34d9-89a3-6f8f7279605e",
"path" : "/usr/lib/system/libsystem_pthread.dylib",
"name" : "libsystem_pthread.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4341661696,
"CFBundleShortVersionString" : "3.10.2, (c) 2001-2021 Python Software Foundation.",
"CFBundleIdentifier" : "org.python.python",
"size" : 2998272,
"uuid" : "00c5723d-1ca4-3147-945c-9423aebf940e",
"path" : "/opt/homebrew/
/Python.framework/Versions/3.10/Python",
"name" : "Python",
"CFBundleVersion" : "3.10.2"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4353687552,
"size" : 360448,
"uuid" : "58ede521-caa3-34a4-90f1-cd49c469972a",
"path" : "/Users/USER//_objc.cpython-310-darwin.so",
"name" : "_objc.cpython-310-darwin.so"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4346937344,
"size" : 32768,
"uuid" : "df2efc61-e780-30e0-b24c-46aa7f6b7310",
"path" : "/opt/homebrew/
/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_asyncio.cpython-310-darwin.so",
"name" : "_asyncio.cpython-310-darwin.so"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 4337254400,
"size" : 393216,
"uuid" : "fbb89662-e6f2-3434-b542-f75185ac5e74",
"path" : "/usr/lib/dyld",
"name" : "dyld"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 6994313216,
"CFBundleShortVersionString" : "1.0",
"CFBundleIdentifier" : "com.apple.TCC",
"size" : 114688,
"uuid" : "5397213b-5dc5-3512-b525-bd2c4f95164f",
"path" : "/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC",
"name" : "TCC",
"CFBundleVersion" : "1"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 6905851904,
"size" : 270336,
"uuid" : "4c6eb90b-bd32-3cad-9f25-c9f234775efb",
"path" : "/usr/lib/system/libxpc.dylib",
"name" : "libxpc.dylib"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 6906961920,
"size" : 290816,
"uuid" : "dc048e3b-e023-3d17-afe5-4ff3dc625608",
"path" : "/usr/lib/system/libdispatch.dylib",
"name" : "libdispatch.dylib"
}
],
"sharedCache" : {
"base" : 6905511936,
"size" : 3136438272,
"uuid" : "00edbaf8-9281-3f26-b94f-e6a315e3a659"
},
"vmSummary" : "ReadOnly portion of Libraries: Total=929.9M resident=0K(0%) swapped_out_or_unallocated=929.9M(100%)\nWritable regions: Total=1.6G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.6G(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nAccelerate framework 256K 2 \nActivity Tracing 256K 1 \nCG image 496K 4 \nColorSync 576K 25 \nCoreAnimation 3008K 8 \nCoreGraphics 16K 1 \nCoreUI image data 752K 5 \nFoundation 16K 1 \nKernel Alloc Once 32K 1 \nMALLOC 278.3M 47 \nMALLOC guard page 192K 11 \nMALLOC_MEDIUM (reserved) 960.0M 8 reserved VM address space (unallocated)\nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nSTACK GUARD 80K 5 \nStack 18.1M 5 \nVM_ALLOCATE 18.5M 24 \n__AUTH 1859K 163 \n__AUTH_CONST 10.8M 319 \n__DATA 24.5M 440 \n__DATA_CONST 14.3M 442 \n__DATA_DIRTY 704K 111 \n__FONT_DATA 4K 1 \n__LINKEDIT 602.7M 125 \n__OBJC_CONST 1477K 133 \n__OBJC_RO 82.9M 1 \n__OBJC_RW 3152K 1 \n__TEXT 327.2M 458 \n__UNICODE 592K 1 \ndyld private memory 1024K 1 \nmapped file 67.8M 14 \nshared memory 848K 15 \n=========== ======= ======= \nTOTAL 2.7G 2374 \nTOTAL, minus reserved VM space 1.4G 2374 \n",
"legacyInfo" : {
"threadTriggered" : {
"queue" : "com.apple.root.default-qos"
}
},
"trialInfo" : {
"rollouts" : [
{
"rolloutId" : "60da5e84ab0ca017dace9abf",
"factorPackIds" : {

  },
  "deploymentId" : 240000008
},
{
  "rolloutId" : "61af99aeda72d16a4beb7756",
  "factorPackIds" : {

  },
  "deploymentId" : 240000093
}

],
"experiments" : [

]
}
}

Model: MacBookPro18,3, BootROM 7459.101.2, proc 8:6:2 processors, 16 GB, SMC
Graphics: Apple M1 Pro, Apple M1 Pro, Built-In
Display: LG UltraFine, 4096 x 2304, Main, MirrorOff, Online
Memory Module: LPDDR5
AirPort: Wi-Fi, wl0: Feb 8 2022 01:51:44 version 20.90.39.0.8.7.114 FWID 01-510a2aee
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB2.1 Hub
USB Device: USB2.0 Hub
USB Device: USB2.0 Hub
USB Device: Digital Hifi Audio
USB Device: USB 2.0 BILLBOARD
USB Device: USB 10/100/1000 LAN
USB Device: USB3.0 Card Reader
USB Device: iPhone
USB Device: hub_device
USB Device: USB Controls
USB Device: USB Audio
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.

Finding the BLE device name

This might be a silly question, but I'm not able to find the printer (Using MacOS). Is there any particular way to know what the name of the BLE device is?

Other device names than GT01 are possible

I see you've hard-coded the device search to GT01, with my cat printer the device name is GB02.

I bought my cat printer from Wish.com, it's a "Wirelessly BT 203dpi Mini Thermal Printer Photo Label Memo Wrong Question Printing with USB Cable imprimante portable".

After some searching around and looking at other cat printer_-related_ projects, there are a few variations: GB01, GB02, GT01

Visually the device looks identical to yours. It uses the same iPrint software from the Google Play Store.

Changing the hard-coded GT01 to GB02 in ble.py seems to make the script work with my cat printer.

(venv) max@mbp catprinter % python print.py ~/Desktop/cool.png
โณ Applying Floyd-Steinberg dithering to image...
โœ… Done.
โœ… Read image: (384, 384) (h, w) pixels
โœ… Generated BLE commands: 19009 bytes
โณ Looking for a BLE device named GB02...
โœ… Got it. Address: EF9E8FA3-81D1-4426-9451-38AA6EB13B71: GB02
โณ Connecting to EF9E8FA3-81D1-4426-9451-38AA6EB13B71: GB02...
โœ… Connected: True; MTU: 248
โณ Sending 19009 bytes of data in chunks of 245 bytes...
โœ… Done.
(venv) max@mbp catprinter %

PXL_20210819_194603190

Halftone Encoding Algorithm is Broken

When using 'halftone' algorithm for image encoding, a Python error is present:

โณ Applying halftone dithering to image...
Traceback (most recent call last):
  File "/Projects/cat_printer_interface/catprinter/print-modified.py", line 80, in <module>
    custom()
  File "/Projects/cat_printer_interface/catprinter/print-modified.py", line 48, in custom
    data = cmds_print_img(bin_img, dark_mode=True)
  File "/Projects/cat_printer_interface/catprinter/catprinter/cmds.py", line 167, in cmds_print_img
    data += cmd_print_row(row)
  File "/Projects/cat_printer_interface/catprinter/catprinter/cmds.py", line 127, in cmd_print_row
    encoded_img = run_length_encode(img_row)
  File "/Projects/cat_printer_interface/catprinter/catprinter/cmds.py", line 101, in run_length_encode
    if val == last_val:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
โœ… Done.

$ python --version Python 3.10.2

Troublesooting bluez error

I get this everytime I try to print:

โณ Applying Floyd-Steinberg dithering to image...
โœ… Done.
โœ… Read image: (288, 384) (h, w) pixels
โœ… Generated BLE commands: 11085 bytes
โณ Connecting to 69:CE:2A:FF:B5:2A...
Traceback (most recent call last):
  File "/home/samthelion17/Desktop/catprinter/./print.py", line 83, in <module>
    main()
  File "/home/samthelion17/Desktop/catprinter/./print.py", line 79, in main
    asyncio.run(run_ble(data, device=args.device))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/samthelion17/Desktop/catprinter/catprinter/ble.py", line 80, in run_ble
    async with BleakClient(address) as client:
  File "/home/samthelion17/Desktop/catprinter/venv/lib/python3.10/site-packages/bleak/backends/client.py", line 61, in __aenter__
    await self.connect()
  File "/home/samthelion17/Desktop/catprinter/venv/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 278, in connect
    assert_reply(reply)
  File "/home/samthelion17/Desktop/catprinter/venv/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.NotAvailable] br-connection-profile-unavailable

My device looks exactly like yours but it's called SC03h-CE69, It is NOT recognized when I connect it via USB (I know some of these printers do get recognized)

Printing text

Hi,

thanks for the project I am having much fun with it.

I wanted to print a simple text message, without the binarization.
Do you have some advice for me on how I could achieve this.

CUPS support

Hi,
one thing could make this printer even more awesome: network printing!

What is the difficulty of creating a CUPS filter able to print through this cat thingy?

Can't print on uncommon printer model

According to the QR code information page that prints out, my device's name is YHK-9B51 (instead of the more common GB01, GB02, etc). It seems the last four digits of the device name come from the mac address which ends in :9B:51. However, when I use bleak to scan devices, what shows up under the name "YHK-9B51" has a completely different MAC address ending in :C4:AD. (Specifically, when I try to pair the printer in Windows, two copies of "YHK-9B51" show up. One pairs but doesn't connect, and the other always rejects a connection. I'm not sure if any of that info is helpful, it is just things I've found while troubleshooting.

Anyways, when I run the print script with devicename set to YHK-9B51, sometimes it exits with exception asyncio.exceptions.TimeoutError and other times it first says Connected: True; MTU: 508 and then exits with exception bleak.exc.BleakError: Characteristic 0000ae01-0000-1000-8000-00805f9b34fb was not found! Could this be a newer hardware revision that's not compatible with the program, and if so, is there any data I could provide to help support it? (Also, I also tried this on macOS 12 Monterey, but bleak does not show any devices whatsoever because bleak currently doesn't support Monterey: hbldh/bleak#635)

How can I fix this error?

(base) C:\Users\marce\catprinter>python printer.py test.jpg --devicename GB03
โณ Applying Floyd-Steinberg dithering to image...
โœ… Done.
โœ… Read image: (512, 384) (h, w) pixels
โœ… Generated BLE commands: 28803 bytes
โณ Looking for a BLE device named GB03...
โœ… Got it. Address: 91:24:97:5B:61:54: GB03
โณ Connecting to 91:24:97:5B:61:54: GB03...
Traceback (most recent call last):
File "C:\Users\marce\anaconda3\lib\asyncio\locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\marce\anaconda3\lib\asyncio\tasks.py", line 492, in wait_for
fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\marce\catprinter\printer.py", line 66, in
main()
File "C:\Users\marce\catprinter\printer.py", line 62, in main
loop.run_until_complete(run_ble(data, args.devicename, logger))
File "C:\Users\marce\anaconda3\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Users\marce\catprinter\catprinter\ble.py", line 36, in run_ble
async with BleakClient(address) as client:
File "C:\Users\marce\anaconda3\lib\site-packages\bleak\backends\client.py", line 61, in aenter
await self.connect()
File "C:\Users\marce\anaconda3\lib\site-packages\bleak\backends\winrt\client.py", line 219, in connect
await asyncio.wait_for(event.wait(), timeout=timeout)
File "C:\Users\marce\anaconda3\lib\asyncio\tasks.py", line 494, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

pip install in Linux errors because pyobjc for MacOS only?

Trying to pip install -r requirements.txt on the following environment:

  • Ubuntu 20.04
  • Python 3.8.11 installed in Miniconda environment

Gives the following output:

(catprinter) david@Ubuntu-Main:~/catprinter$ pip install -r requirements.txt 
Collecting appnope==0.1.2
  Downloading appnope-0.1.2-py2.py3-none-any.whl (4.3 kB)
Collecting autopep8==1.5.7
  Downloading autopep8-1.5.7-py2.py3-none-any.whl (45 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 45 kB 2.7 MB/s 
Collecting backcall==0.2.0
  Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Collecting bleak==0.12.1
  Downloading bleak-0.12.1-py2.py3-none-any.whl (123 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 123 kB 7.0 MB/s 
Collecting decorator==5.0.9
  Downloading decorator-5.0.9-py3-none-any.whl (8.9 kB)
Collecting jedi==0.18.0
  Downloading jedi-0.18.0-py2.py3-none-any.whl (1.4 MB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 1.4 MB 52.3 MB/s 
Collecting matplotlib-inline==0.1.2
  Downloading matplotlib_inline-0.1.2-py3-none-any.whl (8.2 kB)
Collecting numpy==1.21.1
  Downloading numpy-1.21.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 15.8 MB 25.0 MB/s 
Collecting opencv-contrib-python==4.5.3.56
  Downloading opencv_contrib_python-4.5.3.56-cp38-cp38-manylinux2014_x86_64.whl (56.1 MB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 56.1 MB 37.9 MB/s 
Collecting parso==0.8.2
  Downloading parso-0.8.2-py2.py3-none-any.whl (94 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 94 kB 9.3 MB/s 
Collecting pexpect==4.8.0
  Downloading pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 59 kB 25.8 MB/s 
Collecting pickleshare==0.7.5
  Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting prompt-toolkit==3.0.19
  Downloading prompt_toolkit-3.0.19-py3-none-any.whl (368 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 368 kB 42.8 MB/s 
Collecting ptyprocess==0.7.0
  Downloading ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting pycodestyle==2.7.0
  Downloading pycodestyle-2.7.0-py2.py3-none-any.whl (41 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 41 kB 2.5 MB/s 
Collecting Pygments==2.9.0
  Using cached Pygments-2.9.0-py3-none-any.whl (1.0 MB)
Collecting pyobjc-core==7.3
  Downloading pyobjc-core-7.3.tar.gz (684 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 684 kB 26.6 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /home/david/.miniconda3/envs/catprinter/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5mcpi8rx/pyobjc-core_cfe5e073d2034c1e9dcdb6813915c6b2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5mcpi8rx/pyobjc-core_cfe5e073d2034c1e9dcdb6813915c6b2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-a94s4x5_
         cwd: /tmp/pip-install-5mcpi8rx/pyobjc-core_cfe5e073d2034c1e9dcdb6813915c6b2/
    Complete output (2 lines):
    running egg_info
    error: PyObjC requires macOS to build
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/50/eb/a358e36731f5cb3b824ca27d2260f7f6acbd0d1f63c971ca83b4627d9ec6/pyobjc-core-7.3.tar.gz#sha256=5081aedf8bb40aac1a8ad95adac9e44e148a882686ded614adf46bb67fd67574 (from https://pypi.org/simple/pyobjc-core/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement pyobjc-core==7.3 (from versions: 2.2b1, 2.2b2, 2.2, 2.3, 2.4, 2.5.1, 3.0.1, 3.0.3, 3.0.4, 3.1, 3.1.1, 3.2, 3.2.1b1, 3.2.1, 4.0b1, 4.0, 4.0.1, 4.1, 4.2, 4.2.1, 4.2.2, 5.0a1, 5.0b1, 5.0, 5.1, 5.1.1, 5.1.2, 5.2, 5.3, 6.0, 6.0.1, 6.1, 6.2, 6.2.1, 6.2.2, 7.0, 7.0.1, 7.1, 7.2, 7.3, 8.0b1)
ERROR: No matching distribution found for pyobjc-core==7.3

Removing all the "pyobj" dependencies from requirements.txt installs successfully all the dependencies, and the application works perfectly ๐Ÿคฉ

I guess that requirement is only for MacOS clients? In that case, maybe could be interesting to:

a) Advice about this on README
b) Provide a base requirements.txt without these dependencies, and another file with MacOS exclusive dependencies
c) Use conditionals in requirements.txt, this may work? https://stackoverflow.com/a/35614580/11245195

What do you think?

cmd_feed_paper, cmd_set_energy, dark_mode seem to have no effect

When trying to implement cmd_set_energy and cmd_feed_paper in my own application, changing the values used in cmds_print_img function appears to have no effect. The paper doesn't feed any further, and/or the text is not any darker if I increase the values in these fields.

Printing a demo page from the iOS App (or the built-in debug QR code print mechanism) provides much darker prints than printing a black text on white BG PNG from catprinter. I suspect that these values are not being properly set when I print from the function vs. the App.

Printer model: GB02

Problem with preview: TypeError: ufunc 'invert' not supported for the input types


$ python3 ./print.py -b none -s ~/cat.png
Traceback (most recent call last):
  File "/home/user/build/catprinter/./print.py", line 83, in <module>
    main()
  File "/home/user/build/catprinter/./print.py", line 69, in main
    show_preview(bin_img)
  File "/home/user/build/catprinter/catprinter/img.py", line 143, in show_preview
    preview_img = ~bin_img.astype(float)
TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

cat

Difficulties printing YHK model

I tried printing with this script.
It will connect to my printer but it errors out with the following error:

I'm using endeavourOS (arch linux) on a Dell Latitude E5450

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/bleak/backends/bluezdbus/client.py", line 209, in connect
    reply = await self._bus.call(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/dbus_fast/aio/message_bus.py", line 384, in call
    await future
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/sven/Thermal printer/catprinter-main/print.py", line 83, in <module>
    main()
  File "/home/sven/Thermal printer/catprinter-main/print.py", line 79, in main
    asyncio.run(run_ble(data, device=args.device))
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/sven/Thermal printer/catprinter-main/catprinter/ble.py", line 80, in run_ble
    async with BleakClient(address) as client:
  File "/usr/lib/python3.12/site-packages/bleak/__init__.py", line 565, in __aenter__
    await self.connect()
  File "/usr/lib/python3.12/site-packages/bleak/__init__.py", line 605, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/bleak/backends/bluezdbus/client.py", line 146, in connect
    async with async_timeout(timeout):
  File "/usr/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

Printing is very light

All images are printed with no dithering in -t mode. On the left is a color image of a frog. In the center is a test all-black image. On the right is a test page the printer auto-printed when it turned on.

PXL_20230422_224138701 MP-crop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.