Open saharmor opened 6 months ago
Just a quick check: did you run the code only as written in your post? Because the code in your post won't work: as soon as it's done sending the first package from the print_image('image.jpg')
command, python will quit. We need Python to stay active and listen for the printer's response, which indicate if it can send the next part of the image.
That is why in the example (just run python3 InstaxBLE.py
) there is a sleep()
command:
finally:
sleep(60)
instax.disconnect() # all done, disconnect
This will make sure Python stays active for at least 60 seconds, during which it can receive printer responses and reply to them by sending the next part of the image.
This isn't the most refined way of handling things, I'll see if I can implement some sort of threading in the future. See issue #11
Just checking in to see if you've had time to try this, @saharmor. Would be great to know if this was indeed the problem :)
@javl Instax Mini 2 works after adding the sleep(60). Anyway, thanks for the cool library, i can now print it using python
Hi I have tried to connect to my instax mini link 2 using the demo function from the InstaxBLE file and it seems like some UUID is not found .
def test():
instax = InstaxBLE(device_address="88:B4:36:XX:XX:XX",verbose= True)
try:
# To prevent misprints during development this script sends all the
# image data except the final 'go print' command. To enable printing
# uncomment the next line, or pass --print-enabled when calling
# this script
# instax.enable_printing()
instax.connect()
# instax.deviceName()
# Set a rainbow effect to be shown while printing and a pulsating
# green effect when printing is done
instax.send_led_pattern(LedPatterns.rainbow, when=1)
instax.send_led_pattern(LedPatterns.pulseGreen, when=2)
# you can also read the current accelerometer values if you want
# while True:
# instax.get_printer_orientation()
# sleep(.5)
# send your image (.jpg) to the printer by
# passing the image_path as an argument when calling
# this script, or by specifying the path in your code
if instax.image_path:
instax.print_image(instax.image_path)
else:
instax.print_image(instax.printerSettings['exampleImage'])
except Exception as e:
print(type(e).__name__, __file__, e.__traceback__.tb_lineno)
instax.log(f'Error: {e}')
finally:
sleep(60)
print('finally, disconnect')
instax.disconnect() # all done, disconnect
test()
This is the console output :
Connecting to INSTAX-4211XXX(ANDROID) [88:B4:36:XX:XX:XX]
Connected
Error on attaching notification_handler: Service with UUID 70954782-2d83-473d-9e5f-81e1d02d5273 not found.
RuntimeError /home/XXXX/XXXX/instax-printing/printing-worker/main.py 55
Error: Service with UUID 70954782-2d83-473d-9e5f-81e1d02d5273 not found.
finally, disconnect
Process finished with exit code 0 ```
This error in trowed from line 214 in InstaxBLE.py file .
Maybe can you give me some info about how can I find the correct UUID
That's odd, @buj99
Can you try adding instax.print_services()
to the code? This should print an overview of all available endpoints.
def test():
instax = InstaxBLE(verbose=True)
try:
instax.connect()
instax.print_services()
except Exception as e:
print(type(e).__name__, __file__, e.__traceback__.tb_lineno)
instax.log(f'Error: {e}')
finally:
sleep(60)
print('finally, disconnect')
instax.disconnect() # all done, disconnect
@javl It gives me the same error :
Searching for instax printer... Connecting to INSTAX-42113XXX(ANDROID) [88:B4:36:XX:XX:XX] Connected Error on attaching notification_handler: Service with UUID 70954782-2d83-473d-9e5f-81e1d02d5273 not found. Successfully connected, listing services... RuntimeError /home/buj/Projects/testbanch/instax-test/main.py 21 Error: Service with UUID 70954782-2d83-473d-9e5f-81e1d02d5273 not found.
Also I observed in the Bluetooth settings that the connection is closed after 1-2 seconds , it might be a Bluetooth drive issue. It would be very helpful to point me where I can find some logs for the Bluetooth if you can :D . I have installed Ubuntu on another device and tested it and the connection seems to be right . I'm going to do some more digging and post the results here if I find something .
Thx for the reply
Ah yeah, I see it already attaches inside the connect()
method.
You could try calling the print_services()
directy after connecting, before it tries to attach the handlers:
Around this line: https://github.com/javl/InstaxBLE/blob/e9f1d0c1c3898832bebe2fed2b64f80ae89144f2/InstaxBLE.py#L208
But, if you say it works on a different system the address shouldn't be the problem. Would be great if you can report back if you find a solution.
This is the output , not very helpful i guess :))
/usr/bin/python3.10 /home/buj/Projects/testbanch/instax-test/main.py Searching for instax printer... Connecting to INSTAX-4211XXXX(ANDROID) [88:B4:36:XX:XX:XX] Successfully connected, listing services... Connected Error on attaching notification_handler: Service with UUID 70954782-2d83-473d-9e5f-81e1d02d5273 not found. Successfully connected, listing services... RuntimeError /home/buj/Projects/testbanch/instax-test/main.py 21 Error: Service with UUID 70954782-2d83-473d-9e5f-81e1d02d5273 not found.
I'm going dig some more on the driver side of things .
Hey, I'm trying to print an image from my Mac using this Python SDK to no avail.
My spec MacBook Pro M2 Max
Code
Terminal output
I've put a few prints in InstaxBLE.py and this code is being called (line 399):
Followed by line 409:
So I'm not sure what's the problem.