Revision 1932 trunk/code/projects/calibration_platform/server/cal_sta_server.py

View differences:

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