7 Define the basic classes and rotines to a sensor
10 from startx
import BREAK_MSP, DIRECTION_MSP, VELOCITY_MSP, ALL_VALUES
14 """docstring for Device"""
28 """ Enable the sensor """
33 """ Desable the sensor """
40 return self.serial.readline()
45 """docstring for Passive"""
48 super(Active, self).
__init__(terminal)
49 self.
data = self.serial.readline()
50 self.
data = self.data.split(
'\n')[0]
53 """ Return actual data from device """
54 self.serial.write(str(command))
55 self.serial.write(str(data))
63 """docstring for Active"""
66 super(Passive, self).
__init__(terminal)
67 self.
data = self.serial.readline()
68 self.
data = self.data.split(
'\n')[0]
71 """ Send some data to device """
72 self.serial.write(str(command))
73 self.
data = self.serial.readline()
74 self.
data = self.data.split(
'\n')[0]
82 """docstring for Break"""
84 super(Break, self).
__init__(terminal)
89 if (data >= 0)
and (data <= 9):
94 """docstring for Direction"""
95 def __init__(self,terminal, arg=DIRECTION_MSP):
96 super(Direction, self).
__init__(terminal)
104 """docstring for Velocity"""
106 super(Velocity, self).
__init__(terminal)
114 """docstring for Passives"""
116 super(Passives, self).
__init__(terminal)
122 if __name__ ==
'__main__':
124 from glob
import glob
125 PORTS_AVAILABLE = glob(
'/dev/ttyUSB*') + glob(
'/dev/ttyACM*')
126 print PORTS_AVAILABLE
127 ser = serial.Serial(PORTS_AVAILABLE[0], 4800)
129 print act.write_data(
'r', 't')
131 print passive.read_data(
'g')