Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Get acceleration data from Chronos watch.
- #Taken from info posted at: http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/32714.aspx
- #x, y, and z values may not be "in order". The first three bytes from the packet
- #of data sent from the watch seemed to be different than what was listed
- #on the page, though the datatype byte was in the correct place. So YMMV.
- #
- #Written by Sean Brewer (seabre)
- #seabre986@gmail.com
- #
- import serial
- import array
- def startAccessPoint():
- return array.array('B', [0xFF, 0x07, 0x03]).tostring()
- def accDataRequest():
- return array.array('B', [0xFF, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00]).tostring()
- #Open COM port 6 (check your system info to see which port
- #yours is actually on.)
- #argments are 5 (COM6), 115200 (bit rate), and timeout is set so
- #the serial read function won't loop forever.
- ser = serial.Serial(5,115200,timeout=1)
- #Start access point
- ser.write(startAccessPoint())
- while True:
- #Send request for acceleration data
- ser.write(accDataRequest())
- accel = ser.read(7)
- if len(accel) != 7 or (ord(accel[0]) == 0 and ord(accel[1]) == 0 and ord(accel[2]) == 0):
- continue
- print "x: " + str(ord(accel[2])) + " y: " + str(ord(accel[1])) + " z: " + str(ord(accel[0]))
- print "Datatype: " + str(ord(accel[3]))
- ser.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement