-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_analyse.py
executable file
·60 lines (53 loc) · 1.61 KB
/
debug_analyse.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python2
#coding:utf8
import serial, sys, time
if "-bt05" in sys.argv:
port = serial.Serial('/dev/ttyS0', baudrate=9600, timeout=0.2)
port.write("AT+ROLE\r\n");
ROLE=port.readall()
if ROLE.strip()=="+ROLE=0":
port.write("AT+ROLE1\r\n");
ROLE=port.readall()
if ROLE.strip()!="+ROLE=1":
print "Error master mode selected"
exit(-1)
port.write("AT+BAND\r\n");
CONN=port.readall()
if not ("Connected" in CONN):
ind=sys.argv.index("-bt05")
if len(sys.argv) > ind+1:
bt_addr=sys.argv[ind+1]
try:
int(bt_addr,16)
except:
print "Address of connecting device must be hex!"
exit(-3)
port.write("AT+BAND%s\r\n" %(bt_addr));
# port.write("AT+BAND\r\n");
time.sleep(1)
CONN=port.readall()
print CONN
if "Connected" not in CONN:
print "Error connection device"
exit(-2)
else:
print "Scanning devices: ...."
port.write("AT+INQ\r\n");time.sleep(1);
SCAN=port.readall()
print SCAN
exit(0)
from interact import *
interact=interact()
if "-g" in sys.argv:
interact.debug=1;
sys.argv.remove("-g")
else:
debug=None;
# Example commands: ./debug_analyse.py Rw:2000080c
if len(sys.argv)>1:
print interact.interact(sys.argv[1])
#cmd = interact.cmd_gen(sys.argv[1])
#interact.transmit_cmd(cmd)
if not interact.R: # Command without read
exit(0)
print interact.recieve_ans()