initial
commit
eff4ec5f68
@ -0,0 +1,33 @@
|
|||||||
|
import serial
|
||||||
|
|
||||||
|
ser = serial.Serial(
|
||||||
|
port='/dev/ttyUSB0',
|
||||||
|
baudrate=3000000,
|
||||||
|
parity=serial.PARITY_NONE,
|
||||||
|
stopbits=serial.STOPBITS_ONE,
|
||||||
|
bytesize=serial.SEVENBITS,
|
||||||
|
timeout=0.1
|
||||||
|
)
|
||||||
|
|
||||||
|
one = 0xfe
|
||||||
|
zero = 0xe0
|
||||||
|
stop = 0xfe
|
||||||
|
|
||||||
|
status = bytes([zero, zero, zero, zero, zero, zero, zero, zero, stop])
|
||||||
|
poll = bytes([zero, zero, zero, zero, zero, zero, zero, one, stop])
|
||||||
|
|
||||||
|
ser.write(status)
|
||||||
|
ret=ser.read(30)
|
||||||
|
print(' '.join('{:02x}'.format(x) for x in ret))
|
||||||
|
|
||||||
|
while(1):
|
||||||
|
ser.write(poll)
|
||||||
|
ret=ser.read(50)
|
||||||
|
print(' '.join('{:02x}'.format(x) for x in ret))
|
||||||
|
if(ret[8] & 0xE0):
|
||||||
|
print("A")
|
||||||
|
if(ret[9] & 0xF0 == 0x70):
|
||||||
|
print("B")
|
||||||
|
if(ret[10] & 0x0F == 0x0e):
|
||||||
|
print("Z")
|
||||||
|
ser.flush()
|
||||||
Loading…
Reference in New Issue