Created
February 5, 2016 14:28
-
-
Save Overdrivr/9a7582e4bd710b45e0e9 to your computer and use it in GitHub Desktop.
Print received values from a telemetry-enabled serial connection using pytelemetry
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
import pytelemetry as tm | |
import pytelemetry.transports.serialtransport as transports | |
import time | |
def printer(topic, data): | |
print(topic," : ", data) | |
transport = transports.SerialTransport() | |
c = tm.pytelemetry(transport) | |
options = dict() | |
options['port'] = "COM20" | |
options['baudrate'] = 9600 | |
transport.connect(options) | |
c.subscribe(None, printer) | |
timeout = time.time() + 3 | |
while True: | |
c.update() | |
if time.time() > timeout: | |
break | |
transport.disconnect() | |
print("Done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment