Created
December 6, 2015 01:28
-
-
Save Harakan/35dd924ad23fdfc4d185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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