root / trunk / code / projects / calibration_platform / server / cal_sta_server.py @ 1932
History | View | Annotate | Download (503 Bytes)
1 | 1926 | jsexton | #!/usr/bin/python
|
---|---|---|---|
2 | import sys, serial |
||
3 | |||
4 | try:
|
||
5 | 1932 | jsexton | serial0 = serial.Serial(port='/dev/ttyUSB0', baudrate=19200) # Adruino |
6 | serial1 = serial.Serial(port='/dev/ttyUSB1', baudrate=115200) # Robot |
||
7 | 1926 | jsexton | except serial.SerialException as e: |
8 | print 'Error: %s' % e |
||
9 | sys.exit(0)
|
||
10 | |||
11 | while True: |
||
12 | 1932 | jsexton | 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 |
||
22 | 1926 | jsexton | |
23 | usb.close() |