~roger.light/ubuntu/vivid/mosquitto/fix-for-1423037

« back to all changes in this revision

Viewing changes to misc/currentcost/cc128_read.py

  • Committer: Bazaar Package Importer
  • Author(s): Roger A. Light
  • Date: 2011-05-01 20:12:51 UTC
  • Revision ID: james.westby@ubuntu.com-20110501201251-omjk4eyw5hmx0v2j
Tags: upstream-0.10
ImportĀ upstreamĀ versionĀ 0.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python -u
 
2
 
 
3
import serial
 
4
import shlex
 
5
import subprocess
 
6
 
 
7
pub_cmd = "mosquitto_pub -t cc128/raw -l -q 2"
 
8
pub_args = shlex.split(pub_cmd)
 
9
pub = subprocess.Popen(pub_args, stdin=subprocess.PIPE)
 
10
 
 
11
usb = serial.Serial(port='/dev/ttyUSB0', baudrate=57600)
 
12
 
 
13
 
 
14
running = True
 
15
try:
 
16
        while running:
 
17
                line = usb.readline()
 
18
                pub.stdin.write(line)
 
19
                pub.stdin.flush()
 
20
except usb.SerialException, e:
 
21
        running = False
 
22
 
 
23
pub.stdin.close()
 
24
 
 
25
pub.wait()
 
26