-
Notifications
You must be signed in to change notification settings - Fork 0
/
I2C_master.py
49 lines (42 loc) · 1.11 KB
/
I2C_master.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
'''
Pins used:
Arduino 1 | Arduino 2 | Buspirate
A4 --> A4 --> MOSI
A5 --> A5 --> CLK
5V --> Vin --> Vp
GND --> GND --> GND
'''
import time
import serial
ser=serial.Serial('COM9',115200,timeout=1)
ser.write(str('#' + '\n').encode('ascii'))
time.sleep(0.3)
ser.write(str('m' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.3)
ser.write(str('4' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.3)
ser.write(str('\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.3)
ser.write(str('W' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.3)
ser.write(str('P' + '\n').encode('ascii'))
for i in ser.readlines():
print(i.strip())
time.sleep(0.3)
print('Sniffing Traffic....',end='')
ser.write(str('(2)' + '\n').encode('ascii'))
time.sleep(6)
print('..')
ser.write(str('q' + '\n').encode('ascii'))
x = ser.readlines(1000)
print((str(x[3])[2::])[:-5:])
ser.write(str('#' + '\n').encode('ascii'))
ser.close()