-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
43 lines (29 loc) · 752 Bytes
/
test.py
File metadata and controls
43 lines (29 loc) · 752 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
import USB
import USB
import sys
import time
from bitarray import bitarray
def callback(data):
print(data)
usb = USB.USB(10, 10, 15)
temp = bytearray()
#control test
#turn on led
usb.writeControl(1,0xc0,0,0,16,temp)
time.sleep(2)
#turn off led
usb.writeControl(0,0xc0,0,0,16,temp)
time.sleep(1)
#read data
temp = bytearray(" ")
print(usb.readControl(2,0xC0,0,0,16,temp))
#write data in value and index
#usb.writeControl(3, 0xc0, ord("e") + (ord("t")<<8), ord("t") + (ord("s")<<8), 16)
#read data
print(usb.readControl(2,0xC0,0,0,16,temp))
#write new data
data = bytearray("wla wla ")
usb.writeControl(4,0x40,0,0,16,data)
#read data
temp = bytearray(" ")
print(usb.readControl(2,0xC0,0,0,16,temp))