File: cc128_read.py

package info (click to toggle)
mosquitto 2.0.22-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,572 kB
  • sloc: ansic: 51,107; python: 15,095; xml: 7,187; makefile: 1,821; cpp: 1,541; sh: 320; perl: 70
file content (22 lines) | stat: -rwxr-xr-x 391 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python -u

import mosquitto
import serial

usb = serial.Serial(port='/dev/ttyUSB0', baudrate=57600)

mosq = mosquitto.Mosquitto()
mosq.connect("localhost")
mosq.loop_start()

running = True
try:
    while running:
        line = usb.readline()
        mosq.publish("sensors/cc128/raw", line)
except usb.SerialException, e:
    running = False

mosq.disconnect()
mosq.loop_stop()