# -*- coding: utf-8 -*-

import sys
import serial
import config
import time

port = '/dev/tty.usbmodemfd131'
ser = serial.Serial(port, 9600)

def send(text):
    #time.sleep(2)
    #print ser.readline()
    text += '\n'
    ser.write(text)
    print ">", text
    ser.close()

def read():
    try:
        while True:
            line = ser.readline().strip()
            print "<", line
    except KeyboardInterrupt:
        print "Terminated by user"
    finally:
        ser.close()

def send_and_read():
    print 'Type "quit" to exit'
    #print "<", ser.readline()
    text = ""
    while text != "quit":
        text = raw_input("> ")
        ser.write(text + '\n')
        print "<", ser.readline().strip()
@@ -70,16 +70,33 @@
 t time%0A%0A
+import dispatch%0A%0A
 port = '
@@ -398,16 +398,300 @@
 %22, line%0A
+            if (len(line.split()) == 3):%0A                switch, group, command = line.split()%0A                if switch == %22device%22:%0A                    dispatch.device(group, command);%0A                elif switch == %22activity%22:%0A                    dispatch.activity(group, command)%0A
     exce

Use dispatch in arduino read