The way this script works is that we send a message to the printer, and receive a response in a listener function, which then triggers sending the next message to the printer.
Problem here is that Python thinks we're done as soon as we've send our message, and exists the script. To prevent this I've added an ugly hack by calling sleep(60), which keeps our script running for at least a minute. During this time the listener is still active and can respond to messages from the printer.
It would be great if we could somehow get rid of this hack and implement a better way of making sure we're done before exiting.
The way this script works is that we send a message to the printer, and receive a response in a listener function, which then triggers sending the next message to the printer.
Problem here is that Python thinks we're done as soon as we've send our message, and exists the script. To prevent this I've added an ugly hack by calling
sleep(60)
, which keeps our script running for at least a minute. During this time the listener is still active and can respond to messages from the printer.It would be great if we could somehow get rid of this hack and implement a better way of making sure we're done before exiting.