Skip to content

Instantly share code, notes, and snippets.

@Harakan
Created December 6, 2015 01:28
Show Gist options
  • Save Harakan/35dd924ad23fdfc4d185 to your computer and use it in GitHub Desktop.
Save Harakan/35dd924ad23fdfc4d185 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import time
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
from peachyprinter.infrastructure.communicator import UsbPacketCommunicator
from peachyprinter.infrastructure.messages import *
class TestCommunication(object):
def __init__(self):
self._usb = UsbPacketCommunicator(10)
self._usb.register_handler(IAmMessage, self.i_am_handler)
self._usb.start()
self._usb.send(IdentifyMessage())
time.sleep(0.1)
self._usb.send(EnterBootloaderMessage())
time.sleep(0.1)
self._usb.close()
def i_am_handler(self, message):
print('Serial number: {0}'.format(message.sn))
if __name__ == '__main__':
t = TestCommunication()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment