Skip to content

Instantly share code, notes, and snippets.

@theterg
Created December 18, 2013 20:31
Show Gist options
  • Select an option

  • Save theterg/8029406 to your computer and use it in GitHub Desktop.

Select an option

Save theterg/8029406 to your computer and use it in GitHub Desktop.
Found some data on a UART channel connecting the sensor board to the bluetooth/main MCU on a Mio Alpha watch. Wrote a quick script to assist in viewing the data on this bus.
'''
MioDecode.py
Reads data from the internal serial bus of a Mio Alpha and prints the BPM to screen.
Dependences:
-pyserial
Usage:
python.exe MioDecode.py --port='<serial port>' --baud=<baud rate>
'''
import serial
import argparse
import sys
import time
parser = argparse.ArgumentParser(description='Consume CSV data from a serial port')
parser.add_argument('--port', type=str, default='com7', help='The serial port to open')
parser.add_argument('--baud', type=int, default=19200, help='The baud rate to use')
args = parser.parse_args()
ser = serial.Serial(args.port, args.baud)
ser.setTimeout(1.0)
def waitForStartChar():
c = ' '
while c != 'o':
c = ser.read().decode('utf-8')
waitForStartChar()
start = time.time()
while(1):
try:
waitForStartChar()
pkt = ser.read(6)
except:
print (sys.exc_info())
break
if len(pkt) != 6:
continue
print("%.3f: %02x %02x %02x %02x %02x %02x BPM: %d" % ((time.time() - start), pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[5]))
ser.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment