Skip to content

Commit 55f70e8

Browse files
committed
Tiny Code Reader
1 parent 9aab8ad commit 55f70e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

python3/samples/tcr.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
import struct
3+
from i2cdriver import I2CDriver
4+
5+
class TCR:
6+
pass
7+
8+
if __name__ == '__main__':
9+
i2 = I2CDriver(sys.argv[1])
10+
i2.setspeed(400)
11+
i2.scan()
12+
while 1:
13+
i2.start(0x0c, 1)
14+
b = i2.read(256)
15+
i2.stop()
16+
(l, ) = struct.unpack("<H", b[0:2])
17+
s = b[2:2+l]
18+
if l:
19+
print(s)
20+
else:
21+
print('nothing')

0 commit comments

Comments
 (0)