Project

General

Profile

Revision 1932

Renamed arduino file name. Python script can read from both robot and arduino at the same time.

View differences:

trunk/code/projects/calibration_platform/station/cal_sta_station/cal_sta_station.pde
1

  
2
void setup() {
3
  Serial.begin(9600);    // Actual baud rate appears to be 19200
4
}
5

  
6
void loop() {
7
  Serial.print("ST:Robo\n");
8
  delay(1000);
9
  Serial.print("ST:Club\n");
10
  delay(1000);
11
  Serial.print("ST:Colony\n");
12
  delay(1000);
13
}
trunk/code/projects/calibration_platform/robot/cal_sta_robot.c
26 26
	while (1) {
27 27
		/* Drive left, set orbs, and wait */
28 28
		orbs_set_color(RED, GREEN);
29
        usb_puts("Robot\n");
29
        usb_puts("RO:Robot\n");
30 30
        delay_ms(TIME_DELAY);
31 31

  
32 32
		/* Drive right, change orb colors, and wait */
33 33
		orbs_set_color(PURPLE, BLUE);
34
        usb_puts("Marvin\n");
34
        usb_puts("RO:Marvin\n");
35 35
		delay_ms(TIME_DELAY);
36 36
	}
37 37

  
trunk/code/projects/calibration_platform/server/cal_sta_server.py
2 2
import sys, serial
3 3

  
4 4
try:
5
#usb = serial.Serial(port='/dev/ttyUSB0', baudrate=19200) # Adruino
6
	usb = serial.Serial(port='/dev/ttyUSB1', baudrate=115200) # Robot
5
	serial0 = serial.Serial(port='/dev/ttyUSB0', baudrate=19200)    # Adruino
6
	serial1 = serial.Serial(port='/dev/ttyUSB1', baudrate=115200)   # Robot
7 7
except serial.SerialException as e:
8 8
	print 'Error: %s' % e
9 9
	sys.exit(0)
10 10

  
11 11
while True:
12
	if usb.inWaiting() > 0:
13
		print usb.read()
12
	if serial0.inWaiting() > 0:
13
		try:
14
			print serial0.read()
15
		except OSError as e:
16
			print 'Error: %s' %e
17
	if serial1.inWaiting() > 0:
18
		try:
19
			print serial1.read()
20
		except OSError as e:
21
			print 'Error: %s' %e
14 22

  
15 23
usb.close()

Also available in: Unified diff