-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtele.py
More file actions
45 lines (35 loc) · 747 Bytes
/
tele.py
File metadata and controls
45 lines (35 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import serial
import time
import sys
def sendData(input):
ser.write(input + '\r\n')
outstr = ''
time.sleep(1.1)
while ser.inWaiting() > 0:
outstr += ser.read(1)
if outstr != '':
print outstr
def read():
while True:
outstr = ''
while ser.inWaiting() > 0:
outstr += ser.readline(1)
#for str in outstr:
# sys.stdout.write(hex(ord(str)))
#print "--"
if outstr != '':
sys.stdout.write( outstr)
sys.stdout.flush()
outstr = ''
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate=9600,
parity=serial.PARITY_ODD,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.SEVENBITS
)
print "start"
read()
#ser.isOpen()
#sendData("+++")
#sendData("ATI")