@@ -0,0 +1,1700 @@
+#!/usr/bin/env python%0A# -*- coding: utf8 -*-%0A#%0A# Copyright (c) 2013 Nautilabs%0A#%0A# Licensed under the MIT License,%0A# https://github.com/baptistelabat/robokite%0A# Authors: Baptiste LABAT%0Aimport time%0Aimport serial%0Aimport numpy as np%0A%0Adef computeXORChecksum(chksumdata):%0A%09# Inspired from http://doschman.blogspot.fr/2013/01/calculating-nmea-sentence-checksums.html%0A    # Initializing XOR counter%0A    csum = 0%0A    %0A    # For each char in chksumdata, XOR against the previous %0A    # XOR char.  The final XOR of the last char will be the%0A    # checksum  %0A    for c in chksumdata:%0A        # Makes XOR value of counter with the next char in line%0A        # and stores the new XOR value in csum%0A        csum %5E= ord(c)%0A    h = hex(csum)    %0A    return h%5B2:%5D#get hex data without 0x prefix%0A    %0A%0Adt = 0.1%0Alocations=%5B'/dev/ttyACM0','/dev/ttyACM1','/dev/ttyACM2','/dev/ttyACM3','/dev/ttyACM4','/dev/ttyACM5','/dev/ttyUSB0','/dev/ttyUSB1','/dev/ttyUSB2','/dev/ttyUSB3','/dev/ttyS0','/dev/ttyS1','/dev/ttyS2','/dev/ttyS3'%5D%0Afor device in locations:%0A  try:%0A    print %22Trying...%22, device%0A    ser = serial.Serial(device, 19200)%0A    print %22Connected on %22, device%0A    break%0A  except:%0A    print %22Failed to connect on %22, device%0Atime.sleep(1.5)%0Aser.write('i1')%0At0 = time.time()%0An = 0%0Awhile True:%0A  n = n+1%0A  t = time.time()-t0%0A  print %22n= %22, n, %22, t= %22, t%0A  order = 0.3*np.sin(t)%0A  alpha = np.round(order, 2)%0A  msg = %22ORPWM%22+%22,%22+str(alpha)%0A  msg = %22$%22+msg +%22*%22+ computeXORChecksum(msg) + chr(13).encode('ascii')%0A  print msg%0A  ser.write(msg)%0A  try:%0A    line = ser.readline()%0A    print %22Received from arduino: %22, line%0A  except Exception, e:%0A    print(%22Error reading from serial port%22 + str(e))%0A%09  %0A  time.sleep(dt)%0A3%0Aser.close()%0A

Add a script to check motor (and communication!)